最新的64位系统下opencv的capture不支持libcamera
直接调用capturevideo运行代码会出现如下报错:
WARN:[email protected]] global ./modules/videoio/src/cap_gstreamer.cpp (2401) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Cannot identify device '/dev/video1'.
[ 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
[ WARN:[email protected]] global ./modules/videoio/src/cap_v4l.cpp (902) open VIDEOIO(V4L2:/dev/video1): can't open camera by ind
可使用picamera2调用csi摄像头,代码如下:
from picamera2 import Picamera2
import cv2
import time
picam2 = Picamera2()
picam2.start()
try:
while True:
array = picam2.capture_array("main")
cv2.imshow('Real-time Camera Feed', array)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
finally:
picam2.stop()
cv2.destroyAllWindows()