OpenCV/Windows Broke yesterday

Hi All,

I am a long time programmer (mostly embedded firmware), and have used OpenCV for several years.

I was working yesterday on an application that uses two 2MP USB cameras and was having some issues opening both for video capture at once. I ran across some forum comments saying that the issue could be caused by having both on the same USB hub, which they were. So I moved one to a different hub on my AMD Threadripper 2950X CPU with 32GB of RAM running fully updated Windows 10. Anyway, after doing so, OpenCV displayed images from both cameras and all seemed OK. I think they were both running at 1280x720 resolution. I wondered if they could display full resolution, so I added set( CAP_PROP_FRAME_WIDTH, 1600 ) statements to set the cameras to their full resolution.

Running this code failed to open the cameras and since then I can’t open any single or multiple cameras with OpenCV.

I thought perhaps a DLL was corrupted I ran sfc which said it found issues, but didn’t fix this issue.

Anyway, my code is minimal:

int main( )
{
    VideoCapture vid(0);
    Mat img;

    if ( !vid.isOpened()) <priint message & quit>

    do
    {
        vid.read(img);
        if ( !img.empty() ) imshow( “front”, img );
    }
    while ( waitKey( 1 ) != 0x1B );

    vid.release();
    destroyAllWindows();
    return 0;
}

I didn’t have vid.release() in the original code.

I’ve tried camera indexes: -1, 0 and 1 (yesterday when things worked the cameras indexes were 0 and 1). I also have tried various capture backend options CAP_DSHOW, CAP_FFMPEG, … none of these has made any difference. If I change the option to CAP_FFMPEG a single camera opens, but vid.read( img ) never returns an image.

Both cameras still work using Microsoft’s Camera App, and both are reported in device manager as working.

Here’s the OpenCV diagnostic log without the CAP_FFMPEG option:

[ INFO:0@0.038] global videoio_registry.cpp:251 cv::`anonymous-namespace'::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(9, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930); OBSENSOR(920)
[ INFO:0@0.039] global backend_plugin.cpp:382 cv::impl::getPluginCandidates Found 2 plugin(s) for GSTREAMER 
[ INFO:0@0.039] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_videoio_gstreamer4110_64d.dll => FAILED 
[ INFO:0@0.041] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_videoio_gstreamer4110_64d.dll => FAILED 
[ INFO:0@0.041] global backend_plugin.cpp:382 cv::impl::getPluginCandidates Found 2 plugin(s) for MSMF 
[ INFO:0@0.048] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_videoio_msmf4110_64d.dll => OK 
[ INFO:0@0.048] global backend_plugin.cpp:50 cv::impl::PluginBackend::initCaptureAPI Found entry: 'opencv_videoio_capture_plugin_init_v1' 
[ INFO:0@0.048] global backend_plugin.cpp:169 cv::impl::PluginBackend::checkCompatibility Video I/O: initialized 'Microsoft Media Foundation OpenCV Video I/O plugin': built with OpenCV 4.11 (ABI/API = 1/2), current OpenCV version is '4.11.0' (ABI/API = 1/2) 
[ INFO:0@0.048] global backend_plugin.cpp:69 cv::impl::PluginBackend::initCaptureAPI Video I/O: plugin is ready to use 'Microsoft Media Foundation OpenCV Video I/O plugin' 
[ INFO:0@0.048] global backend_plugin.cpp:84 cv::impl::PluginBackend::initWriterAPI Found entry: 'opencv_videoio_writer_plugin_init_v1' 
[ INFO:0@0.048] global backend_plugin.cpp:169 cv::impl::PluginBackend::checkCompatibility Video I/O: initialized 'Microsoft Media Foundation OpenCV Video I/O plugin': built with OpenCV 4.11 (ABI/API = 1/1), current OpenCV version is '4.11.0' (ABI/API = 1/1) 
[ INFO:0@0.048] global backend_plugin.cpp:103 cv::impl::PluginBackend::initWriterAPI Video I/O: plugin is ready to use 'Microsoft Media Foundation OpenCV Video I/O plugin' 
[ INFO:0@0.660] global cap_msmf.cpp:1033 CvCapture_MSMF::configureHW MSMF: Using D3D11 video acceleration on GPU device: NVIDIA GeForce GTX 1650 Can't open cameras 
[ INFO:0@1.795] global cap_msmf.cpp:551 `anonymous-namespace’::SourceReaderCB::~SourceReaderCB terminating async callback

[ INFO:1@1.800] global plugin_loader.impl.hpp:74 cv::plugin::impl::DynamicLib::libraryRelease unload D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_videoio_msmf4110_64d.dll

D:\Projects\Coin_Pricer\soft\coin_viewer\x64\Debug\coin_viewer.exe (process 1944) exited with code 1 (0x1).

And with the FFMPEG option:

[ INFO:0@0.051] global videoio_registry.cpp:251 cv::`anonymous-namespace’::VideoBackendRegistry::VideoBackendRegistry VIDEOIO: Enabled backends(9, sorted by priority): FFMPEG(1000); GSTREAMER(990); INTEL_MFX(980); MSMF(970); DSHOW(960); CV_IMAGES(950); CV_MJPEG(940); UEYE(930); OBSENSOR(920)
[ INFO:0@10.460] global registry.impl.hpp:118 cv::highgui_backend::UIBackendRegistry::UIBackendRegistry UI: Enabled backends(4, sorted by priority): GTK(1000); GTK3(990); GTK2(980); WIN32(970) + BUILTIN(WIN32UI)
[ INFO:0@10.461] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_highgui_gtk4110_64.dll => FAILED
[ INFO:0@10.463] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk4110_64.dll => FAILED
[ INFO:0@10.464] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_highgui_gtk34110_64.dll => FAILED
[ INFO:0@10.465] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk34110_64.dll => FAILED
[ INFO:0@10.465] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load D:\opencv4_11_0\opencv\build\x64\vc16\bin\opencv_highgui_gtk24110_64.dll => FAILED
[ INFO:0@10.466] global plugin_loader.impl.hpp:67 cv::plugin::impl::DynamicLib::libraryLoad load opencv_highgui_gtk24110_64.dll => FAILED
[ INFO:0@10.467] global backend.cpp:90 cv::highgui_backend::createUIBackend UI: using backend: WIN32 (priority=970)

D:\Projects\Coin_Pricer\soft\coin_viewer\x64\Debug\coin_viewer.exe (process 2980) exited with code -1 (0xffffffff).

I have tried several versions of OpenCV, 4.12.0, 4.11.0 all behave the same.

Any thoughts are much appreciated.

Thanks,

Scott

OMG! I didn’t notice that the “!” is missing in front of front.isOpened()! DUH.

Sorry, Scott

so… problem solved, or problem still there?

that’s the issue with “pseudocode”. there is no “front.isOpened” in anything you posted.

when in doubt, reboot the computer.

Sorry, the issue is resolved. Thanks for your reply.

Scott