From: Nikita Manovich Date: Wed, 10 Jul 2013 13:43:47 +0000 (+0400) Subject: Fixed VideoCapture::open() does not release previous capture sources (Bug #3150). X-Git-Tag: accepted/tizen/ivi/20140515.103456~1^2~652^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05aeb7083114f5cb72cefc433a987ecfc19d6cad;p=profile%2Fivi%2Fopencv.git Fixed VideoCapture::open() does not release previous capture sources (Bug #3150). VideoCapture didn't call release method and just ignored the new capture sources. OpenCV documentation: bool VideoCapture::open(const string& filename); bool VideoCapture::open(int device); The methods first call VideoCapture::release() to close the already opened file or camera. --- diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index 0d0fd41..b5cdc5e 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -489,14 +489,14 @@ VideoCapture::~VideoCapture() bool VideoCapture::open(const string& filename) { - if (!isOpened()) + if (isOpened()) release(); cap = cvCreateFileCapture(filename.c_str()); return isOpened(); } bool VideoCapture::open(int device) { - if (!isOpened()) + if (isOpened()) release(); cap = cvCreateCameraCapture(device); return isOpened(); }