Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Use Vector Points in C++ OpenCv?

Tags:

c++

opencv

Could you guys Please help me in providing good notes or links ?

For Ex : I need to create a vector and dump these x,y values in Vector ..

Data { X , Y } = {1,1} , {1,2} , {1,3}, {2,1},{2,2},{2,3},{3,1},{3,2},{3,3}
like image 858
Pixel Avatar asked Apr 12 '13 07:04

Pixel


1 Answers

A vector of point in OpenCV is just a standard C++ STL vector containing OpenCV Point objects :

std::vector<Point> data;
data.push_back(Point(1,1));
data.push_back(Point(1,2));
data.push_back(Point(1,3));
data.push_back(Point(2,1));
...

Alternatively, if you're using C++11 or later you can use a list initialization:

std::vector<Point> data = {Point(1,1), Point(1,2), Point(1,3), Point(2,1)};

Take a look at the C++ reference for STL Vector

like image 144
zakinster Avatar answered Sep 25 '22 01:09

zakinster