Start on adding point settings to request handler

This commit is contained in:
Matt
2020-01-14 08:21:50 -08:00
parent c48b8c9590
commit ec93c0225c
3 changed files with 26 additions and 8 deletions

View File

@@ -4,10 +4,7 @@ import com.chameleonvision.vision.enums.*;
import com.chameleonvision.vision.pipeline.CVPipelineSettings;
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.wpi.first.wpilibj.util.Units;
import org.opencv.core.Mat;
import org.opencv.core.MatOfDouble;
import org.opencv.core.Point;
import org.opencv.core.Point3;
import org.opencv.core.*;
import java.util.Arrays;
import java.util.List;
@@ -35,7 +32,22 @@ public class StandardCVPipelineSettings extends CVPipelineSettings {
public double dualTargetCalibrationB = 0;
// 3d stuff
public double targetWidth = 15.5, targetHeight = 6.0;
public MatOfPoint3f targetCornerMat = new MatOfPoint3f();
private static MatOfPoint3f hexTargetMat = new MatOfPoint3f();
static {
hexTargetMat.fromList(List.of(
new Point3(-19.625, 0, 0),
new Point3(-9.819867, -17, 0),
new Point3(9.819867, -17, 0),
new Point3(19.625, 0, 0)));
}
public StandardCVPipelineSettings() {
super();
hexTargetMat.copyTo(targetCornerMat);
}
public boolean is3D = false;
}

View File

@@ -81,6 +81,7 @@ public class SolvePNPPipe implements Pipe<Pair<List<StandardCVPipeline.TrackedTa
// setBoundingBoxTarget(settings.targetWidth, settings.targetHeight);
// TODO add proper year differentiation
tilt_angle = tilt.getRadians();
this.objPointsMat = settings.targetCornerMat;
}
private void setCameraCoeffs(CameraCalibrationConfig settings) {

View File

@@ -176,8 +176,13 @@ public class RequestHandler {
}
public static void onPnpModel(Context ctx) throws JsonProcessingException {
ObjectMapper objectMapper = kObjectMapper;
List points = objectMapper.readValue(ctx.body(), List.class);
System.out.println(points);
//noinspection unchecked
List<Object> points = kObjectMapper.readValue(ctx.body(), List.class);
// each entry should be an xy pair
for(Object point: points) {
//noinspection RedundantCast
point = (List<Object>) point;
}
}
}