fix video reading skipping

This commit is contained in:
jario-jin
2023-12-27 15:24:47 +08:00
parent 5f656487a1
commit cf6a285f3e
2 changed files with 22 additions and 14 deletions
+6 -3
View File
@@ -1185,8 +1185,11 @@ void CameraBase::_run()
{
while (this->_is_running && this->_cap.isOpened())
{
this->_cap >> this->_frame;
this->_is_updated = true;
if (this->_type != CameraType::VIDEO || this->_is_updated == false)
{
this->_cap >> this->_frame;
this->_is_updated = true;
}
std::this_thread::sleep_for(std::chrono::milliseconds(2));
}
}
@@ -1199,8 +1202,8 @@ bool CameraBase::read(cv::Mat& image)
{
if (this->_is_updated)
{
this->_is_updated = false;
this->_frame.copyTo(image);
this->_is_updated = false;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(20));