diff --git a/openbr/plugins/stream.cpp b/openbr/plugins/stream.cpp index 15944be..4550baa 100644 --- a/openbr/plugins/stream.cpp +++ b/openbr/plugins/stream.cpp @@ -364,6 +364,7 @@ protected: QMutex last_frame_update; }; +static QMutex openLock; // Read a video frame by frame using cv::VideoCapture class VideoDataSource : public DataSource { @@ -396,6 +397,8 @@ public: // Yes, we should specify absolute path: // http://stackoverflow.com/questions/9396459/loading-a-video-in-opencv-in-python QString fileName = (Globals->path.isEmpty() ? "" : Globals->path + "/") + input.file.name; + // On windows, this appears to not be thread-safe + QMutexLocker lock(&openLock); video.open(QFileInfo(fileName).absoluteFilePath().toStdString()); } @@ -1057,7 +1060,10 @@ public: dst = src; bool res = readStage->dataSource.open(dst); - if (!res) return; + if (!res) { + qDebug("stream failed to open %s", qPrintable(dst[0].file.name)); + return; + } // Start the first thread in the stream. QWriteLocker lock(&readStage->statusLock);