Problem with start opencv300 and Video [closed]

asked 2015-11-04 05:44:54 -0500

MValeriy gravatar image

I want to start Opencv300 in VC12 . have everything connected as in the video : [ https://www.youtube.com/watch?v=ScAPi...]

with images I can work without any problems , but if I want CONNECTING camera immediately comes error message :

Unhandled exception at at 0x7510812F in Sample1.exe : Microsoft C ++ exception : cv :: Exception at memory location 0x001BD64C .

and the window is :

OpenCV Error : Assertion failed < SCN == 3 SCN== 4 > in cv :: cvtColor , file c: \ builds \ master_PackSlave Win32 VC11 - shared \ OpenCV \ modules \ imgproc \ src \ color . cpp Line 7564

Why is that ? thank you

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by MValeriy
close date 2015-11-25 00:46:35.287414

Comments

First of all, you say you want to use OpenCV in VC12 but your folder says you're using VC11 binaries, so that may cause problems (in general). About your specific problem, hard to say what's going on without any code, but guessing you just haven't checked if the camera is properly opened/outputting non-empty frames

LorenaGdL gravatar imageLorenaGdL ( 2015-11-04 06:01:11 -0500 )edit

I use VC12 and VC12 of all libraries , I do not know what does this error message . To the camera : I have previously worked with Opencv231 but is ziehlich old when code is running smoothly , but here with this error

MValeriy gravatar imageMValeriy ( 2015-11-04 07:15:12 -0500 )edit

Code:

#include "opencv2/opencv.hpp"
     using namespace cv;
     int main()
    {
        int c;
        Mat img;
        VideoCapture cap(0);
        while (true)
        {
            cap >> img;
            imshow("Norm", img); 
            c=waitKey(1);
              if(c==27) 
             break;
        }


        return 0;
    }
MValeriy gravatar imageMValeriy ( 2015-11-04 07:16:23 -0500 )edit

Is that the code you're using? I very much doubt it, because the error is in function cvtColor, which you don't seem to use.

LorenaGdL gravatar imageLorenaGdL ( 2015-11-04 07:21:33 -0500 )edit

NOOOOO, It is a simplified version. there's something in between . Cod is different, which I have brought as an example.

 Mat edges;
        cvtColor(img, edges, CV_BGR2GRAY);
        Canny(edges, edges, 50, 160);

without cvtColor i have: OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, fi le C:\builds\master_PackSlave-win32-vc11-shared\opencv\modules\highgui\src\windo w.cpp, line 271

MValeriy gravatar imageMValeriy ( 2015-11-04 09:18:45 -0500 )edit

no matter what kind of code I have . Problem is due to the camera , as all code without using the camera run ( eg images ) , as far as I calls camera , it does not go

MValeriy gravatar imageMValeriy ( 2015-11-04 09:21:05 -0500 )edit

As I said in the first comment, what you need to do is check if the image has been captured or not:

while(true){
    cap >> img;
    if(img.empty()){
        continue;    //or break; depending on your application/preferene
    }
    imshow("My image", img);
}
LorenaGdL gravatar imageLorenaGdL ( 2015-11-04 09:28:30 -0500 )edit

thank you , I'm a little further , but I still have not viedeo

a lot of: Cannot find or open the PDB file. and 'Sample1.exe' (Win32): Unloaded 'C:\Windows\System32\vfwwdm32.dll' The thread 0x1d70 has exited with code 0 (0x0). The thread 0x2048 has exited with code 0 (0x0). The thread 0x23e8 has exited with code 0 (0x0). The thread 0x2198 has exited with code 0 (0x0). The thread 0x7ec has exited with code 0 (0x0). The program '[9988] Sample1.exe' has exited with code 0 (0x0).

MValeriy gravatar imageMValeriy ( 2015-11-04 09:41:50 -0500 )edit

Instead of VideoCapture cap(0), try one of the following:

VideoCapture cap(-1);
VideoCapture cap(0 + CV_CAP_VFW);
VideoCapture cap(0 + CV_CAP_DSHOW);

And add this check just below whatever option you choose:

if (!cap.isOpened()) // check if we succeeded
    return -1;
LorenaGdL gravatar imageLorenaGdL ( 2015-11-04 10:25:08 -0500 )edit

Hello , unfortunately, that did not help

1)for VideoCapture cap(-1); VideoCapture cap(0 + CV_CAP_VFW);

a lot of Cannot find or open the PDB file. VIDEOINPUT LIBRARY - 0.1995 - TFW07 The thread 0x10d4 has exited with code 0 (0x0). The thread 0xe50 has exited with code -1 (0xffffffff). The program '[1656] Sample1.exe' has exited with code -1 (0xffffffff).

2)for VideoCapture cap(0 + CV_CAP_DSHOW);

a lot of Cannot find or open the PDB file. SETUP: Disconnecting device 0 SETUP: freeing Grabber Callback SETUP: freeing Renderer SETUP: freeing Capture Source SETUP: freeing Grabber Filter SETUP: freeing Grabber SETUP: freeing Control SETUP: freeing Media Type SETUP: removing filter NullRenderer... SETUP: filter removed NullRenderer .....

MValeriy gravatar imageMValeriy ( 2015-11-05 01:44:13 -0500 )edit