I tried the following:
cv::RotatedRect minRect = cv::minAreaRect(contour);
std::vector<cv::Point2f> boxPts;
cv::boxPoints(minRect, boxPts);
The boxPoints function does not seem to like the vector of Point2f. What kind of OutputArray does it want?
One can also use RotatedRect.points which works with Point2f[] as follow:
RotatedRect minRect = minAreaRect(contour);
vector<Point2f> boxPts(4);
minRect.points(boxPts.data());
Give a Mat as OutputArray.
RotatedRect minRect = minAreaRect(contour);
Mat boxPts;
boxPoints(minRect, boxPts);
cout << boxPts.size() << endl;
cout << "boxPts " << endl << " " << boxPts << endl;
The order of the box points: bottom left, top left, top right, bottom right
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With