How to pass points to minAreaRect using Java Bindings
I'm looking for a way to use minAreaRect
with certain points I've collected. I'm converting this C++ code to Java using the OpenCV Java Bindings
c++
std::vector<cv::Point> box_points;
box_points.push_back(cv::Point(left, top));
box_points.push_back(cv::Point(left, bottom));
box_points.push_back(cv::Point(right, bottom));
box_points.push_back(cv::Point(right, top));
// Compute minimal bounding box for the ROI
// Note: for some unknown reason, width/height of the box are switched.
cv::RotatedRect box = cv::minAreaRect(cv::Mat(box_points));
Java:
List <Point> boxPoints = new ArrayList<Point>();
boxPoints.add(new Point(left, top));
boxPoints.add(new Point(left, bottom));
boxPoints.add(new Point(right, bottom));
boxPoints.add(new Point(right, top));
RotatedRect box = Imgproc.minAreaRect(new Mat(boxPoints));
However, the last line of my java code is giving me an error.
What is the best way to pass boxPoints
to minAreaRect
?