|
|
|
| Nothing in the KOP can prepare me for you. |
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Sort array in filterContours
FWIW you could also write that as
Code:
public static void sortContoursByArea(List<MatOfPoint> contours) {
Collections.sort(contours, Comparator.comparingDouble(Imgproc::contourArea));
}
|
|
#2
|
|||||
|
|||||
|
Re: Sort array in filterContours
Quote:
Is there a name for what is hapening with "Imgproc::contourArea" ? I'd like to look up the explanation of how that works... Clearly it's getting expanded internally into Imgprog.contourArea(contours[n]) for the comparison.... but I don't know how/why..... |
|
#3
|
||||
|
||||
|
Re: Sort array in filterContours
That's called a method reference.
This article explains it quite well Also, you don't even need a special method for sorting a list. The List interface defines a method "sort(Comparator)" that you can use inline like Code:
contours.sort(Comparator.comparingDouble(Imgproc::contourArea)); |
|
#4
|
|||||
|
|||||
|
Re: Sort array in filterContours
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|