mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-03 03:01:40 +00:00
Remove PhotonJNICommon in favor of CombinedRuntimeLoader (#2223)
## Description PhotonJNICommon is just our implementation of combined runtime loader, which we don't really need. This removes it and just uses CombinedRuntimeLoader directly. This also fixes the issues introduced in #2219, which lead to some of our JNIs not loading. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2025.3.2 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [x] If this PR addresses a bug, a regression test for it is added --------- Co-authored-by: Matt M <matthew.morley.ca@gmail.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.photonvision.common;
|
||||
|
||||
import edu.wpi.first.util.CombinedRuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import org.photonvision.jni.LibraryLoader;
|
||||
|
||||
public class LoadJNI {
|
||||
private static HashMap<JNITypes, Boolean> loadedMap = new HashMap<>();
|
||||
|
||||
public enum JNITypes {
|
||||
RUBIK_DETECTOR("tensorflowlite", "tensorflowlite_c", "external_delegate", "rubik_jni"),
|
||||
RKNN_DETECTOR("rga", "rknnrt", "rknn_jni"),
|
||||
MRCAL("mrcal_jni"),
|
||||
LIBCAMERA("photonlibcamera");
|
||||
|
||||
public final String[] libraries;
|
||||
|
||||
JNITypes(String... libraries) {
|
||||
this.libraries = libraries;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void forceLoad(JNITypes type) throws IOException {
|
||||
loadLibraries();
|
||||
|
||||
if (loadedMap.getOrDefault(type, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CombinedRuntimeLoader.loadLibraries(LoadJNI.class, type.libraries);
|
||||
loadedMap.put(type, true);
|
||||
}
|
||||
|
||||
public static boolean loadLibraries() {
|
||||
return LibraryLoader.loadWpiLibraries() && LibraryLoader.loadTargeting();
|
||||
}
|
||||
|
||||
public static boolean hasLoaded(JNITypes t) {
|
||||
return loadedMap.getOrDefault(t, false);
|
||||
}
|
||||
}
|
||||
@@ -19,14 +19,14 @@ package org.photonvision.common.dataflow.websocket;
|
||||
|
||||
import java.util.List;
|
||||
import org.photonvision.PhotonVersion;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.LoadJNI.JNITypes;
|
||||
import org.photonvision.common.configuration.NeuralNetworkModelManager;
|
||||
import org.photonvision.common.configuration.PhotonConfiguration;
|
||||
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.networking.NetworkManager;
|
||||
import org.photonvision.common.networking.NetworkUtils;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.raspi.LibCameraJNILoader;
|
||||
import org.photonvision.vision.processes.VisionModule;
|
||||
import org.photonvision.vision.processes.VisionSourceManager;
|
||||
|
||||
@@ -53,8 +53,8 @@ public class UIPhotonConfiguration {
|
||||
new UIGeneralSettings(
|
||||
PhotonVersion.versionString,
|
||||
// TODO add support for other types of GPU accel
|
||||
LibCameraJNILoader.getInstance().isSupported() ? "Zerocopy Libcamera Working" : "",
|
||||
TestUtils.isMrcalLoaded(),
|
||||
LoadJNI.hasLoaded(JNITypes.LIBCAMERA) ? "Zerocopy Libcamera Working" : "",
|
||||
LoadJNI.hasLoaded(JNITypes.MRCAL),
|
||||
c.neuralNetworkPropertyManager().getModels(),
|
||||
NeuralNetworkModelManager.getInstance().getSupportedBackends(),
|
||||
c.getHardwareConfig().deviceName.isEmpty()
|
||||
|
||||
@@ -20,41 +20,17 @@ package org.photonvision.common.util;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import edu.wpi.first.math.geometry.Translation2d;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import edu.wpi.first.util.CombinedRuntimeLoader;
|
||||
import java.awt.HeadlessException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.highgui.HighGui;
|
||||
import org.photonvision.jni.LibraryLoader;
|
||||
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
|
||||
import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
import org.photonvision.vision.target.TrackedTarget;
|
||||
|
||||
public class TestUtils {
|
||||
private static boolean hasMrcalLoaded = false;
|
||||
|
||||
public static boolean loadLibraries() {
|
||||
return LibraryLoader.loadWpiLibraries() && LibraryLoader.loadTargeting();
|
||||
}
|
||||
|
||||
public static boolean loadMrcal() {
|
||||
if (hasMrcalLoaded) return true;
|
||||
try {
|
||||
CombinedRuntimeLoader.loadLibraries(TestUtils.class, "mrcal_jni");
|
||||
hasMrcalLoaded = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
hasMrcalLoaded = false;
|
||||
}
|
||||
return hasMrcalLoaded;
|
||||
}
|
||||
|
||||
public static boolean isMrcalLoaded() {
|
||||
return hasMrcalLoaded;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public enum WPI2019Image {
|
||||
kCargoAngledDark48in(1.2192),
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.photonvision.jni;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.List;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
|
||||
public abstract class PhotonJNICommon {
|
||||
public abstract boolean isLoaded();
|
||||
|
||||
public abstract void setLoaded(boolean state);
|
||||
|
||||
protected static Logger logger = null;
|
||||
|
||||
protected static synchronized void forceLoad(
|
||||
PhotonJNICommon instance, Class<?> clazz, List<String> libraries) throws IOException {
|
||||
if (instance.isLoaded()) return;
|
||||
if (logger == null) logger = new Logger(clazz, LogGroup.General);
|
||||
|
||||
for (var libraryName : libraries) {
|
||||
logger.info("Loading " + libraryName);
|
||||
// We always extract the shared object (we could hash each so, but that's a lot
|
||||
// of work)
|
||||
var arch_name = Platform.getNativeLibraryFolderName();
|
||||
var nativeLibName = System.mapLibraryName(libraryName);
|
||||
try (var in =
|
||||
clazz.getResourceAsStream("/nativelibraries/" + arch_name + "/" + nativeLibName)) {
|
||||
if (in == null) {
|
||||
logger.error("Could not find " + libraryName);
|
||||
instance.setLoaded(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// It's important that we don't mangle the names of these files
|
||||
var temp = Files.createTempDirectory("nativeExtract").resolve(nativeLibName);
|
||||
Files.copy(in, temp, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
try {
|
||||
System.load(temp.toAbsolutePath().toString());
|
||||
logger.info("Successfully loaded shared object " + temp.getFileName());
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
logger.error("Couldn't load shared object " + libraryName, e);
|
||||
e.printStackTrace();
|
||||
instance.setLoaded(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
instance.setLoaded(true);
|
||||
}
|
||||
|
||||
protected static synchronized void forceLoad(
|
||||
PhotonJNICommon instance, Class<?> clazz, String libraryName) throws IOException {
|
||||
forceLoad(instance, clazz, List.of(libraryName));
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.photonvision.jni;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
|
||||
public class RknnDetectorJNI extends PhotonJNICommon {
|
||||
private boolean isLoaded;
|
||||
private static RknnDetectorJNI instance = null;
|
||||
|
||||
private RknnDetectorJNI() {
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
public static RknnDetectorJNI getInstance() {
|
||||
if (instance == null) instance = new RknnDetectorJNI();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
TestUtils.loadLibraries();
|
||||
|
||||
forceLoad(getInstance(), RknnDetectorJNI.class, List.of("rga", "rknnrt", "rknn_jni"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoaded(boolean state) {
|
||||
isLoaded = state;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.photonvision.jni;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
|
||||
public class RubikDetectorJNI extends PhotonJNICommon {
|
||||
private boolean isLoaded;
|
||||
private static RubikDetectorJNI instance = null;
|
||||
|
||||
private RubikDetectorJNI() {
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
public static RubikDetectorJNI getInstance() {
|
||||
if (instance == null) instance = new RubikDetectorJNI();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
TestUtils.loadLibraries();
|
||||
|
||||
forceLoad(
|
||||
getInstance(),
|
||||
RubikDetectorJNI.class,
|
||||
List.of("tensorflowlite", "tensorflowlite_c", "external_delegate", "rubik_jni"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoaded(boolean state) {
|
||||
isLoaded = state;
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.photonvision.raspi;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.photonvision.jni.PhotonJNICommon;
|
||||
|
||||
/** Helper for extracting photon-libcamera-gl-driver shared library files. */
|
||||
public class LibCameraJNILoader extends PhotonJNICommon {
|
||||
private boolean libraryLoaded = false;
|
||||
private static LibCameraJNILoader instance = null;
|
||||
|
||||
public static synchronized LibCameraJNILoader getInstance() {
|
||||
if (instance == null) instance = new LibCameraJNILoader();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static synchronized void forceLoad() throws IOException {
|
||||
forceLoad(
|
||||
LibCameraJNILoader.getInstance(), LibCameraJNILoader.class, List.of("photonlibcamera"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return libraryLoaded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoaded(boolean state) {
|
||||
libraryLoaded = state;
|
||||
}
|
||||
|
||||
public boolean isSupported() {
|
||||
return libraryLoaded && LibCameraJNI.isSupported();
|
||||
}
|
||||
}
|
||||
@@ -26,13 +26,12 @@ import org.opencv.core.Size;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.ColorHelper;
|
||||
import org.photonvision.jni.RknnDetectorJNI;
|
||||
import org.photonvision.rknn.RknnJNI;
|
||||
import org.photonvision.vision.pipe.impl.NeuralNetworkPipeResult;
|
||||
|
||||
/** Manages an object detector using the rknn backend. */
|
||||
public class RknnObjectDetector implements ObjectDetector {
|
||||
private static final Logger logger = new Logger(RknnDetectorJNI.class, LogGroup.General);
|
||||
private static final Logger logger = new Logger(RknnObjectDetector.class, LogGroup.General);
|
||||
|
||||
/** Cleaner instance to release the detector when it goes out of scope */
|
||||
private final Cleaner cleaner = Cleaner.create();
|
||||
|
||||
@@ -26,13 +26,12 @@ import org.opencv.core.Size;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.ColorHelper;
|
||||
import org.photonvision.jni.RubikDetectorJNI;
|
||||
import org.photonvision.rubik.RubikJNI;
|
||||
import org.photonvision.vision.pipe.impl.NeuralNetworkPipeResult;
|
||||
|
||||
/** Manages an object detector using the rubik backend. */
|
||||
public class RubikObjectDetector implements ObjectDetector {
|
||||
private static final Logger logger = new Logger(RubikDetectorJNI.class, LogGroup.General);
|
||||
private static final Logger logger = new Logger(RubikObjectDetector.class, LogGroup.General);
|
||||
|
||||
/** Cleaner instance to release the detector when it goes out of scope */
|
||||
private final Cleaner cleaner = Cleaner.create();
|
||||
|
||||
@@ -27,9 +27,10 @@ import org.apache.commons.io.FileUtils;
|
||||
import org.opencv.calib3d.Calib3d;
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.LoadJNI.JNITypes;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.util.math.MathUtils;
|
||||
import org.photonvision.mrcal.MrCalJNI;
|
||||
import org.photonvision.mrcal.MrCalJNI.MrCalResult;
|
||||
@@ -94,7 +95,7 @@ public class Calibrate3dPipe
|
||||
CameraCalibrationCoefficients ret;
|
||||
var start = System.nanoTime();
|
||||
|
||||
if (TestUtils.isMrcalLoaded() && params.useMrCal) {
|
||||
if (LoadJNI.hasLoaded(JNITypes.MRCAL) && params.useMrCal) {
|
||||
logger.debug("Calibrating with mrcal!");
|
||||
ret =
|
||||
calibrateMrcal(
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.LoadJNI.JNITypes;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.dataflow.DataChangeService;
|
||||
@@ -40,7 +42,6 @@ import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.TimedTaskManager;
|
||||
import org.photonvision.raspi.LibCameraJNI;
|
||||
import org.photonvision.raspi.LibCameraJNILoader;
|
||||
import org.photonvision.vision.camera.CameraType;
|
||||
import org.photonvision.vision.camera.FileVisionSource;
|
||||
import org.photonvision.vision.camera.PVCameraInfo;
|
||||
@@ -301,7 +302,7 @@ public class VisionSourceManager {
|
||||
.filter(c -> !(String.join("", c.otherPaths()).contains("csi-video")))
|
||||
.filter(c -> !c.name().equals("unicam"))
|
||||
.forEach(cameraInfos::add);
|
||||
if (LibCameraJNILoader.getInstance().isSupported()) {
|
||||
if (LoadJNI.hasLoaded(JNITypes.LIBCAMERA)) {
|
||||
// find all CSI cameras (Raspberry Pi cameras)
|
||||
Stream.of(LibCameraJNI.getCameraNames())
|
||||
.map(
|
||||
|
||||
@@ -40,7 +40,7 @@ import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
public class BenchmarkTest {
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
public class ShapeBenchmarkTest {
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,10 +28,10 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.util.file.JacksonUtils;
|
||||
import org.photonvision.vision.camera.PVCameraInfo;
|
||||
import org.photonvision.vision.pipeline.AprilTagPipelineSettings;
|
||||
@@ -51,7 +51,7 @@ public class ConfigTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var path = Path.of("testconfigdir");
|
||||
configMgr = new ConfigManager(path, new LegacyConfigProvider(path));
|
||||
configMgr.load();
|
||||
@@ -79,7 +79,7 @@ public class ConfigTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
public void serializeConfig() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
|
||||
Logger.setLevel(LogGroup.General, LogLevel.TRACE);
|
||||
configMgr.getConfig().addCameraConfig(cameraConfig);
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.camera.CameraQuirk;
|
||||
import org.photonvision.vision.camera.PVCameraInfo;
|
||||
@@ -39,7 +40,7 @@ public class SQLConfigTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,12 +25,13 @@ import edu.wpi.first.math.geometry.Transform3d;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.math.MathUtils;
|
||||
|
||||
public class CoordinateConversionTest {
|
||||
@BeforeAll
|
||||
public static void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,17 +21,17 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.hardware.GPIO.CustomGPIO;
|
||||
import org.photonvision.common.hardware.GPIO.GPIOBase;
|
||||
import org.photonvision.common.hardware.GPIO.pi.PigpioPin;
|
||||
import org.photonvision.common.hardware.Platform;
|
||||
import org.photonvision.common.hardware.metrics.MetricsManager;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
|
||||
public class HardwareTest {
|
||||
@Test
|
||||
public void testHardware() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
MetricsManager mm = new MetricsManager();
|
||||
|
||||
if (!Platform.isRaspberryPi()) return;
|
||||
|
||||
@@ -23,13 +23,14 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.frame.Frame;
|
||||
|
||||
public class FileFrameProviderTest {
|
||||
@BeforeAll
|
||||
public static void initPath() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,12 +25,12 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
|
||||
public class ContourTest {
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.apriltag.AprilTagFamily;
|
||||
@@ -33,7 +34,7 @@ import org.photonvision.vision.target.TargetModel;
|
||||
public class AprilTagTest {
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
ConfigManager.getInstance().load();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import edu.wpi.first.math.geometry.Translation3d;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.apriltag.AprilTagFamily;
|
||||
@@ -33,7 +34,7 @@ import org.photonvision.vision.target.TargetModel;
|
||||
public class ArucoPipelineTest {
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
ConfigManager.getInstance().load();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.opencv.calib3d.Calib3d;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
@@ -50,8 +51,8 @@ import org.photonvision.vision.pipeline.UICalibrationData.TagFamily;
|
||||
public class Calibrate3dPipeTest {
|
||||
@BeforeAll
|
||||
public static void init() throws IOException {
|
||||
TestUtils.loadLibraries();
|
||||
TestUtils.loadMrcal();
|
||||
LoadJNI.loadLibraries();
|
||||
LoadJNI.forceLoad(LoadJNI.JNITypes.MRCAL);
|
||||
|
||||
var logLevel = LogLevel.DEBUG;
|
||||
Logger.setLevel(LogGroup.Camera, logLevel);
|
||||
|
||||
@@ -29,11 +29,11 @@ import org.junitpioneer.jupiter.cartesian.CartesianTest;
|
||||
import org.junitpioneer.jupiter.cartesian.CartesianTest.Enum;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
import org.photonvision.common.logging.Logger;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.estimation.OpenCVHelp;
|
||||
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
|
||||
import org.photonvision.vision.calibration.CameraLensModel;
|
||||
@@ -48,8 +48,8 @@ import org.photonvision.vision.target.TrackedTarget;
|
||||
public class CalibrationRotationPipeTest {
|
||||
@BeforeAll
|
||||
public static void init() throws IOException {
|
||||
TestUtils.loadLibraries();
|
||||
TestUtils.loadMrcal();
|
||||
LoadJNI.loadLibraries();
|
||||
LoadJNI.forceLoad(LoadJNI.JNITypes.MRCAL);
|
||||
|
||||
var logLevel = LogLevel.DEBUG;
|
||||
Logger.setLevel(LogGroup.Camera, logLevel);
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
@@ -40,7 +41,7 @@ public class CirclePNPTest {
|
||||
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,7 +133,7 @@ public class CirclePNPTest {
|
||||
|
||||
// used to run VisualVM for profiling, which won't run on unit tests.
|
||||
public static void main(String[] args) {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var frameProvider =
|
||||
new FileFrameProvider(
|
||||
TestUtils.getWPIImagePath(TestUtils.WPI2019Image.kCargoStraightDark72in_HighRes, false),
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package org.photonvision.vision.pipeline;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
import org.photonvision.vision.frame.Frame;
|
||||
@@ -89,7 +90,7 @@ public class ColoredShapePipelineTest {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
System.out.println(
|
||||
TestUtils.getWPIImagePath(TestUtils.WPI2020Image.kBlueGoal_108in_Center, false));
|
||||
var frameProvider =
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
import org.photonvision.vision.frame.Frame;
|
||||
@@ -34,7 +35,7 @@ import org.photonvision.vision.pipeline.result.CVPipelineResult;
|
||||
public class ReflectivePipelineTest {
|
||||
@Test
|
||||
public void test2019() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var pipeline = new ReflectivePipeline();
|
||||
pipeline.getSettings().hsvHue.set(60, 100);
|
||||
pipeline.getSettings().hsvSaturation.set(100, 255);
|
||||
@@ -72,7 +73,7 @@ public class ReflectivePipelineTest {
|
||||
|
||||
@Test
|
||||
public void test2020() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var pipeline = new ReflectivePipeline();
|
||||
|
||||
pipeline.getSettings().hsvHue.set(60, 100);
|
||||
@@ -108,7 +109,7 @@ public class ReflectivePipelineTest {
|
||||
|
||||
// used to run VisualVM for profiling. It won't run on unit tests.
|
||||
public static void main(String[] args) {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var frameProvider =
|
||||
new FileFrameProvider(
|
||||
TestUtils.getWPIImagePath(TestUtils.WPI2019Image.kCargoStraightDark72in_HighRes, false),
|
||||
|
||||
@@ -26,6 +26,7 @@ import edu.wpi.first.math.geometry.Translation3d;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
|
||||
import org.photonvision.vision.camera.QuirkyCamera;
|
||||
@@ -44,7 +45,7 @@ public class SolvePNPTest {
|
||||
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -213,7 +214,7 @@ public class SolvePNPTest {
|
||||
|
||||
// used to run VisualVM for profiling, which won't run on unit tests.
|
||||
public static void main(String[] args) {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
var frameProvider =
|
||||
new FileFrameProvider(
|
||||
TestUtils.getWPIImagePath(TestUtils.WPI2019Image.kCargoStraightDark72in_HighRes, false),
|
||||
|
||||
@@ -23,15 +23,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.vision.pipeline.DriverModePipelineSettings;
|
||||
import org.photonvision.vision.pipeline.PipelineType;
|
||||
|
||||
public class PipelineManagerTest {
|
||||
@BeforeAll
|
||||
public static void init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.dataflow.CVPipelineResultConsumer;
|
||||
@@ -46,7 +47,7 @@ public class VisionModuleManagerTest {
|
||||
String classpathStr = System.getProperty("java.class.path");
|
||||
System.out.print(classpathStr);
|
||||
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
if (!LibraryLoader.loadTargeting()) fail();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.configuration.CameraConfiguration;
|
||||
import org.photonvision.common.configuration.ConfigManager;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
@@ -58,7 +59,7 @@ public class VisionSourceManagerTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void loadLibraries() {
|
||||
assertTrue(TestUtils.loadLibraries());
|
||||
assertTrue(LoadJNI.loadLibraries());
|
||||
|
||||
// Broadcast all still calls into configmanager (ew) so set that up here
|
||||
ConfigManager.getInstance().load();
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.opencv.calib3d.Calib3d;
|
||||
import org.opencv.core.*;
|
||||
import org.opencv.imgproc.Imgproc;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.common.util.numbers.DoubleCouple;
|
||||
import org.photonvision.vision.calibration.CameraCalibrationCoefficients;
|
||||
import org.photonvision.vision.calibration.CameraLensModel;
|
||||
@@ -63,7 +63,7 @@ public class TargetCalculationsTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,14 +25,14 @@ import org.junit.jupiter.api.Test;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.photonvision.common.util.TestUtils;
|
||||
import org.photonvision.common.LoadJNI;
|
||||
import org.photonvision.vision.opencv.Contour;
|
||||
import org.photonvision.vision.opencv.DualOffsetValues;
|
||||
|
||||
public class TrackedTargetTest {
|
||||
@BeforeEach
|
||||
public void Init() {
|
||||
TestUtils.loadLibraries();
|
||||
LoadJNI.loadLibraries();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user