Skip to content

Commit

Permalink
Run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Dec 27, 2023
1 parent 2b3ed4f commit 5ff7138
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 58 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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'
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/org/photonvision/ArucoNanoV5Detector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
77 changes: 38 additions & 39 deletions src/test/java/org/photonvision/DetectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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<MatOfPoint> 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<MatOfPoint> 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);
// }
// }
}

0 comments on commit 5ff7138

Please sign in to comment.