1,视频输入输出相关教程
https://docs.opencv.org/master/d5/dc4/tutorial_video_input_psnr_ssim.html


点击(此处)折叠或打开

  1. #include <stdio.h>
  2. #include <opencv2\opencv.hpp>

  3. using namespace std;
  4. using namespace cv;

  5. int main()
  6. {
  7.     VideoCapture cap(0); //
  8.     if (cap.isOpened())
  9.         cout << "camera is opened "<< endl;
  10.     else
  11.         cout << "camera is not opende" <<endl;
  12.     
  13.     bool stop = false;
  14.     Mat frame;

  15.     cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
  16.     cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
  17.     cap.set(CV_CAP_PROP_FPS, 30.0);

  18.     //VideoWriter writer("test0.avi", CV_FOURCC('M', 'J', 'P', 'G'), 30, Size(640,480), true);
  19.     for(;;)
  20.     {
  21.         cap >> frame;
  22.         imshow("camera0", frame);

  23.         char c = (char) waitKey(50);
  24.         if (c == 27) break;
  25.     }

  26. /*    Mat grayim(600, 800, CV_8UC1);
  27.     Mat colorim(600, 800, CV_8UC3);

  28.     grayim = imread("E:\\会务系统开发\\Module\\opencv_door\\Debug\\ceshi.jpg");    

  29.     imshow("grayim", grayim);

  30.     waitKey(0);
  31.     */
  32.     return 0;
  33. }

2, 特征提取。因为我要追踪的物体没有特征,所以需要自己去人为的创造特征。
09-29 16:43