Hey guys, I have GRIP finding contours for the cargo in a pretty reliable way. I just need it to draw a rectangle around that. However, CV Rectangle calls for two points, so obviously the contours can’t work for that. How do I take the contours I have right now and turn those into meaningful points (ie max and min x and y) for drawing a bounding box?
Nevermind, I got it to work by just reading the contours themselves.
If anyone else is confused on this step, you use the convexHullsOutput() method to return an ArrayList of the MatOfPoints (matrix of points) that it finds, then iterate through the ArrayList and then iterate again inside of that by using toArray() which gives a regular array. Like so:
ArrayList<MatOfPoint> contours = pipeline.convexHullsOutput();
for (MatOfPoint contour : contours) {
for(int i = 0; i < contour.toArray().length; i++) {
/* do things with the value (I found the biggest and smallest X value here */
}
}