If I have a vector and I initialize it like this. How do I access just the first part of the point separately and second separately.
vector<Point2i> cent_i(1); // how do i initialize with a point like (1,2 )
cent_i[0][0] = (floor( s.width/2)); //TRYING TO change the points
cent_i[0][1] = (floor( s.height/2));
I don't know if I am doing this right
Based on the Documentation from OpenCv. Here is how you index a std::vector
of Point2i
named points
:
points[0].x, points[0].y, points[1].x, points[1].y, ...
You can initialize the point directly in the constructor, like:
vector<Point> pts {Point(1,2), Point(3,4), Point(5,6)};
or:
vector<Point> pts {{1,2}, {3,4}, {5,6}};
You can access i-th Point
of the vector like:
pts[i].x = ...
pts[i].y = ...
Remember that Point
is just a typedef
for Point2i
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.