Opencv 3.2 and Videocapture not work [closed]
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
Which camera do you use?
i have 2 camera. A cam is inside the laptop. The second cam is a simple cam usb. I have tried them with AMCap and they work. they are 640x480
Some antiviruses can lock webcam. If you use one of them you need to manually allow webcam usage.
Yes check antivurus but have you installed something like MPHC ?
I haven't antivirus installed. No, I do not think I have installed MPHC. Do I have to install it? i use https://github.com/opencv/opencv/rele...
No don't install it. but try VideoCapture cap(1) instead of 0 for your webcam
I have already tried both. The result is the same. Gray screen
Which webcam do you use?
ok i write the id hardware: 1) USB Camera -> VID 0C45 PID 6340 2) USB2.0 HD UVC WebCam -> VID 04F2 PID B354
I have solved. I've installed all Windows updates. I do not know how I got stuffed but I did :)