# dl.download_ostrich_video(download_to_path)
# stabilizer = VidStab()
# stabilizer.gen_transforms(download_to_path)
# download_to_path = f'{tmp_dir.name}/test_video.mp4'
# dl.download_skateline_video(download_to_path)
# stabilizer.apply_transforms(download_to_path,
#                             'stable.avi',
#                             border_size='auto',
#                             playback=True)


##################################################################
# TEST TYPICAL STABILIZATION PROCESS
##################################################################
download_to_path = f'{tmp_dir.name}/test_video.mp4'
dl.download_ostrich_video(download_to_path)
# dl.download_skateline_video(download_to_path)

stabilizer = VidStab()
stabilizer.stabilize(download_to_path,
                     'stable.avi',
                     # max_frames=30,
                     border_type='black',
                     border_size='auto',
                     layer_func=layer_overlay,
                     playback=True)

##################################################################
# TEST PLOT OUTPUT
##################################################################
# import matplotlib.pyplot as plt
from vidstab.download_videos import download_ostrich_video, download_truncated_ostrich_video
from .pickled_transforms import download_pickled_transforms, pickle_test_transforms

# excluding non-free "SIFT" & "SURF" methods do to exclusion from opencv-contrib-python
# see: https://github.com/skvark/opencv-python/issues/126
kp_methods = [
    "GFTT", "BRISK", "DENSE", "FAST", "HARRIS", "MSER", "ORB", "STAR"
]

tmp_dir = tempfile.TemporaryDirectory()

truncated_ostrich_video = '{}/trunc_vid.avi'.format(tmp_dir.name)
ostrich_video = '{}/vid.avi'.format(tmp_dir.name)

download_truncated_ostrich_video(truncated_ostrich_video)
download_ostrich_video(ostrich_video)


# test that all keypoint detection methods load without error
def test_default_init():
    for kp in kp_methods:
        print('testing kp method {}'.format(kp))
        assert VidStab(kp_method=kp).kp_method == kp


def test_kp_options():
    stabilizer = VidStab(kp_method='FAST',
                         threshold=42,
                         nonmaxSuppression=False)
    assert not stabilizer.kp_detector.getNonmaxSuppression()
    assert stabilizer.kp_detector.getThreshold() == 42
Exemple #3
0
from vidstab.download_videos import download_ostrich_video, download_truncated_ostrich_video
from .pickled_transforms import download_pickled_transforms, pickle_test_transforms

# atol value to use when comparing results using np.allclose
NP_ALLCLOSE_ATOL = 1e-3

# excluding non-free 'SIFT' & 'SURF' methods do to exclusion from opencv-contrib-python
# see: https://github.com/skvark/opencv-python/issues/126
KP_METHODS = ['GFTT', 'BRISK', 'DENSE', 'FAST', 'HARRIS', 'MSER', 'ORB', 'STAR']

tmp_dir = tempfile.TemporaryDirectory()
TRUNCATED_OSTRICH_VIDEO = '{}/trunc_vid.avi'.format(tmp_dir.name)
OSTRICH_VIDEO = '{}/vid.avi'.format(tmp_dir.name)

download_truncated_ostrich_video(TRUNCATED_OSTRICH_VIDEO)
download_ostrich_video(OSTRICH_VIDEO)


# test that all keypoint detection methods load without error
def test_default_init():
    for kp in KP_METHODS:
        print('testing kp method {}'.format(kp))
        assert VidStab(kp_method=kp).kp_method == kp


def test_kp_options():
    stabilizer = VidStab(kp_method='FAST', threshold=42, nonmaxSuppression=False)
    assert not stabilizer.kp_detector.getNonmaxSuppression()
    assert stabilizer.kp_detector.getThreshold() == 42

    with pytest.raises(TypeError) as err: