@@ -0,0 +1,1031 @@
+# coding: utf-8%0A%0Aimport os%0Aimport shutil%0Aimport cv2%0A%0A%0Adef delete_and_make_directory(dir_path='./image_dir/'):%0A%09# Delete the entire directory tree if it exists.%0A%09if os.path.exists(dir_path):%0A%09%09shutil.rmtree(dir_path)  %0A%09%0A%09# Make the directory if it doesn't exist.%0A%09if not os.path.exists(dir_path):%0A%09%09os.makedirs(dir_path)%0A%0A%0A%0Adef video_2_frames(video_file='./IMG_2140.MOV', image_dir='./image_dir/', image_file='img_%25s.png'):%0A%09# Delete the entire directory tree if it exists.%0A%09if os.path.exists(image_dir):%0A%09%09shutil.rmtree(image_dir)  %0A%09%0A%09# Make the directory if it doesn't exist.%0A%09if not os.path.exists(image_dir):%0A%09%09os.makedirs(image_dir)%0A%0A%09# Video to frames%0A%09i = 0%0A%09cap = cv2.VideoCapture(video_file)%0A%09while(cap.isOpened()):%0A%09%09flag, frame = cap.read()  # Capture frame-by-frame%0A%09%09if flag == False:  # Is a frame left?%0A%09%09%09break%0A%09%09cv2.imwrite(image_dir+image_file %25 str(i).zfill(6), frame)  # Save a frame%0A%09%09print('Save', image_dir+image_file %25 str(i).zfill(6))%0A%09%09i += 1%0A%0A%09cap.release()  # When everything done, release the capture%0A

Add util directory and a code