“cv2.VideoCapture()” does not work properly on Monterey

cap_device = 0						# built-in camera of MacBook Pro 2018
cap = cv2.VideoCapture(cap_device)	
cfps = int(cap.get(cv2.CAP_PROP_FPS))

The program above can’t import video properly from built-in camera of MacBook Pro 2018. In my case, cfps(in the above program) is 5Hz and import frequency also behaves about 5Hz.

How can I solve this problem? Or is it a bug?

welcome.

use Capture/Webcam – FFmpeg

list the capabilities (formats) of the camera. yes, try -list_formats true for -f avfoundation

see if you can get ffmpeg or VLC to show video from the camera at a pleasing frame rate.

1 Like

Sorry, the problem was solved in another way.

cap_device = 0 # built-in camera of MacBook Pro 2018
cap = cv2.VideoCapture(cap_device)	
cap.set(cv2.CAP_PROP_FPS, 60) # newly added code
cfps = int(cap.get(cv2.CAP_PROP_FPS))

With the newly added part, cap.get(cv2.CAP_PROP_FPS) is no longer NaN and can be imported successfully.