From 5ff71381d2441bf03613dc4f4679126c5c864d28 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 27 Dec 2023 08:59:03 -0800 Subject: [PATCH] Run lint --- .github/workflows/main.yml | 8 +- .../org/photonvision/ArucoNanoV5Detector.java | 17 +--- .../java/org/photonvision/DetectorTest.java | 77 +++++++++---------- 3 files changed, 44 insertions(+), 58 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0a90796..37d219b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,8 +39,8 @@ jobs: - run: git fetch --tags --force - run: | chmod +x gradlew - ./gradlew build - - run: ./gradlew publish photon-targeting:publish + ./gradlew build -Ptoolchain-optional-roboRio + - run: ./gradlew publish -Ptoolchain-optional-roboRio name: Publish env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} @@ -75,11 +75,11 @@ jobs: - name: Build PhotonLib run: | chmod +x gradlew - ./gradlew build + ./gradlew build -Ptoolchain-optional-roboRio - name: Publish run: | chmod +x gradlew - ./gradlew photon-lib:publish + ./gradlew publish -Ptoolchain-optional-roboRio env: ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} if: github.event_name == 'push' diff --git a/src/main/java/org/photonvision/ArucoNanoV5Detector.java b/src/main/java/org/photonvision/ArucoNanoV5Detector.java index 3d75e3c..88389da 100644 --- a/src/main/java/org/photonvision/ArucoNanoV5Detector.java +++ b/src/main/java/org/photonvision/ArucoNanoV5Detector.java @@ -17,24 +17,11 @@ package org.photonvision; -import java.util.Arrays; -import org.opencv.core.Point; - public final class ArucoNanoV5Detector { public static class DetectionResult { public DetectionResult(double[] corns, int id) { - this.xCorners = new double[]{ - corns[0], - corns[2], - corns[4], - corns[6] - }; - this.yCorners = new double[]{ - corns[1], - corns[3], - corns[5], - corns[7] - }; + this.xCorners = new double[] {corns[0], corns[2], corns[4], corns[6]}; + this.yCorners = new double[] {corns[1], corns[3], corns[5], corns[7]}; this.id = id; } diff --git a/src/test/java/org/photonvision/DetectorTest.java b/src/test/java/org/photonvision/DetectorTest.java index f95d50d..db4b5a0 100644 --- a/src/test/java/org/photonvision/DetectorTest.java +++ b/src/test/java/org/photonvision/DetectorTest.java @@ -3,16 +3,7 @@ import edu.wpi.first.cscore.CameraServerCvJNI; import edu.wpi.first.util.CombinedRuntimeLoader; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.junit.jupiter.api.Test; import org.opencv.core.Core; -import org.opencv.core.Mat; -import org.opencv.core.MatOfPoint; -import org.opencv.core.Scalar; -import org.opencv.highgui.HighGui; -import org.opencv.imgcodecs.Imgcodecs; -import org.opencv.imgproc.Imgproc; public class DetectorTest { @@ -29,39 +20,47 @@ public static boolean loadLibraries() { } } - @Test - public void testThing() { - DetectorTest.loadLibraries(); - System.load( - "/home/matt/Documents/GitHub/fiducial-playground/build/libs/photonmiscjniJNI/shared/linuxx86-64/release/libphotonmiscjnijni.so"); + // @Test + // public void testThing() { + // DetectorTest.loadLibraries(); + // System.load( + // + // "/home/matt/Documents/GitHub/fiducial-playground/build/libs/photonmiscjniJNI/shared/linuxx86-64/release/libphotonmiscjnijni.so"); - var mat = Imgcodecs.imread("image1.jpg"); - var out = new Mat(); - mat.copyTo(out); - Imgproc.cvtColor(mat, mat, Imgproc.COLOR_BGR2GRAY); + // var mat = Imgcodecs.imread("image1.jpg"); + // var out = new Mat(); + // mat.copyTo(out); + // Imgproc.cvtColor(mat, mat, Imgproc.COLOR_BGR2GRAY); - for (int i = 0; i < 1; i++) { - var start = System.nanoTime(); - var ret = List.of(ArucoNanoV5Detector.detect(mat.getNativeObjAddr(), 0)); - var end = System.nanoTime(); - var dt = (end - start) / 1e6; - System.out.println(ret); - System.out.println("Dt ms: " + dt); + // for (int i = 0; i < 1; i++) { + // var start = System.nanoTime(); + // var ret = List.of(ArucoNanoV5Detector.detect(mat.getNativeObjAddr(), 0)); + // var end = System.nanoTime(); + // var dt = (end - start) / 1e6; + // System.out.println(ret); + // System.out.println("Dt ms: " + dt); - ArrayList pts = new ArrayList<>(); - for (var tgt : ret) { - var m = new MatOfPoint(); - m.fromArray(tgt.corners); - pts.add(m); - } - Imgproc.polylines(out, pts, true, new Scalar(0, 255, 0), 2); + // ArrayList pts = new ArrayList<>(); + // for (var tgt : ret) { + // var m = new MatOfPoint(); + // // TODO + // pts.add(m); + // } + // Imgproc.polylines(out, pts, true, new Scalar(0, 255, 0), 2); - for (var tgt : ret) { - Imgproc.putText(out, "id " + tgt.id, tgt.corners[0], 0, 1, new Scalar(255, 255, 0), 2); - } + // for (var tgt : ret) { + // Imgproc.putText( + // out, + // "id " + tgt.id, + // new Point(tgt.xCorners[0], tgt.yCorners[0]), + // 0, + // 1, + // new Scalar(255, 255, 0), + // 2); + // } - HighGui.imshow("foo", out); - HighGui.waitKey(20000); - } - } + // // HighGui.imshow("foo", out); + // // HighGui.waitKey(20000); + // } + // } }