Opencv java how to sort a bubble sheet TopLeftToBottomRight
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;
});
}
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: