Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
f2a62e4126 |
|
@ -1172,9 +1172,12 @@ void CameraBase::open(CameraType type, int id)
|
|||
if (this->_cap.isOpened())
|
||||
{
|
||||
std::cout << "Camera opened!" << std::endl;
|
||||
this->_is_running = true;
|
||||
this->_tt = std::thread(&CameraBase::_run, this);
|
||||
this->_tt.detach();
|
||||
if(type != CameraType::VIDEO)
|
||||
{
|
||||
this->_is_running = true;
|
||||
this->_tt = std::thread(&CameraBase::_run, this);
|
||||
this->_tt.detach();
|
||||
}
|
||||
}
|
||||
else if (type != CameraType::NONE)
|
||||
{
|
||||
|
@ -1194,17 +1197,24 @@ bool CameraBase::read(cv::Mat& image)
|
|||
{
|
||||
if (this->_type != CameraType::NONE)
|
||||
{
|
||||
int n_try = 0;
|
||||
while (n_try < 5000)
|
||||
if(this->_type == CameraType::VIDEO)
|
||||
{
|
||||
if (this->_is_updated)
|
||||
this->_cap >> image;
|
||||
}
|
||||
else
|
||||
{
|
||||
int n_try = 0;
|
||||
while (n_try < 5000)
|
||||
{
|
||||
this->_is_updated = false;
|
||||
this->_frame.copyTo(image);
|
||||
break;
|
||||
if (this->_is_updated)
|
||||
{
|
||||
this->_is_updated = false;
|
||||
this->_frame.copyTo(image);
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
n_try ++;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
n_try ++;
|
||||
}
|
||||
}
|
||||
if (image.cols == 0 || image.rows == 0)
|
||||
|
|
Loading…
Reference in New Issue