diff --git a/video_io/sv_video_base.cpp b/video_io/sv_video_base.cpp index aaf716a..e98941f 100644 --- a/video_io/sv_video_base.cpp +++ b/video_io/sv_video_base.cpp @@ -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 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;