0

I am attempting to pull simple video from a USB camera, which I will then export to either .AVI or .PNG, as required.

I have implemented OpenCV, version 3.4.1-dev, in both a Python3 script and a C++ program. Both the Python3 script and the C++ program run beautifully on Windows, with no errors.

The C++ program compiles just fine on Windows and Ubuntu, but both the Python Script and the C++ program crash with the following errors when run on Ubuntu:

libv4l2: error set_fmt gave us a different result then try_fmt!
OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /opt/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised OpenCV exception:

OpenCV(3.4.1-dev) /opt/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) Unspecified error: GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

libpng warning: Image width is zero in IHDR
libpng warning: Image height is zero in IHDR
libpng error: Invalid IHDR data

I experimented with a number of printf() statements and narrowed the issue down to the line "VideoCapture capture(0);". From my limited knowledge, it appears that Ubuntu cannot find the camera at ID 0, where Windows was able to. I also tried a for loop to see if the camera was at a higher ID number, but that did not help; it passed right by the other numbers and still crashed when it hit ID 0.

My every search for help yielded many different issues for earlier versions of OpenCV, and all routed back to the same error message:

libv4l2: error set_fmt gave us a different result then try_fmt!

I do not know how to approach this error. It seems to be a problem with OpenCV 3.4.1-dev itself. Any advice?

1 Answers1

0

Well, I ran into a similar issue (same error message):

libv4l2: error set_fmt gave us a different result then try_fmt!

It's not an OpenCV issue but rather is a BUG in v4l:

https://bugs.launchpad.net/ubuntu/+source/v4l-utils/+bug/1737063

I upgraded the v4l-utils package to the fix version (1.12.6) indicated by the BUG report, the error message disappeared and the camera started working without issues.

rkachach
  • 16,517
  • 6
  • 42
  • 66