optimize image get
This commit is contained in:
parent
d51037be4f
commit
07f7cac7b7
|
@ -8,9 +8,9 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
sv::Camera cap;
|
||||
cap.setIp(argv[1]);
|
||||
cap.open(sv::CameraType::G1);
|
||||
cap.setWH(1280, 720);
|
||||
cap.setFps(30);
|
||||
cap.setFps(120);
|
||||
cap.open(sv::CameraType::G1);
|
||||
|
||||
cv::Mat img;
|
||||
|
||||
|
|
|
@ -1134,26 +1134,26 @@ bool CameraBase::read(cv::Mat& image)
|
|||
}
|
||||
return ret;
|
||||
|
||||
if (this->_type == CameraType::WEBCAM || this->_type == CameraType::G1 || this->_type == CameraType::MIPI)
|
||||
{
|
||||
int n_try = 0;
|
||||
while (n_try < 5000)
|
||||
{
|
||||
if (this->_is_updated)
|
||||
{
|
||||
this->_is_updated = false;
|
||||
this->_frame.copyTo(image);
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
n_try ++;
|
||||
}
|
||||
}
|
||||
if (image.cols == 0 || image.rows == 0)
|
||||
{
|
||||
throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
||||
}
|
||||
return image.cols > 0 && image.rows > 0;
|
||||
// if (this->_type == CameraType::WEBCAM || this->_type == CameraType::G1 || this->_type == CameraType::MIPI)
|
||||
// {
|
||||
// int n_try = 0;
|
||||
// while (n_try < 5000)
|
||||
// {
|
||||
// if (this->_is_updated)
|
||||
// {
|
||||
// this->_is_updated = false;
|
||||
// this->_frame.copyTo(image);
|
||||
// break;
|
||||
// }
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
// n_try ++;
|
||||
// }
|
||||
// }
|
||||
// if (image.cols == 0 || image.rows == 0)
|
||||
// {
|
||||
// throw std::runtime_error("SpireCV (101) Camera cannot OPEN, check CAMERA_ID!");
|
||||
// }
|
||||
// return image.cols > 0 && image.rows > 0;
|
||||
}
|
||||
void CameraBase::release()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue