diff --git a/demos/video/resources/pre-processed/Avatar.npz b/demos/video/resources/pre-processed/Avatar.npz new file mode 100644 index 0000000..c61f105 Binary files /dev/null and b/demos/video/resources/pre-processed/Avatar.npz differ diff --git a/demos/video/resources/pre-processed/Bob_Ross.npz b/demos/video/resources/pre-processed/Bob_Ross.npz new file mode 100644 index 0000000..5b2129b Binary files /dev/null and b/demos/video/resources/pre-processed/Bob_Ross.npz differ diff --git a/demos/video/resources/pre-processed/Maxwell.npz b/demos/video/resources/pre-processed/Maxwell.npz new file mode 100644 index 0000000..d18d208 Binary files /dev/null and b/demos/video/resources/pre-processed/Maxwell.npz differ diff --git a/demos/video/resources/pre-processed/Rick.npz b/demos/video/resources/pre-processed/Rick.npz new file mode 100644 index 0000000..dff4c61 Binary files /dev/null and b/demos/video/resources/pre-processed/Rick.npz differ diff --git a/demos/video/resources/pre-processed/Stick_Bug.npz b/demos/video/resources/pre-processed/Stick_Bug.npz new file mode 100644 index 0000000..d93130e Binary files /dev/null and b/demos/video/resources/pre-processed/Stick_Bug.npz differ diff --git a/demos/video/video_processing.py b/demos/video/video_processing.py index bdc8d36..2baa5cc 100644 --- a/demos/video/video_processing.py +++ b/demos/video/video_processing.py @@ -44,6 +44,7 @@ # Create directory for pre-processed videos path = "./demos/video/resources/videos/" +path_processed = "./demos/video/resources/pre-processed/" try: os.mkdir(path) except: @@ -68,18 +69,23 @@ def normalize(x): total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) # Check if the video has already been processed - if not os.path.exists(f"{path}{target[:-4]}.csv"): - processing = True - logger.info(f"processing {target}") - else: + if os.path.exists(f"{path_processed}{target[:-4]}.npz"): processing = False logger.info(f"{target} has already been processed") + else: + processing = True + logger.info(f"processing {target}") # Iterate through all frames in the video video = np.array([]) while processing: (ret, frame) = cap.read() if not ret: + # Reshape the video and save it + video = video.reshape((total_frames, 48, 48)) + video = video.astype(np.uint8) + np.savez_compressed(f"{path_processed}{target[:-4]}.npz", video) + logger.info(f"processed {target}") break # fmt: off @@ -92,12 +98,5 @@ def normalize(x): video = np.append(video, graySmall) # append the frame to the video # fmt: on - # Reshape the video and save it - video = video.reshape((total_frames, 48, 48)) - video = video.astype(np.uint8) - np.savez_compressed( - f"./demos/video/resources/pre-processed/{target[:-4]}.npz", video - ) - # Release the video cap.release()