#include <iostream>
#include <opencv2/imgproc/imgproc.hpp> // Gaussian Blur
#include <opencv2/core/core.hpp> // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp> // OpenCV window I/O
using namespace cv;//必须加入,否则无法检找到OPENCV的各个函数
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
VideoCapture cap(0); // open the default camera
if (!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
for (;;)
{
if (!cap.isOpened())
{//等等摄像头打开
continue;
}
Mat frame;
cap >> frame; // get a new frame from camera
if (frame.data == NULL)
{//等到捕获到数据
continue;
}
cvtColor(frame, edges, CV_BGR2BGRA);
imshow("edges", edges);
if (waitKey(30) >= 0) break;
}
return 0;
}
来自:http://blog.csdn.net/lan120576664
还没有评论,来说两句吧...