稳定输出帧率,调整异常说明
Signed-off-by: AiYangSky <1732570904@qq.com>
This commit is contained in:
parent
07f7cac7b7
commit
0d3ba503e4
|
@ -1118,19 +1118,24 @@ void CameraBase::_run()
|
||||||
}
|
}
|
||||||
bool CameraBase::read(cv::Mat& image)
|
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)
|
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);
|
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);
|
falseCount ++;
|
||||||
ret = true;
|
if(falseCount >= 1000)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("SpireCV (101) Camera has offline, check CAMERA!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
{
|
falseCount = 0;
|
||||||
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
|
||||||
}
|
}
|
||||||
|
this->_frame.copyTo(image);
|
||||||
|
ret = true;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue