Skip to content

Commit

Permalink
status update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishaan-Datta committed Nov 6, 2024
1 parent fcfeed2 commit 948a9b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tools/video/mp4-recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import cv2
import numpy as np
import pyzed.sl as sl
import time

def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):
# Create a ZED camera object
zed = sl.Camera()

# Set initialization parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD720 # Set resolution
init_params.camera_resolution = sl.RESOLUTION.HD1080 # Set resolution
init_params.camera_fps = fps # Set FPS

# Open the ZED camera
Expand Down Expand Up @@ -38,6 +39,7 @@ def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):

# Main loop
frame_count = int(duration * fps)
start_time = time.time()
for i in range(frame_count):
# Grab the current image
if zed.grab(runtime_parameters) == sl.ERROR_CODE.SUCCESS:
Expand All @@ -51,11 +53,17 @@ def record_zed_to_mp4(output_file="output.mp4", fps=30, duration=10):

# Write the frame to the video file
video_writer.write(frame)

# Print status update
elapsed_time = time.time() - start_time
print(f"\rRecording... {elapsed_time:.2f}/{duration} seconds", end='')

# # Optional: Display the frame (press 'q' to exit early)
# cv2.imshow("ZED Video", frame)
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break


else:
print("Frame grab failed")
break
Expand Down

0 comments on commit 948a9b7

Please sign in to comment.