Blue screen when using VideoCapture
I'm accessing the front and back cameras of my surface pro 4. When I run my code the program usually get stuck at the following line and I get a bluescreen after a while.
std::VideoCapture vidCap(1);
Strangely it doesn't always happen. Sometimes (about 1 out of 5 tries) the programm works perfectly fine and I can see my camera stream. Do you guys have ideas what I can do?
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
int main()
{
const char* windowName = "Webcam Stream";
cv::namedWindow(windowName, CV_WINDOW_AUTOSIZE);
cv::Mat frame;
cv::VideoCapture vidCap(1);
while (vidCap.isOpened()) {
vidCap >> frame;
cv::cvtColor(frame, frame, CV_BGR2GRAY);
cv::imshow(windowName, frame);
int k = cv::waitKey(33);
if (k == 27) {
break;
}
}
return 0;
}
Is your
cam id =1
available ? did you try the defaultcv::VideoCapture vidCap(0);
?I have got a surface pro4 and I like to use a logitech webcam with cv::VideoCapture vidCap(2);
@pklab 0 is the back camera and 1 is the front camera. Somethimes it works can I can see the stream perfectly and the next time I run it ends in a bluescreen.
@LBerger have you tried it with your surface cameras? USB Cameras w. vidCap(2) works perfectly for me aswell. I guess the bluescreens are driver realated. What confusses me is that sometimes I can access the onboard cameras perfectly fine.
Yes I tried too. With 0 and 1 it is too slow and sometines blue screen.
Problem is not opencv. With my logitech webcam there is no problem.
I think that origin is Windows Hello which need facial recognition. In camera driver you can check if pcl64.dll is included (or pcl.dll).