From b244310329662870ca829f49771bf05f833414b0 Mon Sep 17 00:00:00 2001 From: Matthew Morley Date: Sat, 7 Oct 2023 21:10:33 -0400 Subject: [PATCH] Add OpenCV DNN test pipeline --- build.gradle | 8 +- .../dashboard/CameraAndPipelineSelectCard.vue | 12 +- photon-client/src/types/PipelineTypes.ts | 20 +- photon-client/src/types/WebsocketDataTypes.ts | 3 +- photon-core/build.gradle | 2 +- .../vision/aruco/ArucoDetectorParams.java | 14 +- .../vision/aruco/PhotonArucoDetector.java | 2 +- .../vision/pipe/impl/ArucoDetectionPipe.java | 4 +- .../pipe/impl/ArucoDetectionPipeParams.java | 2 +- .../vision/pipeline/CVPipelineSettings.java | 3 +- .../vision/pipeline/DnnPipeline.java | 266 ++++++++++++++++++ .../vision/pipeline/DnnPipelineSettings.java | 24 ++ .../vision/pipeline/PipelineType.java | 3 +- .../vision/processes/PipelineManager.java | 6 +- photon-lib/build.gradle | 6 +- photon-server/build.gradle | 2 +- shared/common.gradle | 4 +- shared/config.gradle | 2 +- 18 files changed, 350 insertions(+), 33 deletions(-) create mode 100644 photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipeline.java create mode 100644 photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipelineSettings.java diff --git a/build.gradle b/build.gradle index 0a6e4c10a2..2714e145ea 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,12 @@ plugins { id "com.diffplug.spotless" version "6.19.0" id "com.github.johnrengelman.shadow" version "7.1.2" id "com.github.node-gradle.node" version "3.1.1" apply false - id "edu.wpi.first.GradleJni" version "1.0.0" - id "edu.wpi.first.GradleVsCode" version "1.1.0" + id "edu.wpi.first.GradleJni" version "1.1.0" + id "edu.wpi.first.GradleVsCode" version "1.3.0" id "edu.wpi.first.NativeUtils" version "2023.11.1" apply false id "edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin" version "2020.2" id "org.hidetake.ssh" version "2.10.1" - id 'edu.wpi.first.WpilibTools' version '1.0.0' + id 'edu.wpi.first.WpilibTools' version '1.1.0' } import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency; @@ -27,7 +27,7 @@ apply from: "versioningHelper.gradle" ext { wpilibVersion = "2023.4.2" - opencvVersion = "4.6.0-4" + opencvVersion = "4.8.0-1" joglVersion = "2.4.0-rc-20200307" pubVersion = versionString isDev = pubVersion.startsWith("dev") diff --git a/photon-client/src/components/dashboard/CameraAndPipelineSelectCard.vue b/photon-client/src/components/dashboard/CameraAndPipelineSelectCard.vue index adb0fa846a..4580b9f746 100644 --- a/photon-client/src/components/dashboard/CameraAndPipelineSelectCard.vue +++ b/photon-client/src/components/dashboard/CameraAndPipelineSelectCard.vue @@ -24,6 +24,9 @@ const changeCurrentCameraIndex = (index: number) => { case PipelineType.Aruco: pipelineType.value = WebsocketPipelineType.Aruco; break; + case PipelineType.Dnn: + pipelineType.value = WebsocketPipelineType.Dnn; + break; } }; @@ -151,8 +154,9 @@ const pipelineTypesWrapper = computed<{ name: string; value: number }[]>(() => { const pipelineTypes = [ { name: "Reflective", value: WebsocketPipelineType.Reflective }, { name: "Colored Shape", value: WebsocketPipelineType.ColoredShape }, - { name: "AprilTag", value: WebsocketPipelineType.AprilTag } + { name: "AprilTag", value: WebsocketPipelineType.AprilTag }, // { name: "Aruco", value: WebsocketPipelineType.Aruco } + { name: "DNN", value: WebsocketPipelineType.Dnn } ]; if (useCameraSettingsStore().isDriverMode) { @@ -203,6 +207,9 @@ useCameraSettingsStore().$subscribe((mutation, state) => { case PipelineType.Aruco: pipelineType.value = WebsocketPipelineType.Aruco; break; + case PipelineType.Dnn: + pipelineType.value = WebsocketPipelineType.Dnn; + break; } }); @@ -322,8 +329,9 @@ useCameraSettingsStore().$subscribe((mutation, state) => { :items="[ { name: 'Reflective', value: WebsocketPipelineType.Reflective }, { name: 'Colored Shape', value: WebsocketPipelineType.ColoredShape }, - { name: 'AprilTag', value: WebsocketPipelineType.AprilTag } + { name: 'AprilTag', value: WebsocketPipelineType.AprilTag }, // { name: 'Aruco', value: WebsocketPipelineType.Aruco } + { name: 'Dnn', value: WebsocketPipelineType.Dnn } ]" /> diff --git a/photon-client/src/types/PipelineTypes.ts b/photon-client/src/types/PipelineTypes.ts index 2f2a090316..ee09af6e5b 100644 --- a/photon-client/src/types/PipelineTypes.ts +++ b/photon-client/src/types/PipelineTypes.ts @@ -5,7 +5,8 @@ export enum PipelineType { Reflective = 2, ColoredShape = 3, AprilTag = 4, - Aruco = 5 + Aruco = 5, + Dnn = 6, } export enum AprilTagFamily { @@ -239,6 +240,17 @@ export const DefaultAprilTagPipelineSettings: AprilTagPipelineSettings = { tagFamily: AprilTagFamily.Family16h5 }; +export interface DnnPipelineSettings extends PipelineSettings { + pipelineType: PipelineType.Dnn; +} +export type ConfigurableDnnPipelineSettings = Partial> & + ConfigurablePipelineSettings; +export const DefaultDnnPipelineSettings: DnnPipelineSettings = { + ...DefaultPipelineSettings, + pipelineType: PipelineType.Dnn +}; + + export interface ArucoPipelineSettings extends PipelineSettings { pipelineType: PipelineType.Aruco; decimate: number; @@ -269,9 +281,11 @@ export type ActivePipelineSettings = | ReflectivePipelineSettings | ColoredShapePipelineSettings | AprilTagPipelineSettings - | ArucoPipelineSettings; + | ArucoPipelineSettings + | DnnPipelineSettings; export type ActiveConfigurablePipelineSettings = | ConfigurableReflectivePipelineSettings | ConfigurableColoredShapePipelineSettings | ConfigurableAprilTagPipelineSettings - | ConfigurableArucoPipelineSettings; + | ConfigurableArucoPipelineSettings + | ConfigurableDnnPipelineSettings; diff --git a/photon-client/src/types/WebsocketDataTypes.ts b/photon-client/src/types/WebsocketDataTypes.ts index 1add7a8c64..550c25c292 100644 --- a/photon-client/src/types/WebsocketDataTypes.ts +++ b/photon-client/src/types/WebsocketDataTypes.ts @@ -120,5 +120,6 @@ export enum WebsocketPipelineType { Reflective = 0, ColoredShape = 1, AprilTag = 2, - Aruco = 3 + Aruco = 3, + Dnn = 4 } diff --git a/photon-core/build.gradle b/photon-core/build.gradle index dde8502d4d..0d6635e517 100644 --- a/photon-core/build.gradle +++ b/photon-core/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.0.0' + id 'edu.wpi.first.WpilibTools' version '1.1.0' } import java.nio.file.Path diff --git a/photon-core/src/main/java/org/photonvision/vision/aruco/ArucoDetectorParams.java b/photon-core/src/main/java/org/photonvision/vision/aruco/ArucoDetectorParams.java index a4486a1041..810afe0536 100644 --- a/photon-core/src/main/java/org/photonvision/vision/aruco/ArucoDetectorParams.java +++ b/photon-core/src/main/java/org/photonvision/vision/aruco/ArucoDetectorParams.java @@ -17,10 +17,8 @@ package org.photonvision.vision.aruco; -import org.opencv.aruco.Aruco; -import org.opencv.aruco.ArucoDetector; -import org.opencv.aruco.DetectorParameters; -import org.opencv.aruco.Dictionary; +import org.opencv.objdetect.ArucoDetector; +import org.opencv.objdetect.DetectorParameters; import org.photonvision.common.logging.LogGroup; import org.photonvision.common.logging.Logger; @@ -31,7 +29,7 @@ public class ArucoDetectorParams { private int m_iterations = -1; private double m_accuracy = -1; - DetectorParameters parameters = DetectorParameters.create(); + DetectorParameters parameters = new DetectorParameters(); ArucoDetector detector; public ArucoDetectorParams() { @@ -39,7 +37,8 @@ public ArucoDetectorParams() { setCornerAccuracy(25); setCornerRefinementMaxIterations(100); - detector = new ArucoDetector(Dictionary.get(Aruco.DICT_APRILTAG_16h5), parameters); + // TODO + // detector = new ArucoDetector(Dictionary.get(Aruco.DICT_APRILTAG_16h5), parameters); } public void setDecimation(float decimate) { @@ -56,7 +55,8 @@ public void setDecimation(float decimate) { public void setCornerRefinementMaxIterations(int iters) { if (iters == m_iterations || iters <= 0) return; - parameters.set_cornerRefinementMethod(Aruco.CORNER_REFINE_SUBPIX); + // TODO + // parameters.set_cornerRefinementMethod(Aruco.CORNER_REFINE_SUBPIX); parameters.set_cornerRefinementMaxIterations(iters); // 200 m_iterations = iters; diff --git a/photon-core/src/main/java/org/photonvision/vision/aruco/PhotonArucoDetector.java b/photon-core/src/main/java/org/photonvision/vision/aruco/PhotonArucoDetector.java index b04418059a..0963a2812a 100644 --- a/photon-core/src/main/java/org/photonvision/vision/aruco/PhotonArucoDetector.java +++ b/photon-core/src/main/java/org/photonvision/vision/aruco/PhotonArucoDetector.java @@ -24,8 +24,8 @@ import edu.wpi.first.math.util.Units; import java.util.ArrayList; import org.opencv.aruco.Aruco; -import org.opencv.aruco.ArucoDetector; import org.opencv.core.Mat; +import org.opencv.objdetect.ArucoDetector; import org.photonvision.common.logging.LogGroup; import org.photonvision.common.logging.Logger; import org.photonvision.vision.calibration.CameraCalibrationCoefficients; diff --git a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipe.java b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipe.java index d5bc76bf55..b18978c912 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipe.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipe.java @@ -19,8 +19,8 @@ import edu.wpi.first.math.util.Units; import java.util.List; -import org.opencv.aruco.DetectorParameters; import org.opencv.core.Mat; +import org.opencv.objdetect.DetectorParameters; import org.photonvision.vision.aruco.ArucoDetectionResult; import org.photonvision.vision.aruco.PhotonArucoDetector; import org.photonvision.vision.pipe.CVPipe; @@ -45,6 +45,6 @@ public void setParams(ArucoDetectionPipeParams params) { } public DetectorParameters getParameters() { - return params == null ? null : params.detectorParams.get_params(); + return params == null ? null : params.detectorParams.getDetectorParameters(); } } diff --git a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipeParams.java b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipeParams.java index 98e9daf411..62d3214030 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipeParams.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipe/impl/ArucoDetectionPipeParams.java @@ -18,7 +18,7 @@ package org.photonvision.vision.pipe.impl; import java.util.Objects; -import org.opencv.aruco.ArucoDetector; +import org.opencv.objdetect.ArucoDetector; import org.photonvision.vision.calibration.CameraCalibrationCoefficients; public class ArucoDetectionPipeParams { diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/CVPipelineSettings.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/CVPipelineSettings.java index 077b4254a1..b89ef0a38c 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/CVPipelineSettings.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/CVPipelineSettings.java @@ -32,7 +32,8 @@ @JsonSubTypes.Type(value = ReflectivePipelineSettings.class), @JsonSubTypes.Type(value = DriverModePipelineSettings.class), @JsonSubTypes.Type(value = AprilTagPipelineSettings.class), - @JsonSubTypes.Type(value = ArucoPipelineSettings.class) + @JsonSubTypes.Type(value = ArucoPipelineSettings.class), + @JsonSubTypes.Type(value = DnnPipelineSettings.class) }) public class CVPipelineSettings implements Cloneable { public int pipelineIndex = 0; diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipeline.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipeline.java new file mode 100644 index 0000000000..0a3ad28cbf --- /dev/null +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipeline.java @@ -0,0 +1,266 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.photonvision.vision.pipeline; + +import java.util.ArrayList; +import java.util.List; +import org.opencv.core.Core; +import org.opencv.core.Mat; +import org.opencv.core.MatOfFloat; +import org.opencv.core.MatOfInt; +import org.opencv.core.MatOfRect2d; +import org.opencv.core.Point; +import org.opencv.core.Rect2d; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.dnn.Dnn; +import org.opencv.dnn.Net; +import org.opencv.imgproc.Imgproc; +import org.opencv.utils.Converters; +import org.photonvision.common.util.ColorHelper; +import org.photonvision.vision.frame.Frame; +import org.photonvision.vision.frame.FrameThresholdType; +import org.photonvision.vision.pipe.impl.*; +import org.photonvision.vision.pipeline.result.CVPipelineResult; +import org.photonvision.vision.target.TrackedTarget; + +public class DnnPipeline extends CVPipeline { + private final CalculateFPSPipe calculateFPSPipe = new CalculateFPSPipe(); + + private static final FrameThresholdType PROCESSING_TYPE = FrameThresholdType.NONE; + + public DnnPipeline() { + super(PROCESSING_TYPE); + settings = new DnnPipelineSettings(); + } + + Net net = null; + private List outBlobNames = List.of(); + + private List coco_names; + + public DnnPipeline(DnnPipelineSettings settings) { + super(PROCESSING_TYPE); + this.settings = settings; + + // Downloaded from https://dev.to/kojix2/yolov7-object-detection-in-ruby-in-10-minutes-5cjh + // https://s3.ap-northeast-2.wasabisys.com/pinto-model-zoo/307_YOLOv7/with-postprocess/resources_post.tar.gz + try { + // this.net = Dnn.readNetFromONNX("/home/matt/Downloads/best_1.onnx"); + // this.net = Dnn.readNet("/home/matt/Downloads/yolov7_post_640x640.onnx"); + this.net = + Dnn.readNetFromDarknet( + "/home/matt/Downloads/yolov4-csp-swish.cfg", + "/home/matt/Downloads/yolov4-csp-swish.weights"); + Core.setNumThreads(4); + } catch (Exception e) { + System.out.println(e); + } + this.outBlobNames = getOutputNames(net); + + this.coco_names = + List.of( + "person", + "bicycle", + "car", + "motorcycle", + "airplane", + "bus", + "train", + "truck", + "boat", + "traffic light", + "fire hydrant", + "stop sign", + "parking meter", + "bench", + "bird", + "cat", + "dog", + "horse", + "sheep", + "cow", + "elephant", + "bear", + "zebra", + "giraffe", + "backpack", + "umbrella", + "handbag", + "tie", + "suitcase", + "frisbee", + "skis", + "snowboard", + "sports ball", + "kite", + "baseball bat", + "baseball glove", + "skateboard", + "surfboard", + "tennis racket", + "bottle", + "wine glass", + "cup", + "fork", + "knife", + "spoon", + "bowl", + "banana", + "apple", + "sandwich", + "orange", + "broccoli", + "carrot", + "hot dog", + "pizza", + "donut", + "cake", + "chair", + "couch", + "potted plant", + "bed", + "dining table", + "toilet", + "tv", + "laptop", + "mouse", + "remote", + "keyboard", + "cell phone", + "microwave", + "oven", + "toaster", + "sink", + "refrigerator", + "book", + "clock", + "vase", + "scissors", + "teddy bear", + "hair drier", + "toothbrush"); + } + + @Override + protected void setPipeParamsImpl() {} + + private static List getOutputNames(Net net) { + // return new + // ArrayList<>(List.of("person","bicycle","car","motorcycle","airplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","couch","potted plant","bed","dining table","toilet","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush")); + + List names = new ArrayList<>(); + + List outLayers = net.getUnconnectedOutLayers().toList(); + List layersNames = net.getLayerNames(); + + outLayers.forEach( + (item) -> names.add(layersNames.get(item - 1))); // unfold and create R-CNN layers from the + // loaded YOLO model// + return names; + } + + @Override + protected CVPipelineResult process(Frame input_frame, DnnPipelineSettings settings) { + long sumPipeNanosElapsed = 0L; + + List targetList = List.of(); + + // ====================== + + var frame = input_frame.colorImage.getMat(); + + if (frame.empty()) { + return new CVPipelineResult(sumPipeNanosElapsed, 0, targetList, input_frame); + } + + var blob = Dnn.blobFromImage(frame, 1.0 / 255.0, new Size(640, 640)); + net.setInput(blob); + + List result = new ArrayList<>(); + net.forward(result, outBlobNames); // outputlayer : output1 and output2 + + // From https://github.com/suddh123/YOLO-object-detection-in-java/blob/code/yolo.java + + float confThreshold = 0.3f; // Insert thresholding beyond which the model will detect objects// + List clsIds = new ArrayList<>(); + List confs = new ArrayList<>(); + List rects = new ArrayList<>(); + for (int i = 0; i < result.size(); ++i) { + // each row is a candidate detection, the 1st 4 numbers are + // [center_x, center_y, width, height], followed by (N-4) class probabilities + Mat level = result.get(i); + for (int j = 0; j < level.rows(); ++j) { + Mat row = level.row(j); + Mat scores = row.colRange(5, level.cols()); + Core.MinMaxLocResult mm = Core.minMaxLoc(scores); + float confidence = (float) mm.maxVal; + Point classIdPoint = mm.maxLoc; + if (confidence > confThreshold) { + // scaling for drawing the bounding boxes// + int centerX = (int) (row.get(0, 0)[0] * frame.cols()); + int centerY = (int) (row.get(0, 1)[0] * frame.rows()); + int width = (int) (row.get(0, 2)[0] * frame.cols()); + int height = (int) (row.get(0, 3)[0] * frame.rows()); + int left = centerX - width / 2; + int top = centerY - height / 2; + + clsIds.add((int) classIdPoint.x); + confs.add((float) confidence); + rects.add(new Rect2d(left, top, width, height)); + } + } + } + float nmsThresh = 0.5f; + MatOfFloat confidences = new MatOfFloat(Converters.vector_float_to_Mat(confs)); + Rect2d[] boxesArray = rects.toArray(new Rect2d[0]); + MatOfRect2d boxes = new MatOfRect2d(boxesArray); + MatOfInt indices = new MatOfInt(); + Dnn.NMSBoxes( + boxes, + confidences, + confThreshold, + nmsThresh, + indices); // We draw the bounding boxes for objects + // here// + + int[] ind = indices.toArray(); + for (int i = 0; i < ind.length; ++i) { + int idx = ind[i]; + var box = boxesArray[idx]; + Imgproc.rectangle(frame, box.tl(), box.br(), new Scalar(0, 0, 255), 2); + Imgproc.putText( + frame, + coco_names.get(clsIds.get(idx)), + box.br(), + 0, + 0.6, + ColorHelper.colorToScalar(java.awt.Color.white), + 2); + + // System.out.println(idx); + } + + // ====================== + + var fpsResult = calculateFPSPipe.run(null); + var fps = fpsResult.output; + + return new CVPipelineResult(sumPipeNanosElapsed, fps, targetList, input_frame); + } +} diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipelineSettings.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipelineSettings.java new file mode 100644 index 0000000000..e5ae95a7bc --- /dev/null +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/DnnPipelineSettings.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) Photon Vision. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.photonvision.vision.pipeline; + +public class DnnPipelineSettings extends CVPipelineSettings { + public DnnPipelineSettings() { + this.pipelineType = PipelineType.Dnn; + } +} diff --git a/photon-core/src/main/java/org/photonvision/vision/pipeline/PipelineType.java b/photon-core/src/main/java/org/photonvision/vision/pipeline/PipelineType.java index a2f6346b89..c050a55d6f 100644 --- a/photon-core/src/main/java/org/photonvision/vision/pipeline/PipelineType.java +++ b/photon-core/src/main/java/org/photonvision/vision/pipeline/PipelineType.java @@ -24,7 +24,8 @@ public enum PipelineType { Reflective(0, ReflectivePipeline.class), ColoredShape(1, ColoredShapePipeline.class), AprilTag(2, AprilTagPipeline.class), - Aruco(3, ArucoPipeline.class); + Aruco(3, ArucoPipeline.class), + Dnn(4, DnnPipeline.class); public final int baseIndex; public final Class clazz; diff --git a/photon-core/src/main/java/org/photonvision/vision/processes/PipelineManager.java b/photon-core/src/main/java/org/photonvision/vision/processes/PipelineManager.java index f898aad573..f126a32892 100644 --- a/photon-core/src/main/java/org/photonvision/vision/processes/PipelineManager.java +++ b/photon-core/src/main/java/org/photonvision/vision/processes/PipelineManager.java @@ -21,7 +21,6 @@ import java.util.Arrays; import java.util.Comparator; import java.util.List; -import org.opencv.aruco.Aruco; import org.photonvision.common.configuration.CameraConfiguration; import org.photonvision.common.configuration.ConfigManager; import org.photonvision.common.dataflow.DataChangeService; @@ -206,11 +205,14 @@ private void setPipelineInternal(int newIndex) { currentUserPipeline = new AprilTagPipeline((AprilTagPipelineSettings) desiredPipelineSettings); break; - case Aruco: logger.debug("Creating Aruco Pipeline"); currentUserPipeline = new ArucoPipeline((ArucoPipelineSettings) desiredPipelineSettings); break; + case Dnn: + logger.debug("Creating DNN Pipeline"); + currentUserPipeline = new DnnPipeline((DnnPipelineSettings) desiredPipelineSettings); + break; default: // Can be calib3d or drivermode, both of which are special cases break; diff --git a/photon-lib/build.gradle b/photon-lib/build.gradle index 1536e9b0d6..8f48dedd61 100644 --- a/photon-lib/build.gradle +++ b/photon-lib/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.0.0' + id 'edu.wpi.first.WpilibTools' version '1.1.0' } import java.nio.file.Path @@ -50,8 +50,8 @@ dependencies { implementation "com.fasterxml.jackson.core:jackson-core:2.12.4" implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4" - implementation "edu.wpi.first.thirdparty.frc2023.opencv:opencv-java:$opencvVersion" - implementation "edu.wpi.first.thirdparty.frc2023.opencv:opencv-jni:$opencvVersion:$jniPlatform" + implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:$opencvVersion" + implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-jni:$opencvVersion:$jniPlatform" implementation "org.ejml:ejml-simple:0.41" diff --git a/photon-server/build.gradle b/photon-server/build.gradle index 6b1a5bf5ec..b965465e84 100644 --- a/photon-server/build.gradle +++ b/photon-server/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'edu.wpi.first.WpilibTools' version '1.0.0' + id 'edu.wpi.first.WpilibTools' version '1.1.0' } apply plugin: "application" diff --git a/shared/common.gradle b/shared/common.gradle index 684cf24bf9..96cab8d526 100644 --- a/shared/common.gradle +++ b/shared/common.gradle @@ -36,8 +36,8 @@ dependencies { implementation wpilibTools.deps.wpilibJava("hal") implementation wpilibTools.deps.wpilibJava("wpilibj") - implementation "edu.wpi.first.thirdparty.frc2023.opencv:opencv-java:$opencvVersion" - implementation "edu.wpi.first.thirdparty.frc2023.opencv:opencv-jni:$opencvVersion:$jniPlatform" + implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-java:$opencvVersion" + implementation "edu.wpi.first.thirdparty.frc2024.opencv:opencv-jni:$opencvVersion:$jniPlatform" implementation "org.ejml:ejml-simple:0.41" diff --git a/shared/config.gradle b/shared/config.gradle index 104faaec04..7cf75d5193 100644 --- a/shared/config.gradle +++ b/shared/config.gradle @@ -9,7 +9,7 @@ nativeUtils.wpi.configureDependencies { wpiVersion = wpilibVersion wpimathVersion = wpilibVersion niLibVersion = "2023.3.0" - opencvVersion = "4.6.0-4" + opencvVersion = "4.8.0-1" googleTestVersion = "1.12.1-1" imguiVersion = "1.86-1" }