def test_estimate_partial_transform():
    expected = [29.999978200505126, 29.999898169013868, 1.0278229229761564e-06]

    matched_keypoints = utils.match_keypoints(optical_flow, frame_1_kps)
    partial_transform = utils.estimate_partial_transform(matched_keypoints)

    assert np.allclose(partial_transform, expected, rtol=0.1)
def test_none_optical_flow():
    prev_gray = np.ones((1208, 1920, 3)) * 250
    current_frame_gray = np.ones((1208, 1920, 3)) * 250
    prev_kps = np.array([], dtype='float32')
    # noinspection PyArgumentList
    prev_kps = prev_kps.reshape(0, 1, 2)

    none_optical_flow = cv2.calcOpticalFlowPyrLK(prev_gray,
                                                 current_frame_gray,
                                                 prev_kps,
                                                 None)

    matched_keypoints = utils.match_keypoints(none_optical_flow, prev_kps)
    transform_i = utils.estimate_partial_transform(matched_keypoints)

    assert transform_i == [0, 0, 0]