VideoCapture did not detect an unopened camera
authorPhilLab <PhilLab@users.noreply.github.com>
Tue, 26 Aug 2014 07:42:46 +0000 (09:42 +0200)
committerPhilLab <PhilLab@users.noreply.github.com>
Tue, 26 Aug 2014 07:42:46 +0000 (09:42 +0200)
modules/videoio/src/cap.cpp
modules/videoio/src/cap_dshow.cpp

index e36dc05..30ec7ec 100644 (file)
@@ -621,15 +621,15 @@ Ptr<IVideoCapture> VideoCapture::createCameraCapture(int index)
         {
 #ifdef HAVE_DSHOW
         case CV_CAP_DSHOW:
-            capture = Ptr<IVideoCapture>(new cv::VideoCapture_DShow(index));
-            if (capture)
+            capture = makePtr<VideoCapture_DShow>(index);
+            if (capture && capture.dynamicCast<VideoCapture_DShow>()->isOpened())
                 return capture;
             break; // CV_CAP_DSHOW
 #endif
 #ifdef HAVE_INTELPERC
         case CV_CAP_INTELPERC:
-            capture = Ptr<IVideoCapture>(new cv::VideoCapture_IntelPerC());
-            if (capture)
+            capture = makePtr<VideoCapture_IntelPerC>();
+            if (capture && capture.dynamicCast<VideoCapture_IntelPerC>()->isOpened())
                 return capture;
             break; // CV_CAP_INTEL_PERC
 #endif
index bc9f05e..efbbd08 100644 (file)
@@ -1590,7 +1590,7 @@ bool videoInput::isFrameNew(int id){
 
 bool videoInput::isDeviceSetup(int id){
 
-    if(id<devicesFound && VDList[id]->readyToCapture)return true;
+    if(id>=0 && id<devicesFound && VDList[id]->readyToCapture)return true;
     else return false;
 
 }