minAreaRect of vector of vector of points
From the documentation, minAreaRect
takes an InputArray
and an InputArray
can be a std::vector<std::vector<T>>
.
However I'm getting an assertion error when calling minAreaRect
with vector<vector<Point>>
:
what(): /build/buildd/opencv-2.4.8+dfsg1/modules/core/src/matrix.cpp:977: error: (-215) 0 <= i && i < (int)vv.size() in function getMat
Isn't Point
a "T
"?
vector<vector<Point>> is a vector of contours, you should apply minAreaRect to a single contour, a vector<Point>, like contours[3]
But the documentation explicitly says
InputArray
can either be avector<T>
or avector<vector<T>>
, among others.does it ?
ok, yea, an InputArray can be anything. but not all of it makes sense in the given context.
I guess it would make sense. You can take the
minAreaRect
of a contour as well as of a set of contours, why not? If not, why allowvector<vector<T>>
?if you try, you will get a runtime exception. so, it's not allowed.
can we settle it here ?
We can: you ran out of arguments so you used a fallacy. That's common.
I would say T is a template type, so if I use T=vector< vector< vector< vector< cv::Point > > > > is still an InputArray. Therefore, it means you have to understand: InputArray could be a vector< vector< T, but it's a convenient way of writing things. There is no function able to work on all type, that the point with template, and therefore, when you are using a template, usually (always?) the class needs some basic requirement. In that case, it's that the function is working "only" with a list of points, not many list of points. Nevertheless, I will add 2 things: First, if you have a valuable impovement to make to the doc, please make a pull request. Second, if you are able to implement minAreaRect with vector of vector, please also make a pull request, therefore everyone can use it.
And to add to this discussion, afaik there is a difference between templates of form vector of vectors and a vector only. Let me clear this out
I understand the original author of this topic wants to argue that T, which is a template can be of any type and thus also of vector, however not a single OpenCV function is capable of dealing with such understanding.
Also adding the function for a vector of vector of points is quite useless and not extra functionality, you should just run over the indices of the master vector and iteratively run the operation.
I asked because I really didn't know. I was not trying to argue about T, which in fact I was not sure what it could mean (I interpreted it could be "anything" but not a vector).
What caused my doubt is the explicit mention to vectors of vectors: http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=inputarray#InputArray
Anyway I tried to create a vector or RotatedRect's in the first pass and then get the minAreaRect of that vector but I get a different assertion error: what(): /build/buildd/opencv-2.4.8+dfsg1/modules/imgproc/src/contours.cpp:1913: error: (-215) points.checkVector(2) >= 0 && (points.depth() == CV_32F || points.depth() == CV_32S) in function minAreaRect
Is it possible to compute the RotatedRect of the set of contours using API functions? Thanks.