def roi_square(roi):
    """
    Contract the larger dimension of the rectangle make the ROI dimensions square
    """
    x, y, w, h = roi
    if w > h:
        x += int((w-h)/2.0)
        w = h
    elif h > w:
        y += int((h-w)/2.0)
        h = w
    return x, y, w, h