mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-25 01:41:40 +00:00
added target offset test
This commit is contained in:
@@ -6,7 +6,6 @@ import com.chameleonvision.common.vision.opencv.ContourSortMode;
|
||||
import com.chameleonvision.common.vision.target.RobotOffsetPointMode;
|
||||
import com.chameleonvision.common.vision.target.TargetOffsetPointEdge;
|
||||
import com.chameleonvision.common.vision.target.TargetOrientation;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class AdvancedPipelineSettings extends CVPipelineSettings {
|
||||
|
||||
|
||||
@@ -62,8 +62,7 @@ public class ReflectivePipeline extends CVPipeline<CVPipelineResult, ReflectiveP
|
||||
rotateImagePipe.setParams(rotateImageParams);
|
||||
|
||||
ErodeDilatePipe.ErodeDilateParams erodeDilateParams =
|
||||
new ErodeDilatePipe.ErodeDilateParams(
|
||||
settings.erode, settings.dilate, 5);
|
||||
new ErodeDilatePipe.ErodeDilateParams(settings.erode, settings.dilate, 5);
|
||||
// TODO: add kernel size to pipeline settings
|
||||
erodeDilatePipe.setParams(erodeDilateParams);
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ package com.chameleonvision.common.vision.target;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import com.chameleonvision.common.util.TestUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.core.*;
|
||||
|
||||
public class TargetCalculationsTest {
|
||||
|
||||
@@ -13,6 +14,11 @@ public class TargetCalculationsTest {
|
||||
private static double CameraHorizontalFocalLength = 61;
|
||||
private static double CameraVerticalFocalLength = 34.3;
|
||||
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void yawTest() {
|
||||
var targetPixelOffsetX = 100;
|
||||
@@ -36,4 +42,16 @@ public class TargetCalculationsTest {
|
||||
|
||||
assertEquals(2.607, pitch, 0.025, "Pitch not as expected");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void targetOffsetTest() {
|
||||
Point center = new Point(0, 0);
|
||||
Size rectSize = new Size(10, 5);
|
||||
double angle = 30;
|
||||
RotatedRect rect = new RotatedRect(center, rectSize, angle);
|
||||
Point result =
|
||||
TargetCalculations.calculateTargetOffsetPoint(false, TargetOffsetPointEdge.Top, rect);
|
||||
assertEquals(4.3, result.x, 0.33, "Target offset x not as expected");
|
||||
assertEquals(2.5, result.y, 0.05, "Target offset Y not as expected");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user