I installed bookworm on a pi 4 8gb. Libcamera stuff works, so does PiCamera2. I am trying to get all of my opencv programs running. A simple camera snippet won't work.the message was:I trieedAnd the code still lead to errors. I uninstalled with pip.
I triedAnd the code still lead to errors. At this time I removed withAnd now I can't import cv2. Genius. I read many posts at various places. It seems the solution is to rewrite code to use PiCamera2? Is this the answer? That will take some work that I wasn't expecting. Please share a guide on how to run stretch/bullseye python opencv code on pi bookworm without code changes.
Code:
import numpy as npimport cv2import timewinname='camera0'cap = cv2.VideoCapture(0)while(True): # Capture frame-by-frame ret, frame = cap.read() if not ret: break # Display the resulting frame cv2.imshow(winname,frame) key = cv2.waitKey(20) if key & 0xFF == ord('q'): breakcap.release()cv2.destroyAllWindows()
Code:
[ WARN:0@0.274] 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:0@0.276] global ./modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline[ WARN:0@0.276] global ./modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been createdread framegot nada
Code:
pip install opencv-contrib-python --break-system-packages
I tried
Code:
sudo apt install python3-opencv
Code:
sudo apt remove python3-opencv
Statistics: Posted by bluePiuser — Wed Jun 05, 2024 1:45 am