Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions photon-lib/src/main/java/org/photonvision/PhotonCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.opencv.core.Core;
import org.photonvision.common.hardware.VisionLEDMode;
import org.photonvision.common.networktables.PacketSubscriber;
import org.photonvision.targeting.PhotonPipelineResult;
Expand Down Expand Up @@ -56,7 +55,7 @@
/** Represents a camera that is connected to PhotonVision. */
public class PhotonCamera implements AutoCloseable {
private static int InstanceCount = 1;
public static final String kTableName = "photonvision";

Check warning on line 58 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Build Java and C++ API Docs

no comment

Check warning on line 58 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - Linux

no comment

Check warning on line 58 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - macOS

no comment
private static final String PHOTON_ALERT_GROUP = "PhotonAlerts";

private final NetworkTable cameraTable;
Expand Down Expand Up @@ -184,61 +183,6 @@

// HACK - start a TimeSyncServer, if we haven't yet.
TimeSyncSingleton.load();

// HACK - check if things are compatible
verifyDependencies();
}

/** This is something we only need to check for java because of the way java packages opencv. */
static void verifyDependencies() {
// spotless:off
// WPILIB names their opencv version in the format YEAR-OPENCVVERSION-PATCH
// so we split on '-' and take the middle part to get the version number
if (!Core.VERSION.equals(PhotonVersion.opencvTargetVersion.split("-")[1])) {
String bfw = """




>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\s
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\s
>>> \s
>>> You are running an incompatible version \s
>>> of PhotonVision ! \s
>>> \s
>>> PhotonLib """
+ PhotonVersion.versionString
+ " is built for OpenCV "
+ PhotonVersion.opencvTargetVersion
+ "\n"
+ ">>> but you are using OpenCV "
+ Core.VERSION
+ """
\n>>> \s
>>> This is neither tested nor supported. \s
>>> You MUST update WPILib, PhotonLib, or both.
>>> Check `./gradlew dependencies` and ensure\s
>>> all mentions of OpenCV match the version \s
>>> that PhotonLib was built for. If you find a
>>> a mismatched version in a dependency, you\s
>>> must take steps to update the version of \s
>>> OpenCV used in that dependency. If you do\s
>>> not control that dependency and an updated\s
>>> version is not available, contact the \s
>>> developers of that dependency. \s
>>> \s
>>> Your code will now crash. \s
>>> We hope your day gets better. \s
>>> \s
>>> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\s
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\s
""";
// spotless:on

DriverStationErrors.reportWarning(bfw, false);
DriverStationErrors.reportError(bfw, false);
throw new UnsupportedOperationException(bfw);
}
}

/**
Expand Down Expand Up @@ -353,7 +297,7 @@
}

/**
* @return The current FPS limit.

Check warning on line 300 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Build Java and C++ API Docs

no main description

Check warning on line 300 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - Linux

no main description

Check warning on line 300 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - macOS

no main description
*/
public int getFPSLimit() {
return (int) fpsLimitSubscriber.get();
Expand Down Expand Up @@ -382,7 +326,7 @@
}

/**
* @return Whether the camera is enabled.

Check warning on line 329 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Build Java and C++ API Docs

no main description

Check warning on line 329 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - Linux

no main description

Check warning on line 329 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - macOS

no main description
*/
public boolean getEnabled() {
return enabledSubscriber.get();
Expand Down Expand Up @@ -484,7 +428,7 @@
return (now - prevHeartbeatChangeTime) < HEARTBEAT_DEBOUNCE_SEC;
}

public Optional<Matrix<N3, N3>> getCameraMatrix() {

Check warning on line 431 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Build Java and C++ API Docs

no comment

Check warning on line 431 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - Linux

no comment

Check warning on line 431 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - macOS

no comment
var cameraMatrix = cameraIntrinsicsSubscriber.get();
if (cameraMatrix != null && cameraMatrix.length == 9) {
return Optional.of(MatBuilder.fill(Nat.N3(), Nat.N3(), cameraMatrix));
Expand Down Expand Up @@ -514,7 +458,7 @@
* Gets the NetworkTable representing this camera's subtable. You probably don't ever need to call
* this.
*/
public final NetworkTable getCameraTable() {

Check warning on line 461 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Build Java and C++ API Docs

Check warning on line 461 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - Linux

Check warning on line 461 in photon-lib/src/main/java/org/photonvision/PhotonCamera.java

View workflow job for this annotation

GitHub Actions / Photonlib - Build Host - macOS

return cameraTable;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package org.photonvision;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand Down Expand Up @@ -59,9 +58,4 @@ public void testVersion() {
assertFalse(versionMatches("", "v2021.1.6"));
assertFalse(versionMatches("v2021.1.6", ""));
}

@Test
public void testNominalDeps() {
assertDoesNotThrow(PhotonCamera::verifyDependencies);
}
}
Loading