Finally get a custom pipeline to work
@@ -324,17 +324,20 @@ export interface CustomTestPipelineSettings extends PipelineSettings {
|
||||
test3: number;
|
||||
}
|
||||
export type ConfigurableCustomTestPipelineSettings = Partial<
|
||||
Omit<CustomTestPipelineSettings, "pipelineType" | "hammingDist" | "debug">
|
||||
Omit<CustomTestPipelineSettings, "pipelineType">
|
||||
> &
|
||||
ConfigurablePipelineSettings;
|
||||
export const DefaultCustomTestPipelineSettings: CustomTestPipelineSettings = {
|
||||
...DefaultPipelineSettings,
|
||||
pipelineType: PipelineType.CustomTest,
|
||||
cameraGain: 20,
|
||||
targetModel: TargetModel.InfiniteRechargeHighGoalOuter,
|
||||
ledMode: true,
|
||||
outputShowMultipleTargets: false,
|
||||
cameraExposureRaw: 6,
|
||||
cameraGain: 75,
|
||||
outputShowMultipleTargets: true,
|
||||
targetModel: TargetModel.AprilTag6p5in_36h11,
|
||||
cameraExposureRaw: -1,
|
||||
cameraAutoExposure: true,
|
||||
ledMode: false,
|
||||
|
||||
|
||||
test1: 1,
|
||||
test2: 2,
|
||||
test3: 3
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.photonvision.vision.pipe.impl;
|
||||
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfDouble;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.photonvision.vision.pipe.MutatingPipe;
|
||||
import org.photonvision.vision.pipe.CVPipe;
|
||||
|
||||
import static org.opencv.core.Core.meanStdDev;
|
||||
|
||||
public class BlurDetectionPipe extends CVPipe<Mat, Double, BlurDetectionPipe.BlurDetectionParams> {
|
||||
@Override
|
||||
protected Double process(Mat in) {
|
||||
Mat destination = new Mat();
|
||||
Imgproc.Laplacian(in, destination, 3);
|
||||
|
||||
MatOfDouble pMean = new MatOfDouble();
|
||||
MatOfDouble pStdDev = new MatOfDouble();
|
||||
meanStdDev(destination, pMean, pStdDev);
|
||||
|
||||
double sum = 0.0;
|
||||
double[] arr = pStdDev.toArray();
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
sum += arr[i];
|
||||
}
|
||||
|
||||
return Math.pow(sum, 2);
|
||||
}
|
||||
|
||||
public static class BlurDetectionParams {
|
||||
//Default blur settings
|
||||
public static BlurDetectionParams DEFAULT = new BlurDetectionParams(0.2);
|
||||
|
||||
// Blur threshold
|
||||
private final double threshhold;
|
||||
|
||||
public BlurDetectionParams(double threshhold) {
|
||||
this.threshhold = threshhold;
|
||||
}
|
||||
|
||||
public double getThreshhold() {
|
||||
return threshhold;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,6 @@ public abstract class CVPipeline<R extends CVPipelineResult, S extends CVPipelin
|
||||
*/
|
||||
@Override
|
||||
public void release() {
|
||||
new Exception().printStackTrace();
|
||||
released = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.photonvision.common.util.ColorHelper;
|
||||
import org.photonvision.vision.frame.Frame;
|
||||
import org.photonvision.vision.frame.FrameThresholdType;
|
||||
import org.photonvision.vision.pipe.CVPipe;
|
||||
import org.photonvision.vision.pipe.impl.BlurDetectionPipe;
|
||||
import org.photonvision.vision.pipe.impl.BlurPipe;
|
||||
import org.photonvision.vision.pipe.impl.CalculateFPSPipe;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class CustomTestPipeline extends CVPipeline<CVPipelineResult, CustomTestPipelineSettings> {
|
||||
private static final FrameThresholdType PROCESSING_TYPE = FrameThresholdType.GREYSCALE;
|
||||
private final CalculateFPSPipe calculateFPSPipe = new CalculateFPSPipe();
|
||||
private final BlurDetectionPipe blurDetectionPipe = new BlurDetectionPipe();
|
||||
|
||||
private final BlurPipe blurPipe = new BlurPipe();
|
||||
|
||||
@@ -28,6 +37,7 @@ public class CustomTestPipeline extends CVPipeline<CVPipelineResult, CustomTestP
|
||||
// super.setPipeParamsImpl();
|
||||
this.released = false;
|
||||
blurPipe.setParams(new BlurPipe.BlurParams(5));
|
||||
blurDetectionPipe.setParams(new BlurDetectionPipe.BlurDetectionParams(100));
|
||||
|
||||
|
||||
// if (frameStaticProperties.cameraCalibration != null) {
|
||||
@@ -41,22 +51,33 @@ public class CustomTestPipeline extends CVPipeline<CVPipelineResult, CustomTestP
|
||||
// }
|
||||
}
|
||||
|
||||
private static final Scalar FONT_COLOR = ColorHelper.colorToScalar(Color.RED);
|
||||
|
||||
|
||||
@Override
|
||||
protected CVPipelineResult process(Frame frame, CustomTestPipelineSettings settings) {
|
||||
long total_proc_time = 0;
|
||||
|
||||
if (frame.type != FrameThresholdType.GREYSCALE) {
|
||||
// We asked for a GREYSCALE frame, but didn't get one -- best we can do is give up
|
||||
return new CVPipelineResult(frame.sequenceID, 0, 0, List.of(), frame);
|
||||
}
|
||||
|
||||
var pr = blurPipe.run(frame.processedImage.getMat());
|
||||
// var pr = blurPipe.run(frame.processedImage.getMat());
|
||||
// total_proc_time += pr.nanosElapsed;
|
||||
|
||||
double blurAmount = blurDetectionPipe.run(frame.processedImage.getMat()).output;
|
||||
System.out.println(blurAmount);
|
||||
|
||||
Imgproc.putText(frame.processedImage.getMat(), "BLUR: " + blurAmount, new Point(10,50), Imgproc.FONT_HERSHEY_TRIPLEX, 1, FONT_COLOR);
|
||||
|
||||
return new CVPipelineResult(frame.sequenceID, pr.nanosElapsed, 10, List.of(), frame);
|
||||
var fps = calculateFPSPipe.run(null).output;
|
||||
|
||||
return new CVPipelineResult(frame.sequenceID, total_proc_time, fps, List.of(), frame);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void release() {
|
||||
// super.release();
|
||||
// }
|
||||
@Override
|
||||
public void release() {
|
||||
super.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.photonvision.vision.pipeline;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
@JsonTypeName("AprilTagPipelineSettings")
|
||||
@JsonTypeName("CustomTestPipelineSettings")
|
||||
public class CustomTestPipelineSettings extends AdvancedPipelineSettings {
|
||||
public int test1 = 1;
|
||||
public int test2 = 2;
|
||||
@@ -10,7 +10,7 @@ public class CustomTestPipelineSettings extends AdvancedPipelineSettings {
|
||||
|
||||
public CustomTestPipelineSettings() {
|
||||
super();
|
||||
|
||||
pipelineType = PipelineType.CustomTest;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 333 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 327 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 331 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 336 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 338 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 323 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 360 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 338 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 342 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 350 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 364 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 367 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 370 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 347 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 356 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 668 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 670 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 648 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 657 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 647 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 653 KiB After Width: | Height: | Size: 0 B |
|
Before Width: | Height: | Size: 654 KiB After Width: | Height: | Size: 0 B |