From: Vadim Pisarevsky Date: Tue, 27 Mar 2012 12:50:56 +0000 (+0000) Subject: probably fixed multi-threaded capturing from DShow cameras (ticket #1470) X-Git-Tag: accepted/2.0/20130307.220821~992 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8513ed08d09a7635a1a6547479371a4e0189083c;p=profile%2Fivi%2Fopencv.git probably fixed multi-threaded capturing from DShow cameras (ticket #1470) --- diff --git a/modules/highgui/src/cap_dshow.cpp b/modules/highgui/src/cap_dshow.cpp index 39d8c05..e6549df 100644 --- a/modules/highgui/src/cap_dshow.cpp +++ b/modules/highgui/src/cap_dshow.cpp @@ -384,7 +384,7 @@ typedef _AMMediaType AM_MEDIA_TYPE; //keeps track of how many instances of VI are being used //don't touch -static int comInitCount = 0; +//static int comInitCount = 0; //////////////////////////////////////// VIDEO DEVICE /////////////////////////////////// @@ -1915,7 +1915,7 @@ videoInput::~videoInput(){ // ---------------------------------------------------------------------- bool videoInput::comInit(){ - HRESULT hr = NOERROR; + /*HRESULT hr = NOERROR; //no need for us to start com more than once if(comInitCount == 0 ){ @@ -1935,7 +1935,7 @@ bool videoInput::comInit(){ } } - comInitCount++; + comInitCount++;*/ return true; } @@ -1946,14 +1946,15 @@ bool videoInput::comInit(){ // ---------------------------------------------------------------------- bool videoInput::comUnInit(){ - if(comInitCount > 0)comInitCount--; //decrease the count of instances using com + /*if(comInitCount > 0)comInitCount--; //decrease the count of instances using com if(comInitCount == 0){ CoUninitialize(); //if there are no instances left - uninitialize com return true; } - return false; + return false;*/ + return true; } @@ -2912,7 +2913,7 @@ class CvCaptureCAM_DShow : public CvCapture { public: CvCaptureCAM_DShow(); - virtual ~CvCaptureCAM_DShow() { close(); } + virtual ~CvCaptureCAM_DShow(); virtual bool open( int index ); virtual void close(); @@ -2944,6 +2945,13 @@ CvCaptureCAM_DShow::CvCaptureCAM_DShow() index = -1; frame = 0; width = height = -1; + CoInitialize(0); +} + +CvCaptureCAM_DShow::~CvCaptureCAM_DShow() +{ + close(); + CoUninitialize(); } void CvCaptureCAM_DShow::close()