I tried making this code work with the raspberry pi cam. how do you make the cv2.VideoCapture(0) recognise the raspberry pi camera as the designated camera
You cannot use cv2.VideoCapture()
for RaspiCam.
The cv2.VideoCapture()
is only for USB camera, not for CSI camera.
If you want to use RaspiCam for capturing, you can refer this tutorial
From what I can understand, you need to find the location # of the raspberry pi camera and change
cam = cv2.VideoCapture(0)
to
cam = cv2.VideoCapture(Camera#)
Some time ago, I developed on a rasperry pi with raspicam, an interface for opencv. I thought that the video capture in pure cv only works for usb devices
You can download raspicam under http://sourceforge.net/projects/raspicam/files/
Try the following:
video_capture = cv2.VideoCapture(
get_jetson_gstreamer_source(), cv2.CAP_GSTREAMER
)
The problem is that you are not coding safely.
If you had check the return of the method, you would know instantly that 0
is not the index of your camera:
import sys
cam = cv2.VideoCapture(0)
if not cam:
print("!!! Failed VideoCapture: invalid parameter!")
sys.exit()
Try numbers > 0.