Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

vector<vector<point> >hull( contours.size() ); does not initialize the vector with all the contours data. What you want to do is probably :

enter vector<vector<point> >hull();
hull.insert(hull.begin(),contours.begin(),contours.end());

That will copy all the contents of contours into hull, which is how I do it. Vectors aren't like arrays in C++ because they are dynamic, so when you use hull.size(), it returns zero because you haven't put anything into the vector yet. I hope that helps!

vector<vector<point> >hull( contours.size() ); does not initialize the vector with all the contours data. What you want to do is probably :

enter vector<vector<point> >hull();
hull.insert(hull.begin(),contours.begin(),contours.end());

That will copy all the contents of contours into hull, which is how I do it. Vectors aren't like arrays in C++ because they are dynamic, so when you use hull.size(), it returns zero because you haven't put anything into the vector yet. I hope that helps!

vector<vector<point> >hull( contours.size() ); does not initialize the vector with all the contours data. What you want to do is probably :

:
    vector<vector<point> >hull();
hull.insert(hull.begin(),contours.begin(),contours.end());
hull.insert(hull.begin(),contours.begin(),contours.end());

That will copy all the contents of contours into hull, which is how I do it. Vectors aren't like arrays in C++ because they are dynamic, so when you use hull.size(), it returns zero because you haven't put anything into the vector yet. I hope that helps!

vector<vector<point> >hull( contours.size() ); does not initialize the vector with all the contours data. What you want to do is probably : :

vector<vector<point> >hull();
    hull.insert(hull.begin(),contours.begin(),contours.end());

hull.insert(hull.begin(),contours.begin(),contours.end());

That will copy all the contents of contours into hull, which is how I do it. Vectors aren't like arrays in C++ because they are dynamic, so when you use hull.size(), it returns zero because you haven't put anything into the vector yet. I hope that helps!