opencv-python
opencv-python copied to clipboard
cam.isOpened() returns true, but cam.read() returns (false, None)
openCv python version 4.5.5. Camera module waveshare OV9281-110 I am working with raspberry-pi model 4-B with latest bullseye OS.
I am able to capture image using libcamera-still -o test.png command but when I try to read an image with opencv it returns None. The output for cam.isOpened() is true but cam.grab() and cam.read() return false and (false,None) respectively.
Code:
import cv2
cam_port = 0
cam = cv2.VideoCapture(cam_port)
print(cam.isOpened())
print(cam.grab())
print(cam.read())
cam.release()
Output:
True
False
(False, None)
camera info
~ $ v4l2-ctl --device /dev/video0 --all
Driver Info:
Driver name : unicam
Card type : unicam
Bus info : platform:fe801000.csi
Driver version : 5.15.56
Capabilities : 0xa5a00001
Video Capture
Metadata Capture
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x25200001
Video Capture
Read/Write
Streaming
Extended Pix Format
Media Driver Info:
Driver name : unicam
Model : unicam
Serial :
Bus info : platform:fe801000.csi
Media version : 5.15.56
Hardware revision: 0x00000000 (0)
Driver version : 5.15.56
Interface Info:
ID : 0x03000005
Type : V4L Video
Entity Info:
ID : 0x00000003 (3)
Name : unicam-image
Function : V4L2 I/O
Flags : default
Pad 0x01000004 : 0: Sink
Link 0x02000007: from remote pad 0x1000002 of entity 'ov9281 10-0060': Data, Enabled, Immutable
Priority: 2
Video input : 0 (unicam-image: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'BGR3' (24-bit BGR 8-8-8)
Field : None
Bytes per Line : 1920
Size Image : 921600
Colorspace : sRGB
Transfer Function : sRGB
YCbCr/HSV Encoding: ITU-R 601
Quantization : Full Range
Flags
could someone help me out? I tried building opencv from source and still the same thing.
Duplicate: https://github.com/opencv/opencv/issues/22820
你们可以尝试使用 picamera2,请参考https://blog.csdn.net/zhangmou_9008/article/details/134047114上面的3.1 you kan try to use picamera2,please show the blog's 3.1 :https://blog.csdn.net/zhangmou_9008/article/details/134047114