C++ Opencv如何从相机读取单帧
我试图从相机读取单帧,但它挂起了我的程序,使imshow窗口没有响应,所以你知道如何读取单帧以便我的视觉模块可以处理它吗 这是我的密码:C++ Opencv如何从相机读取单帧,c++,qt,opencv,C++,Qt,Opencv,我试图从相机读取单帧,但它挂起了我的程序,使imshow窗口没有响应,所以你知道如何读取单帧以便我的视觉模块可以处理它吗 这是我的密码: cv::VideoCapture VideoCapture; // Frame read from Camera will be stored in CamFrame MAT cv::Mat CamFrame; // Open camera VideoCapture.open(0); if(!VideoCapture.isOpened()) //
cv::VideoCapture VideoCapture;
// Frame read from Camera will be stored in CamFrame MAT
cv::Mat CamFrame;
// Open camera
VideoCapture.open(0);
if(!VideoCapture.isOpened()) // Check if we succeeded
{
with for loop it not hang the imshow model
// for (;;){
// Read frame from Camera
VideoCapture.read(this->CamFrame);
// check if we succeeded
if (this->CamFrame.empty()) {
qDebug() << "ERROR! blank frame grabbed\n";
break;
}
cv::imshow("live frame ",this->CamFrame);
// }
}
你应该在imshow之后使用。正如文件所说:
注意:此函数是HighGUI中唯一可以获取和
处理事件,因此需要为正常事件定期调用它
处理,除非在需要
关注事件处理
注意:如果要对连续帧使用imshow,可以使用特定的waitKey或in while指定If大小写
cv::VideoCapture VideoCapture;
// Frame read from Camera will be stored in CamFrame MAT
cv::Mat CamFrame;
// Open camera
VideoCapture.open(0);
if(!VideoCapture.isOpened()) // Check if we succeeded
{
with for loop it not hang the imshow model
// for (;;){
// Read frame from Camera
VideoCapture.read(this->CamFrame);
// check if we succeeded
if (this->CamFrame.empty()) {
qDebug() << "ERROR! blank frame grabbed\n";
break;
}
cv::imshow("live frame ",this->CamFrame);
waitKey(0);
// }
}