From 7e7fb0b75dde77291cf7ccb7a061063d1c9cb495 Mon Sep 17 00:00:00 2001 From: WonderRico Date: Tue, 6 Aug 2013 18:35:49 +0200 Subject: [PATCH 1/3] Bug #3201 fix --- modules/highgui/src/cap_dshow.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index b7cfbd94b3..3f364edb2c 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -3164,18 +3164,18 @@ void CvCaptureCAM_DShow::close() // Initialize camera input bool CvCaptureCAM_DShow::open( int _index ) { - int try_index = _index; int devices = 0; close(); devices = VI.listDevices(true); if (devices == 0) return false; - try_index = try_index < 0 ? 0 : (try_index > devices-1 ? devices-1 : try_index); - VI.setupDevice(try_index); - if( !VI.isDeviceSetup(try_index) ) + if (_index < 0 || index > devices-1) + return false; + VI.setupDevice(_index); + if( !VI.isDeviceSetup(_index) ) return false; - index = try_index; + index = _index; return true; } From a0483873764f43de4e5a54f96870d08340307bcd Mon Sep 17 00:00:00 2001 From: WonderRico Date: Fri, 9 Aug 2013 16:13:40 +0200 Subject: [PATCH 2/3] fix formating --- modules/highgui/src/cap_dshow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index 3f364edb2c..4dca387973 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -3170,8 +3170,8 @@ bool CvCaptureCAM_DShow::open( int _index ) devices = VI.listDevices(true); if (devices == 0) return false; - if (_index < 0 || index > devices-1) - return false; + if (_index < 0 || index > devices-1) + return false; VI.setupDevice(_index); if( !VI.isDeviceSetup(_index) ) return false; From d067749c217f3b60688fa191024231f31f8b0f42 Mon Sep 17 00:00:00 2001 From: WonderRico Date: Mon, 12 Aug 2013 11:19:53 +0200 Subject: [PATCH 3/3] fix _index / index --- modules/highgui/src/cap_dshow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index 4dca387973..606e520129 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -3170,7 +3170,7 @@ bool CvCaptureCAM_DShow::open( int _index ) devices = VI.listDevices(true); if (devices == 0) return false; - if (_index < 0 || index > devices-1) + if (_index < 0 || _index > devices-1) return false; VI.setupDevice(_index); if( !VI.isDeviceSetup(_index) )