Ask Your Question
0

Blank video and error message: [ WARN:0] cvCreateFileCaptureWithPreference: backend MSMF doesn't support legacy API anymore

asked 2018-12-05 21:27:28 -0600

Monique gravatar image

Hi,

I am running windows 10 ( 64bit ) with openCV 3.3.0 with C++ code with Visual Studio 2018. I used the OpenCV pre-compiled code. I have tried using the laptop built-in webcam as well as an Intel RealSense RGB camera, and Intel RealSense Depth Camera, and have installed the Intel SDK 2.0 for the Intel cameras. All three cameras appear in the device manager. All of the cameras yield only a solid grey color in the output window. I have tried specifying the camera as '0', '1', and -1 in the command cvCreateCameraCapture(0), with the same result. The enclosed camera test software was downloaded from an OpenCV forum page as an example of camera operation. Upon running the code, the system asks which of the three recognized cameras are to be used. I always receive the following error message regardless of the camera selected: (( The OpenCV code is below the following error message)):

How can I get OpenCV to recognize the cameras? In advance, thank you for your kind assistance. I am a novice programmer, so if possible, please provide an answer in simple terms!

INFO:0- VIDEOIO: Enabled backends(6, sorted by priority): FFMPEG(1000); MSMF(990); DSHOW(980); VFW(970); CV_IMAGES(960); CV_MJPEG(950)  
WARN:0- cvCreateFileCaptureWithPreference: backend MSMF doesn't support legacy API anymore.
WARN:0- cvCreateFileCaptureWithPreference: backend DSHOW doesn't support legacy API anymore.
<-----

(( The OpenCV code follows):

#include<opencv2 opencv.hpp="">
#include<opencv2 core="" core.hpp=""> #include<opencv2 highgui="" highgui.hpp=""> #include<iostream> using namespace std; using namespace cv;

int main(int argc, char* argv) { cvNamedWindow("KillCam"); cvWaitKey(500); CvCapture capture = cvCreateCameraCapture(0); IplImage* frame;

while (1) {
    frame = cvQueryFrame(capture);

    cvShowImage("KillCam", frame);
    char c = cvWaitKey(33);
    if (c == 30) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("KillCam");

}

edit retag flag offensive close merge delete

Comments

The enclosed camera test software was downloaded from an OpenCV forum page as an example of camera operation

where did you find that ? link, please !

berak gravatar imageberak ( 2018-12-06 01:47:42 -0600 )edit
1

Hi, Thank you for your comment. I downloaded that code from a forum entry or tutorial page, but do not have the link address.

Monique gravatar imageMonique ( 2018-12-07 02:37:56 -0600 )edit

ok. good idea to ignore anything with IplImage in the future, no ?

berak gravatar imageberak ( 2018-12-07 02:38:54 -0600 )edit

Yes, I agree. As noted below I have run the suggested code and received many error message that I listed below. Any suggestions as to what the problem is would be greatly appreciated. Monique

Monique gravatar imageMonique ( 2018-12-07 12:43:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-06 01:31:40 -0600

berak gravatar image

updated 2018-12-06 01:46:27 -0600

no, you're NOT using opencv's C++ api, but the deprecated C-api (thus the warning). you can no longer use IplImage and the like with current opencv

again, the main problem is, that the code you are trying to use is from opencv 1.0, and cannot be maintained in the future.

please rather try like this:

#include "opencv2/opencv.hpp" // opencv2 headers !
using namespace cv;           // c++ namespaces !

#include <iostream>
using namespace std;

int main()
{
    VideoCapture cap;         // c++ classes !
    cap.open(0);
    if (! cap.isOpened())     // you have to CHECK this !
    {
        cout << "could not open the VideoCapture !" << endl;
        return -1;
    }
    while(true)
    {
        Mat frame;
        bool ok = cap.read(frame);
        if (! ok)             // also, mandatory CHECK !
             break; 
        imshow("ocv",frame);
        int k = waitKey(10);
        if (k==27) break;     // esc. pressed
    }
    return 0;
}

please also take a look at the tutorials / docs

edit flag offensive delete link more

Comments

Hi,

I appreciate your kind assistance on getting me past this prime issue!. I ran the code that you provided and a screen appeared for about 1 second and then disappeared. I did capture the error codes that the session presented (below) as well as a long list of error codes/warnings that appeared in the Debug Output screen. debug comments will follow on additional comment. ERROR MESSAGES FROM TEMPORARY APPEARING SCREEN: [ INFO:0] VIDEOIO: Enabled backends(6,sorted by priority): FFMPEG(1000); MSMF(990); DSSHOW(980); VFW(970); CV_IMAGES(960); CV_MJPEG(950) [ WARN:1] videoio(MSMF): OnReadSample() is called with error status: -1072875772 [ WARN:1] videoio(MSMF): async ReadSample() call is failed with error status: -1072875772 [ WARN:0] videoio(MSMF): can't grab frame. Error: -107287577

Monique gravatar imageMonique ( 2018-12-07 02:33:16 -0600 )edit

try with cap.open(0, CAP_DSHOW) , then. (using directshow instead of msmf)

berak gravatar imageberak ( 2018-12-07 02:35:54 -0600 )edit

All of the lines of error/warning codes in the debug screen won't fit in the comment section, so I will list as many as will fit below: 'ProjectTest_0.exe' (Win32): Loaded 'C:\opencv_My_Visual_Studio_2017_Files\ProjectTest_6_OpenCV_reponse_test\x64\Debug\ProjectTest_0.exe'. Symbols loaded. 'ProjectTest_0.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. 'ProjectTest_0.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. 'ProjectTest_0.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. 'ProjectTest_0.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. Cannot find or open the PDB file.

Monique gravatar imageMonique ( 2018-12-07 02:36:19 -0600 )edit

the last ones are irrelevant. the prebuilt opencv libs you're apparently using, don't come with PDB files, so you can only debug your own code, not the opencv library one.

(if you need to do that, you have to build opencv from src, this will produce local PDB files, too.)

berak gravatar imageberak ( 2018-12-07 02:41:12 -0600 )edit

Thank you again for your help and detailed explanations. After an automatic Windows 10 update, the RGB camera now works (with Camera = 0 )! The RGB camera is part of the Intel Realsense Depth camera which contains both an RGB camera and a depth sensing camera. I tried various camera numbers for the depth sensor (1,2,3,4) and it doesn't get activated. If you are not familiar with this piece of hardware I understand, but I do greatly appreciate you taking the time to get the RGB camera up and running! Monique

Monique gravatar imageMonique ( 2018-12-07 20:32:31 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-05 21:27:28 -0600

Seen: 5,018 times

Last updated: Dec 06 '18