From 21211308d0afec717f987b7d08bfa8fa391514a4 Mon Sep 17 00:00:00 2001 From: Nikita Manovich Date: Wed, 10 Jul 2013 17:43:47 +0400 Subject: [PATCH] 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. --- modules/highgui/src/cap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index a76cb42..ac3d658 100644 --- a/modules/highgui/src/cap.cpp +++ b/modules/highgui/src/cap.cpp @@ -490,14 +490,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(); } -- 2.7.4