opencv vector 测试


点击(此处)折叠或打开

  1. #include <iostream>
  2. #include <cv.h>
  3. #include <cxcore.h>
  4. #include <highgui.h>

  5. using namespace std;
  6. using namespace cv;

  7. int main( )
  8. {
  9. #if 1
  10.     //声明一个2维点向量,2列,自定义行数
  11.     vector<Point2f> vp2f;
  12.     //二维点向量赋值
  13.     vp2f.push_back(Point2f(3, 3));
  14.     cout << "【二维点向量】" << endl << vp2f << endl;
  15.     //定义4*2的矩阵,并赋值,若没有赋值,则默认为0
  16.     vector<Point2f> corners(4);
  17.     corners[0] = Point2f(0,0);
  18.     corners[1] = Point2f(200-1,0);
  19.     corners[2] = Point2f(0,300-1);
  20.     corners[3] = Point2f(200-1,300-1);
  21.     cout << "【corners(4)】" << endl << corners << endl;
  22.     //定义一个5*2的矩阵,未赋值,默认为0
  23.     vector<Point2f> corners_trans(5);
  24.     cout << "【corners_trans(5)】" << endl << corners_trans << endl;
  25.     //定义20*3的矩阵,并赋值
  26.     vector<Point3f> vp3f(20);
  27.     for (size_t i = 0; i < vp3f.size(); i++)
  28.     {
  29.         vp3f[i] = Point3f((float)(i + i), (float)(i * i), (float)(i + 1));
  30.     }
  31.     cout << "【三维点向量】" << endl << vp3f << endl;
  32.   
  33. #endif
  34.      system("pause");
  35.     cvWaitKey(50000);
  36.     return 0;
  37. }


请使用浏览器的分享功能分享到微信等