这篇文章给大家介绍如何进行opencv vector 测试,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
#include <iostream>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
using namespace std;
using namespace cv;
int main( )
{
#if 1
//声明一个2维点向量,2列,自定义行数
vector<Point2f> vp2f;
//二维点向量赋值
vp2f.push_back(Point2f(3, 3));
cout << "【二维点向量】" << endl << vp2f << endl;
//定义4*2的矩阵,并赋值,若没有赋值,则默认为0
vector<Point2f> corners(4);
corners[0] = Point2f(0,0);
corners[1] = Point2f(200-1,0);
corners[2] = Point2f(0,300-1);
corners[3] = Point2f(200-1,300-1);
cout << "【corners(4)】" << endl << corners << endl;
//定义一个5*2的矩阵,未赋值,默认为0
vector<Point2f> corners_trans(5);
cout << "【corners_trans(5)】" << endl << corners_trans << endl;
//定义20*3的矩阵,并赋值
vector<Point3f> vp3f(20);
for (size_t i = 0; i < vp3f.size(); i++)
{
vp3f[i] = Point3f((float)(i + i), (float)(i * i), (float)(i + 1));
}
cout << "【三维点向量】" << endl << vp3f << endl;
#endif
system("pause");
cvWaitKey(50000);
return 0;
}

关于如何进行opencv vector 测试就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。