diff --git a/src/image_window.cpp b/src/image_window.cpp index 0fb818c..a4258b2 100644 --- a/src/image_window.cpp +++ b/src/image_window.cpp @@ -137,12 +137,11 @@ void ImageWindow::video_Set() { std::string vname = file_name.toStdString(); - ac::v_cap.open(vname); - if(ac::v_cap.isOpened() == false) { + if(playback->openVideo(vname) == true) { + lbl_video->setText("File Opened and Active"); + } else { QMessageBox::information(this, "Error could not open file", "File not supported"); - return; } - lbl_video->setText("File Opened and Active"); } void ImageWindow::video_Clr() { diff --git a/src/playback_thread.cpp b/src/playback_thread.cpp index a9c8e29..6313ee9 100644 --- a/src/playback_thread.cpp +++ b/src/playback_thread.cpp @@ -117,6 +117,17 @@ bool Playback::setVideoCamera(std::string name, int type, int device, int res, c return true; } +bool Playback::openVideo(std::string vname) { + mutex.lock(); + ac::v_cap.open(vname); + if(ac::v_cap.isOpened() == false) { + mutex.unlock(); + return false; + } + mutex.unlock(); + return true; +} + void Playback::setVector(std::vector v) { mutex.lock(); // here: diff --git a/src/playback_thread.h b/src/playback_thread.h index 5272771..954e180 100644 --- a/src/playback_thread.h +++ b/src/playback_thread.h @@ -76,6 +76,7 @@ public: void SetFlip(bool f1, bool f2); void setVideo(cv::VideoCapture cap, cv::VideoWriter writer, bool record, bool record_png); bool setVideoCamera(std::string name, int type, int device, int res, cv::VideoWriter writer, bool record); + bool openVideo(std::string video); bool isStopped() const; void run(); void Clear();