From fbcf5f091881b5c15010e1167ea544c2ec7c9406 Mon Sep 17 00:00:00 2001 From: Alexander Duda Date: Fri, 14 Aug 2015 13:40:24 +0200 Subject: [PATCH] cvCreateCameraCapture: fix using preffered interface The provided interface id must be removed from the index. Otherwise, the underlying implementations are using a wrong camera id. Example: VideoCapture(800) fails because PvAPI tries to open a camera on position 800 --- modules/videoio/src/cap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/videoio/src/cap.cpp b/modules/videoio/src/cap.cpp index d2da6edfe7..2447431cbb 100644 --- a/modules/videoio/src/cap.cpp +++ b/modules/videoio/src/cap.cpp @@ -129,6 +129,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) // interpret preferred interface (0 = autodetect) int pref = (index / 100) * 100; + // remove pref from index + index -= pref; + // local variable to memorize the captured device CvCapture *capture = 0;