I’m looking to see if there is any way to record a short video ~5s and save into a folder.
It should auto record when an object is detected. Is it possible? May I know how.
Below is the standard script I’m using. Appreciate your help!
Thank you for helping in.
After trying it out, that link is more on displaying the video camera rather than recording it and save into some sort of file (mp4 for example). Do you have any other link can share with?
Appreciate your help!
That is the right link. You need to read about videoOutput. When there is a detection, open a videoOutput and write frames for 5 seconds.
Here’s a rudimentary script that worked for me:
import jetson.inference
import jetson.utils
import time
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson.utils.videoSource("csi://0")
while True:
img = camera.Capture()
detections = net.Detect(img)
# Check for a detection
if (len(detections) > 1):
video = jetson.utils.videoOutput(f"output{time.time()}.mp4")
start = time.time()
frame = img
# Record video for 5 seconds
while time.time() < start + 5:
video.Render(frame)
frame = camera.Capture()
net.Detect(frame)