Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
f2a62e4126 |
|
@ -1172,10 +1172,13 @@ void CameraBase::open(CameraType type, int id)
|
||||||
if (this->_cap.isOpened())
|
if (this->_cap.isOpened())
|
||||||
{
|
{
|
||||||
std::cout << "Camera opened!" << std::endl;
|
std::cout << "Camera opened!" << std::endl;
|
||||||
|
if(type != CameraType::VIDEO)
|
||||||
|
{
|
||||||
this->_is_running = true;
|
this->_is_running = true;
|
||||||
this->_tt = std::thread(&CameraBase::_run, this);
|
this->_tt = std::thread(&CameraBase::_run, this);
|
||||||
this->_tt.detach();
|
this->_tt.detach();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (type != CameraType::NONE)
|
else if (type != CameraType::NONE)
|
||||||
{
|
{
|
||||||
std::cout << "Camera can NOT open!" << std::endl;
|
std::cout << "Camera can NOT open!" << std::endl;
|
||||||
|
@ -1193,6 +1196,12 @@ void CameraBase::_run()
|
||||||
bool CameraBase::read(cv::Mat& image)
|
bool CameraBase::read(cv::Mat& image)
|
||||||
{
|
{
|
||||||
if (this->_type != CameraType::NONE)
|
if (this->_type != CameraType::NONE)
|
||||||
|
{
|
||||||
|
if(this->_type == CameraType::VIDEO)
|
||||||
|
{
|
||||||
|
this->_cap >> image;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int n_try = 0;
|
int n_try = 0;
|
||||||
while (n_try < 5000)
|
while (n_try < 5000)
|
||||||
|
@ -1207,6 +1216,7 @@ bool CameraBase::read(cv::Mat& image)
|
||||||
n_try ++;
|
n_try ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (image.cols == 0 || image.rows == 0)
|
if (image.cols == 0 || image.rows == 0)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
||||||
|
|
Loading…
Reference in New Issue