Skip to content

Commit 0903061

Browse files
authored
Merge pull request opencv#25500 from alex-urm:v4l_default_image_size
V4l default image size opencv#25500 Added ability to set default image width and height for V4L capture. This is required for cameras that does not support 640x480 resolution because otherwise V4L capture cannot be opened and failed with "Pixel format of incoming image is unsupported by OpenCV" and then with "can't open camera by index" message. Because of the videoio architecture it is not possible to insert actions between CvCaptureCAM_V4L::CvCaptureCAM_V4L and CvCaptureCAM_V4L::open so the only way I found is to use environment variables to preselect the resolution. Related bug report is [opencv#25499](opencv#25499) Maybe (but not confirmed) this is also related to [opencv#24551](opencv#24551) This fix was made and verified in my local environment: capture board AVMATRIX VC42, Ubuntu 20, NVidia Jetson Orin. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent f3d9d56 commit 0903061

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/videoio/src/cap_v4l.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ bool CvCaptureCAM_V4L::open(const std::string & _deviceName)
919919
{
920920
CV_LOG_DEBUG(NULL, "VIDEOIO(V4L2:" << _deviceName << "): opening...");
921921
FirstCapture = true;
922-
width = DEFAULT_V4L_WIDTH;
923-
height = DEFAULT_V4L_HEIGHT;
922+
width = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_WIDTH", DEFAULT_V4L_WIDTH);
923+
height = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_HEIGHT", DEFAULT_V4L_HEIGHT);
924924
width_set = height_set = 0;
925925
bufferSize = DEFAULT_V4L_BUFFERS;
926926
fps = DEFAULT_V4L_FPS;

0 commit comments

Comments
 (0)