稳定输出帧率,调整异常说明

Signed-off-by: AiYangSky <1732570904@qq.com>
This commit is contained in:
AiYangSky 2023-09-26 03:25:00 +00:00 committed by Gitee
parent 07f7cac7b7
commit 0d3ba503e4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 12 additions and 7 deletions

View File

@ -1118,19 +1118,24 @@ void CameraBase::_run()
}
bool CameraBase::read(cv::Mat& image)
{
bool ret = false;
bool ret = false;
if (this->_type == CameraType::WEBCAM || this->_type == CameraType::G1 || this->_type == CameraType::MIPI)
{
static int falseCount=0;
std::lock_guard<std::mutex> locker(this->_frame_mutex);
if(this->_frame_empty.wait_for(this->_frame_mutex,std::chrono::milliseconds(2000)) == std::cv_status::no_timeout)
if(this->_frame_empty.wait_for(this->_frame_mutex,std::chrono::milliseconds(10)) == std::cv_status::timeout)
{
this->_frame.copyTo(image);
ret = true;
falseCount ++;
if(falseCount >= 1000)
{
throw std::runtime_error("SpireCV (101) Camera has offline, check CAMERA!");
}
}
else
{
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
else{
falseCount = 0;
}
this->_frame.copyTo(image);
ret = true;
}
return ret;