2014/02/07

C++ OpenCV 擷取Webcam視訊

本篇程式碼參考『[OpenCV]影像處理API-OpenCV介紹與安裝教學(OpenCV2.4.x在VS2012)


OpenCV有幾下幾種模組,分別是

core: The Core Functionality
imgproc: Image Processing
highgui: High-level GUI and Media I/O
video: Video Analysis
calib3d: Camera Calibration and 3D Reconstruction
features2d: 2D Features Framework
objdetect: Object Detection
ml: Machine Learning
flann: Clustering and Search in Multi-Dimensional Spaces
gpu: GPU-accelerated Computer Vision
photo: Computational Photography
stitching: Images stitching
nonfree: Non-free functionality
contrib: Contributed/Experimental Stuff
legacy: Deprecated stuff
ocl: OpenCL-accelerated Computer Vision
superres: Super Resolution






#include <stdio.h>
#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>

using namespace cv;
using namespace std;


int main()
{
 VideoCapture cap(0);

 if(!cap.isOpened())
  return -1;

 Mat frame;
 namedWindow("camera",1);

 for(;;)
 {
  cap >> frame;
  imshow("frame",frame);
  if(waitKey(30)>=0)break;
 }

 system("pause");
 return 0;



}





參考資料:
http://www.dotblogs.com.tw/v6610688/archive/2013/10/25/image_process_intro_opencv.aspx
http://opencv.org/
http://docs.opencv.org/index.html
http://docs.opencv.org/modules/core/doc/intro.html