mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
added sigmoid function
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.chameleonvision.Handler;
|
||||
import java.lang.Math;
|
||||
public class MathHandler {
|
||||
MathHandler(){}
|
||||
public static double sigmoid(double x){
|
||||
double bias = 0;
|
||||
double a = 5;
|
||||
double b = -0.05;
|
||||
double k = 200;
|
||||
if (x < 50){
|
||||
bias = -1.339;
|
||||
}
|
||||
return ((k / (1 + Math.pow(Math.E,(a + (b * x))))) + bias);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.chameleonvision.vision.process;
|
||||
|
||||
import com.chameleonvision.vision.camera.CameraValues;
|
||||
import com.chameleonvision.Handler.MathHandler;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@@ -57,8 +57,8 @@ public class CVProcess {
|
||||
for (MatOfPoint Contour : InputContours) {
|
||||
try {
|
||||
double contourArea = Imgproc.contourArea(Contour);
|
||||
double minArea = (area.get(0) * CamVals.ImageArea) / 100;
|
||||
double maxArea = (area.get(1) * CamVals.ImageArea) / 100;
|
||||
double minArea = (MathHandler.sigmoid(area.get(0)) * CamVals.ImageArea) / 100;
|
||||
double maxArea = (MathHandler.sigmoid(area.get(1)) * CamVals.ImageArea) / 100;
|
||||
if (contourArea <= minArea || contourArea >= maxArea) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user