VideoCapture not working on Raspberry Bullseye

Hey there:-)
I´m trying to capture Videos… with no sucess. “libcamera-hello” is working perfectly, but if i try to run this code, it doesn´t

import cv2
print("Package imported")
cap=cv2.VideoCapture(0)
while True:
    sucess, img=cap.read()
    cv2.imshow("Video",img)
    if cv2.waitKey(1) & 0xFF==ord('q'):
        break

[ WARN:0@12.692] global /tmp/pip-wheel-mqp59bja/opencv-python_d3c31dc7802240788618bfcd2774f816/opencv/modules/videoio/src/cap_v4l.cpp (1000) tryIoctl VIDEOIO(V4L2:/dev/video0): select() timeout.
Traceback (most recent call last):
File “/home/pi/MyProjects/test.py”, line 13, in
cv2.imshow(“Video”,img)
cv2.error: OpenCV(4.5.5) /tmp/pip-wheel-mqp59bja/opencv-python_d3c31dc7802240788618bfcd2774f816/opencv/modules/core/src/array.cpp:2494: error: (-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type in function ‘cvGetMat’

raspberry 3. using python 3.9.2, opencv 4.5.5

Can u help me?

kr
Andy

assert cap.isOpened() once right after creating the VideoCapture

thx for your fast reply!
there is no improvement… still facing the same issue…
cap.isOpened() gives me true in debugging

if not sucess: break

and when that passes okay, you might wanna check img.shape and img.dtype

does capturing/playback with ffmpeg/ffplay/vlc/guvcview work okay?

do you have everything installed so the camera is an actual V4L device? it used to be that cameras attached to raspberry pi via MIPI CSI weren’t exposed through V4L

if not sucess: break does not help, i get the same timeout issue.
due to i´m not that good with linux… how do i check if may cam is working properly. Again: “libcamera-hello” works
this is my camera

How about my video guide, for me it was fairly simple:

hope it helps