利用CvPoint的数组构建一个多边形
使用C++里面的vector容器
std::vector<CvPoint>
std::vector<CvPoint> pts1, pts2; pts1.push_back(cvPoint(100, 10)); pts1.push_back(cvPoint(10, 100)); pts1.push_back(cvPoint(200, 200)); pts2.push_back(cvPoint(100, 30)); pts2.push_back(cvPoint(30, 100)); pts2.push_back(cvPoint(150, 200)); std::vector<CvPoint*> pts; pts.push_back(pts1.begin()); pts.push_back(pts2.begin()); std::vector<int> npts; npts.push_back(pts1.size()); npts.push_back(pts2.size()); cvPolyLine(image, pts.begin(), npts.begin(), npts.size(), 1, CV_RGB(0, 0, 255));
这段代码画出下面图里的两个三角形