ESM8000中的VPU解码超出最大解码能力时,用VideoCapture的open方法打不开摄像头并且阻塞的解决方法:
cv::VideoCapture camera;
camera->setExceptionMode(true);//设置为报异常
使用try…catch捕获异常
即可解决。
if(ping(ip.toLatin1().data())){
camera->setExceptionMode(true);
try {
if(camera->open(temp_webcameraUrl, cv::CAP_GSTREAMER)==false){
std::cout<<"camera open fails...!:"<<std::endl;
setCamstatus(CAMERROR);
pcamera=NULL;
return -2;
}
} catch (const cv::Exception& e) {
std::cerr << "OpenCV Exception: " << e.what() << std::endl;
return false;
}
camera->setExceptionMode(false);
}