Issues with VideoCapture.set


I want to use openCV to control in python a webcam from an embedded system. I did this code to manage the resolution of the capture:

import cv2

capture = cv2.VideoCapture(0, cv2.CAP_V4L2)

capture.set(3, 1280)
capture.set(4, 720)

However, the resolution of this capture is stuck at the basic resolution for cv2: 640*480.

The webcam is the nuroum V11 (

The embedded system is a RFSoC 4x2

I use a jupyter notebook and PYNQ to execute the previous python code in the Processing System of the board.

Has someone meet a similar issue with that webcam?

Thank you in advance for your assistance

try access using ffmpeg or gstreamer or guvcview or other way that isn’t opencv, but also uses V4L2

some video modes might require CAP_PROP_FOURCC set to VideoWriter_fourcc(*"MJPG"). order of set() calls matters, try setting this property first and last (not first and last, first first, then last)

general programming advice: named constants please. cv.CAP_PROP_FRAME_WIDTH etc

1 Like


Thank you for your answer. I changed the previous code to:

capture = cv2.VideoCapture(0, cv2.CAP_V4L2)

capture.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*“MJPG”))

capture.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)
capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080)

With that, I am able to change the resolution of the capture. Thank you once again