mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Create speckle rejection code and add to VisionProcess
Isn't yet added to the GUI
This commit is contained in:
@@ -24,6 +24,7 @@ public class CVProcess {
|
||||
private Mat binaryMat = new Mat();
|
||||
private List<MatOfPoint> filteredContours = new ArrayList<>();
|
||||
private Comparator<RotatedRect> sortByCentermostComparator = Comparator.comparingDouble(this::calcDistance);
|
||||
private List<MatOfPoint> speckleRejectedContours = new ArrayList<>();
|
||||
private Comparator<MatOfPoint> sortByMomentsX = Comparator.comparingDouble(this::calcMomentsX);
|
||||
private List<RotatedRect> finalCountours = new ArrayList<>();
|
||||
private MatOfPoint2f intersectMatA = new MatOfPoint2f();
|
||||
@@ -86,6 +87,20 @@ public class CVProcess {
|
||||
return filteredContours;
|
||||
}
|
||||
|
||||
List<MatOfPoint> rejectSpeckles(List<MatOfPoint> inputContours, Double minimumPercentOfAverage) {
|
||||
double averageArea = 0.0;
|
||||
for(MatOfPoint c : inputContours) {
|
||||
averageArea += Imgproc.contourArea(c);
|
||||
}
|
||||
averageArea /= inputContours.size();
|
||||
var minimumAllowableArea = minimumPercentOfAverage / 100.0 * averageArea;
|
||||
speckleRejectedContours.clear();
|
||||
for(MatOfPoint c : inputContours) {
|
||||
if(Imgproc.contourArea(c) >= minimumAllowableArea) speckleRejectedContours.add(c);
|
||||
}
|
||||
return speckleRejectedContours;
|
||||
}
|
||||
|
||||
private double calcDistance(RotatedRect rect) {
|
||||
return FastMath.sqrt(FastMath.pow(cameraValues.CenterX - rect.center.x, 2) + FastMath.pow(cameraValues.CenterY - rect.center.y, 2));
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.chameleonvision.vision.process;
|
||||
|
||||
import org.opencv.core.RotatedRect;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class PipelineResult {
|
||||
public boolean IsValid = false;
|
||||
public double CalibratedX = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user