原文链接:https://blog.csdn.net/qq_30155503/article/details/79460420
原文链接:https://blog.csdn.net/u012792343/article/details/78068964
原文链接:https://blog.csdn.net/piaoxuezhong/article/details/54412359
#include <opencv2\highgui\highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char **argv)
{
// 打开第1个摄像头
VideoCapture cap(0);
if (!cap.isOpened())
{
cout << "不能打开摄像头!" << endl;
return -1;
}
namedWindow("正在对你录像,请保持微笑哦!", CV_WINDOW_AUTOSIZE);
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame);
if (!bSuccess)
{
cout << "不能从视频流中读取帧!" << endl;
break;
}
imshow("正在对你录像,请保持微笑哦!", frame);
waitKey(30);
}
return 0;
}
g++ -o opencv opencv.cpp `pkg-config --libs --cflags opencv` `pkg-config --cflags --libs gtk+-3.0