@@ -25,6 +25,18 @@ def read_image_folder(folder_path, file_extension='.tif', start=0, end=-1, read_
2525 return images
2626
2727
28+ def read_mp4 (video_file ):
29+ video = cv2 .VideoCapture (video_file )
30+ success = True
31+ frames = []
32+ while success :
33+ success , frame = video .read ()
34+ if success :
35+ frames .append (frame )
36+ frames = np .arrays (frames )
37+ return frames
38+
39+
2840def write_video (output_file , images , framerate = 20 , color = False , fourcc = cv2 .VideoWriter_fourcc (* 'mp4v' )):
2941 video = cv2 .VideoWriter (output_file , fourcc , framerate , (images .shape [2 ], images .shape [1 ]), color )
3042 for i in images :
@@ -170,9 +182,6 @@ def feature_tracker(images: np.ndarray, selected_contour: np.ndarray, func=None,
170182
171183
172184if __name__ == "__main__" :
173- images = np .load ('C:/Users/truma/Documents/Code/ComputerVision_ws/data/bird_impact.npy' )
174- print ('images loaded' , images .shape )
175- selected = feature_selector (images [500 :])
176- tracked_feature , returned_images = feature_tracker (images [501 :700 ], selected , show_images = False , return_images = True )
177- print ('finished tracking' )
178- animate_images (returned_images , wait_key = True , BGR = False )
185+ test_frames = read_mp4 ('C:/Users/truma/Downloads/samara_seed.avi' )
186+ print (len (test_frames ))
187+ animate_images (test_frames )
0 commit comments