drawContours vector<Point>
Hello forum,
I have a vector of class Object , each containing a single contour.
vector<Object> People;
Class Object {
private:
vector<Point> contour;
public:
vector<Point> get_Contour { return contour; }
};
I am having problems trying to draw the contour using the drawContours function
for (int i = 0; i < People.size(); i++)
drawContours(display, People[i].get_Contour(), -1, Scalar(255, 255, 255), 1, 8, noArray(), 2147483647 , Point());
OpenCV Error: Assertion failed (i < 0) in cv::_InputArray::getMat_, file C:\builds\master_PackSlave-win64-vc12-shared\opencv\modules\core\src\matrix.cpp, line 1151
How its done in the tutorial is that a vector< vector< Point>> is passed. However I only have one contour, a vector< Point>. I hope I can get some help on this.
may be you can use polylines instead of drawContours
Hello, thanks for the reply. However, I need to be able to offset ( Point(x,y) ) the contours as it's coordinates / midpoint is calculated by another function, Do you think I should just use vector<vector<point>> contour but with only 1 contour stored ?
Yes it works too like this
did you try in the original code instead of using
-1
for theidx
parameter to use thei
from thePeople's
size. Moreover, why yourmaxLevel
parameter is set to so high value (i.e. 2147483647)?your design looks broken. what's the need for an
Object
class ?Like @berak said, I am more convinced that you are making a huge design mistake by wrapping it inside the object class. There is about ZERO need for that right?