23 jevois::Component(instance), itsBuf(bufsize), itsRunning(true)
40 std::this_thread::sleep_for(std::chrono::milliseconds(10));
42 {
LINFO(
"Waiting for " <<
absolutePath(filename::get()) <<
" to start loading..."); count = 0; }
50 itsRunning.store(
false);
58{
return itsBuf.
pop(); }
65 cv::VideoCapture vcap(path);
66 if (vcap.isOpened() ==
false) { itsBuf.
push(cv::Mat());
LERROR(
"Could not open video file " << path);
return; }
69 while (itsRunning.load())
70 if (vcap.read(frame)) itsBuf.
push(frame);
else { itsBuf.
push(cv::Mat());
break; }
#define JEVOIS_WAIT_GET_FUTURE(f)
BufferedVideoReader(std::string const &instance, size_t bufsize=100)
Constructor.
~BufferedVideoReader()
Virtual destructor for safe inheritance.
virtual void postUninit() override
Uninit, wait on our run thread and swallow any exception.
cv::Mat get()
Get the next frame as a BGR cv::Mat, or an empty cv::Mat when the movie is finished.
virtual void postInit() override
Start the thread that loads, decodes and pushes the frames into our buffer.
size_t filled_size() const
std::filesystem::path absolutePath(std::filesystem::path const &path="")
std::future< std::invoke_result_t< std::decay_t< Function >, std::decay_t< Args >... > > async(Function &&f, Args &&... args)