#include <opencv2/opencv>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
VideoCapture camera(0)
if(!camera.isOpened())
{
std::cout<<"The camera is not turned on!!!"<<std::endl;
return 1;
}
while (true)
{
Mat frame;
camera >> frame;
if(frame.empty())
break
else
{
imshow("test",frame);
}
return 0;
}
本博客介绍了一个简单的C++程序,该程序利用OpenCV库实现从摄像头捕获实时视频帧并显示。程序首先检查摄像头是否打开,然后进入一个无限循环,在每次迭代中读取一帧并显示。如果读取的帧为空,则循环终止。
4508

被折叠的 条评论
为什么被折叠?



