GRIP draw bounding rectangle around contours

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?

For reference, here’s our current GRIP pipeline:

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 */
    }
}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.