I’m able to grab a single image from a CSI camera and display it in a cv2 window but my program keeps crashing when I try to release the VideoCapture object. This is a problem because I still need to be able to run code after I close a camera.
Here’s my code:
import cv2 cap = cv2.VideoCapture("nvarguscamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)60/1 ! nvvidconv ! video/x-raw,format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink") _, frame = cap.read() cv2.imshow("Frame", frame) while True: if cv2.waitKey(1) == 27: cv2.destroyAllWindows() break cap.release() print("This print doesn't run")
I built opencv using this tutorial and I’m running the program just through the system terminal. It seems weird to me that this program crashes as it’s fairly simple. Could this be an issue with my build or my hardware? I’ve tried using the Visual Studio Code debugger and it hasn’t provided any additional info. Thanks in advance!