我尝试了以下方法:

cv::RotatedRect minRect = cv::minAreaRect(contour);
std::vector<cv::Point2f> boxPts;
cv::boxPoints(minRect, boxPts);

boxPoints函数似乎不喜欢Point2f的 vector 。它想要哪种OutputArray?

最佳答案

给出一个Mat作为 OutputArray

RotatedRect minRect = minAreaRect(contour);
Mat boxPts;
boxPoints(minRect, boxPts);
cout << boxPts.size() << endl;
cout << "boxPts " << endl << " " << boxPts << endl;

框的顺序为:左下,左上,右上,右下

关于c++ - 如何使用cv::boxPoints(RotatedRect框,OutputArray点),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42449090/

10-15 04:42