|
23 | 23 | import com.fasterxml.jackson.core.JsonProcessingException; |
24 | 24 | import edu.wpi.first.cscore.UsbCameraInfo; |
25 | 25 | import java.nio.file.Path; |
| 26 | +import java.util.Collection; |
26 | 27 | import java.util.List; |
27 | 28 | import org.junit.jupiter.api.BeforeAll; |
28 | 29 | import org.junit.jupiter.api.Order; |
|
34 | 35 | import org.photonvision.vision.camera.CameraQuirk; |
35 | 36 | import org.photonvision.vision.camera.PVCameraInfo; |
36 | 37 | import org.photonvision.vision.pipeline.AprilTagPipelineSettings; |
| 38 | +import org.photonvision.vision.pipeline.ArucoPipelineSettings; |
| 39 | +import org.photonvision.vision.pipeline.CVPipelineSettings; |
37 | 40 | import org.photonvision.vision.pipeline.ColoredShapePipelineSettings; |
38 | 41 | import org.photonvision.vision.pipeline.ObjectDetectionPipelineSettings; |
39 | 42 | import org.photonvision.vision.pipeline.ReflectivePipelineSettings; |
@@ -155,4 +158,48 @@ public void testLoadNewNNMM() throws JsonProcessingException { |
155 | 158 |
|
156 | 159 | ConfigManager.INSTANCE = null; |
157 | 160 | } |
| 161 | + |
| 162 | + @Test |
| 163 | + public void testMaxDetectionsMigration() { |
| 164 | + var folder = TestUtils.getConfigDirectoriesPath(false).resolve("2025.3.1-old-nnmm"); |
| 165 | + var cfgManager = new ConfigManager(folder, new SqlConfigProvider(folder)); |
| 166 | + |
| 167 | + // Replace global configmanager |
| 168 | + ConfigManager.INSTANCE = cfgManager; |
| 169 | + |
| 170 | + assertDoesNotThrow(cfgManager::load); |
| 171 | + |
| 172 | + Collection<CameraConfiguration> cameraConfigs = |
| 173 | + cfgManager.getConfig().getCameraConfigurations().values(); |
| 174 | + |
| 175 | + for (CameraConfiguration cc : cameraConfigs) { |
| 176 | + for (CVPipelineSettings ps : cc.pipelineSettings) { |
| 177 | + if (ps instanceof ObjectDetectionPipelineSettings odps) { |
| 178 | + // Should be set to 20 from migration |
| 179 | + ObjectDetectionPipelineSettings finalPs = odps; |
| 180 | + assertEquals(20, finalPs.outputMaximumTargets); |
| 181 | + } else if (ps instanceof ColoredShapePipelineSettings csps) { |
| 182 | + // Should be set to 20 from migration |
| 183 | + ColoredShapePipelineSettings finalPs = csps; |
| 184 | + assertEquals(20, finalPs.outputMaximumTargets); |
| 185 | + } else if (ps instanceof ReflectivePipelineSettings rps) { |
| 186 | + // Should be set to 20 from migration |
| 187 | + ReflectivePipelineSettings finalPs = rps; |
| 188 | + assertEquals(20, finalPs.outputMaximumTargets); |
| 189 | + } else if (ps instanceof AprilTagPipelineSettings atps) { |
| 190 | + // Should be set to 128 from migration |
| 191 | + AprilTagPipelineSettings finalPs = atps; |
| 192 | + assertEquals(128, finalPs.outputMaximumTargets); |
| 193 | + } else if (ps instanceof ArucoPipelineSettings aps) { |
| 194 | + // Should be set to 128 from migration |
| 195 | + ArucoPipelineSettings finalPs = aps; |
| 196 | + assertEquals(128, finalPs.outputMaximumTargets); |
| 197 | + } else { |
| 198 | + System.out.println("Skipping pipeline settings type: " + ps.getClass().getSimpleName()); |
| 199 | + } |
| 200 | + } |
| 201 | + } |
| 202 | + |
| 203 | + ConfigManager.INSTANCE = null; |
| 204 | + } |
158 | 205 | } |
0 commit comments