Hi, I right now have a python program that detects objects from live video stream, following Hello AI world and NVIDIA’s youtube channel. I have modified it so that on key “q” press, the class it is currently detecting is printed out to the terminal. However, I would like to modify it so that on button press, the current frame which is being streamed in should be captured and saved in some directory. Furthermore, I would like it so that on detecting a “person” it should save the frame and save it in a directory. I am struggling now with how to capture the frame. I just need to substitute the printing of the class with the “snapshot” and I will have the first step done. Any suggestions on how I can just take the current frame and save it as an image?
(I am a intern, still learning the basics of the nano and AI in general)
import jetson.inference
import jetson.utils
import keyboard
net = jetson.inference.detectNet("ssd-mobilenet-v2", threshold=0.5)
camera = jetson.utils.videoSource("/dev/video0") # '/dev/video0' for V4L2
display = jetson.utils.videoOutput("display://0") # 'my_video.mp4' for file
while display.IsStreaming():
img = camera.Capture()
detections = net.Detect(img)
for detection in detections:
if keyboard.is_pressed('q'):
print(net.GetClassDesc(detection.ClassID))
#jetson.utils.saveImageRGBA("1.img",img)
display.Render(img)
display.SetStatus("Object Detection | Network {:.0f} FPS".format(net.GetNetworkFPS()))
This is my current python script. Like in the example you showed, can i load the frame (from img = camera.Capture() ) into CUDA memory like line 39? Then convert it to BGR?