forked from PhotonVision/photonvision
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
photon-core/src/main/java/org/photonvision/jni/ArucoNanoDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.photonvision.jni; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.photonvision.ArucoNanoV5Detector; | ||
import org.photonvision.ArucoNanoV5Detector.DetectionResult; | ||
import org.photonvision.common.util.TestUtils; | ||
import org.photonvision.vision.aruco.ArucoDetectionResult; | ||
import org.photonvision.vision.opencv.CVMat; | ||
|
||
public class ArucoNanoDetector extends PhotonJNICommon { | ||
|
||
private boolean isLoaded; | ||
private static ArucoNanoDetector instance = null; | ||
|
||
private ArucoNanoDetector() { | ||
isLoaded = false; | ||
} | ||
|
||
public static ArucoNanoDetector getInstance() { | ||
if (instance == null) instance = new ArucoNanoDetector(); | ||
|
||
return instance; | ||
} | ||
|
||
public static synchronized void forceLoad() throws IOException { | ||
forceLoad(getInstance(), ArucoNanoDetector.class, List.of("photonmiscjnijni")); | ||
} | ||
|
||
@Override | ||
public boolean isLoaded() { | ||
return isLoaded; | ||
} | ||
|
||
@Override | ||
public void setLoaded(boolean state) { | ||
isLoaded = state; | ||
} | ||
|
||
public static List<ArucoDetectionResult> detect(CVMat in) { | ||
DetectionResult[] ret = ArucoNanoV5Detector.detect(in.getMat().getNativeObjAddr(), 0); | ||
|
||
return List.of(ret).stream() | ||
.map(it -> new ArucoDetectionResult(it.xCorners, it.yCorners, it.id)) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
TestUtils.loadLibraries(); | ||
forceLoad(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters