Currently, I can use Cheese to call my Raspberry Pi Camera v2, but OpenCV cannot call /dev/video0.
The following command is also executable.
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! videoconvert ! video/x-raw,format=NV12,width=1920,height=1080 ! jpegenc ! multifilesink location=/home/radxa/test.jpg
Here is the test code that I used:
import cv2
cap = cv2.VideoCapture(0)
if not cap.isOpened():
print("Don't open camera")
else:
ret, frame = cap.read()
if ret:
cv2.imshow('frame', frame)
cv2.waitKey(0)
cap.release()
cv2.destroyAllWindows()
Here is the error message that is being printed:
[ WARN:0] global /tmp/pip-req-build-6icxdfha/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video0): can’t open camera by index