def crop_img(img, relative_corners):
    """ relative_corners are floats between 0 and 1 designating where the corners of a crop box
    should be ([[top_left_x, top_left_y], [bottom_right_x, bottom_right_y]]).

    e.g. [[0, 0], [1, 1]] would be the full image, [[0.5, 0.5], [1, 1]] would be bottom right."""
    rc = relative_corners
    raw_height, raw_width = img.shape[:2]
    top_left_pix = [int(rc[0][0] * raw_width), int(rc[0][1] * raw_height)]
    bottom_right_pix = [int(rc[1][0] * raw_width), int(rc[1][1] * raw_height)]
    img_cropped = img[top_left_pix[1]:bottom_right_pix[1], top_left_pix[0]:bottom_right_pix[0]]
    return img_cropped