diff --git a/modules/highgui/src/cap.cpp b/modules/highgui/src/cap.cpp index a76cb428eae0..ac3d658dc76e 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(); }