Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Opencv 3.2 and Videocapture not work

Hello to all. I'm noob whit opencv. I'm trying to use Windows 7, Opencv 3.2 and Visual Studio. I test example whit VideoCapture and .avi and it is ok. When i test VideoCapture whit cam usb it is not work. Can someone help me? the code is:

#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

using namespace cv;
int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if (!cap.isOpened())  // check if we succeeded
        return -1;

    Mat edges;
    namedWindow("edges", 1);
    while(true)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        waitKey(100);   
    }
    cap.release();
    return 0;
}

If I try this code the program opens the room but I see nothing (gray window)

***** VIDEOINPUT LIBRARY - 0.1995 - TFW07 *****

SETUP: Setting up device 0
SETUP: USB2.0 PC CAMERA
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 640x480
SETUP: trying specified format RGB24 @ 640x480
SETUP: trying format RGB24 @ 640x480
SETUP: trying format RGB32 @ 640x480
SETUP: trying format RGB555 @ 640x480
SETUP: trying format RGB565 @ 640x480
SETUP: trying format YUY2 @ 640x480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.

Event: Code: 0x0d Params: 0, 0
Event: Code: 0x0e Params: 0, 0
Event: Code: 0x03 Params: -2147024891, 0