@Override public void process(GrayU8 gray) { detector.process(gray); synchronized ( lockGui ) { List<FiducialDetector.Detected> found = detector.getDetected(); // Select the largest quadrilaterals if( found.size() <= detected.length ) { numDetected = found.size(); for (int i = 0; i < numDetected; i++) { detected[i].binary.setTo(found.get(i).binary); detected[i].location.set(found.get(i).location); } } else { indexes.resize( found.size() ); area.resize( found.size()); for (int i = 0; i < found.size(); i++) { area.set(i, -Area2D_F64.quadrilateral(found.get(i).location)); } QuickSelect.selectIndex(area.data, detected.length, found.size(), indexes.data); numDetected = detected.length; for (int i = 0; i < numDetected; i++) { int index = indexes.data[i]; detected[i].binary.setTo(found.get(index).binary); detected[i].location.set(found.get(index).location); } } } }