How to access points from convexHull-vector?

asked 2014-07-05 08:32:26 -0500

Brixus gravatar image

Hello,

I use the function "convexHull" and I would like to know how I can access every vector point of a convex hull object.

For example I use this code:

              /// Find the convex hull object for each contour  
                 vector<vector<Point> >hull( contours_vec.size() );
                 for( int i = 0; i < contours_vec.size(); i++ )
                    {  convexHull( Mat(contours_vec[i]), hull[i], false ); }

              /// Draw contours + hull results Mat
                 Mat drawing = Mat::zeros( Dilated.size(), CV_8UC3 );  
                 for( int i = 0; i< contours_vec.size(); i++ )
                    {
                      Scalar color = Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
                      drawContours( drawing, contours_vec, i, color, 1, 8, vector<Vec4i>(), 0, Point() );
                      drawContours( drawing, hull, i, color, 1, 8, vector<Vec4i>(), 0, Point() );

If I now use "cout << hull[i] << endl;" I get something like this for every contour:

[812,176; 810,182; 805,190; 812, 173].

How can I access just for example the point 805, 190?

I tried hull[i].something, but it did not work.

Thank you very much. :-)

edit retag flag offensive close merge delete

Comments

5

hull[i] is a vector<Point>, so, hull[i][j] is the j'th Point in the i'th contour.

berak gravatar imageberak ( 2014-07-05 08:39:34 -0500 )edit

Thank you very much :-)

Brixus gravatar imageBrixus ( 2014-07-05 09:59:13 -0500 )edit