Opencv java how to sort a bubble sheet TopLeftToBottomRight

asked 2019-06-06 20:56:10 -0600

albert gravatar image

I want to run this code but i have an error : double[] can not be converted to Point. Errors occur on e1.get(0,0 ) and e2.get(0,0 ) i need help please

 public static void sortTopLeft2BottomRight(List<MatOfPoint> points){
    // top-left to right-bottom sort
    Collections.sort(points, (e1, e2) -> {

        **Point o1 = new Point(e1.get(0, 0));
        Point o2 = new Point(e2.get(0, 0));**

        return o1.y > o2.y ? 1 : -1;
    });
}
edit retag flag offensive close merge delete

Comments

1

that's a list of contours (which are kinda lists of points again) ? then your idea probably won't work at all.

imho, you can't (or shouldn't) use the points "as is", but have to make a list of the contour centers first, and sort that.

then there's a trick, to sort by x and y at the same time:

 return o1.y*10000 + o1.x  > o2.y*10000 + o2.x ? 1 : -1;
berak gravatar imageberak ( 2019-06-07 03:17:44 -0600 )edit