Having trouble running OpenCV frame capture on Raspberry Pi 3 B+.
I have installed OpenCV 4.6.0 and Python 3.11.2 on Raspberry Pi OS. (Linux version 6.6.47+rpt-rpi-v8)
This is the Python code being run:
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
status, photo = cap.read()
cv2.imshow("Face Detection", photo)
This code results in:
[ WARN:[email protected]] global ./modules/videoio/src/cap_gstreamer.cpp (2401) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Failed to allocate required memory.
[ WARN:[email protected]] global ./modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:[email protected]] global ./modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Traceback (most recent call last):
File "/home/techsmartkid/camera/test.py", line 7, in <module>
cv2.imshow("Face Detection", photo)
cv2.error: OpenCV(4.6.0) ./modules/highgui/src/window.cpp:967: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
(I have tested the hardware, and the video camera is working.)
If anybody has any suggestions on what I could try, or what may be wrong, it would be very helpful.
New contributor
Ari Schumann is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
5