Package org.photonvision
Class PhotonCamera
java.lang.Object
org.photonvision.PhotonCamera
- All Implemented Interfaces:
AutoCloseable
Represents a camera that is connected to PhotonVision.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPhotonCamera
(edu.wpi.first.networktables.NetworkTableInstance instance, String cameraName) Constructs a PhotonCamera from a root table.PhotonCamera
(String cameraName) Constructs a PhotonCamera from the name of the camera. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Optional<edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,
edu.wpi.first.math.numbers.N3>> final edu.wpi.first.networktables.NetworkTable
Gets the NetworkTable representing this camera's subtable.Optional<edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N5,
edu.wpi.first.math.numbers.N1>> boolean
Returns whether the camera is in driver mode.Returns the latest pipeline result.Returns the current LED mode.getName()
Returns the name of the camera.int
Returns the active pipeline index.boolean
Deprecated.boolean
Returns whether the camera is connected and actively returning new data.void
setDriverMode
(boolean driverMode) Toggles driver mode.void
setLED
(VisionLEDMode led) Sets the LED mode.void
setPipelineIndex
(int index) Allows the user to select the active pipeline index.static void
setVersionCheckEnabled
(boolean enabled) void
Request the camera to save a new image file from the input camera stream with overlays.void
Request the camera to save a new image file from the output stream with overlays.
-
Field Details
-
kTableName
- See Also:
-
-
Constructor Details
-
PhotonCamera
Constructs a PhotonCamera from a root table.- Parameters:
instance
- The NetworkTableInstance to pull data from. This can be a custom instance in simulation, but should *usually* be the default NTInstance from NetworkTableInstance::getDefaultcameraName
- The name of the camera, as seen in the UI.
-
PhotonCamera
Constructs a PhotonCamera from the name of the camera.- Parameters:
cameraName
- The nickname of the camera (found in the PhotonVision UI).
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
setVersionCheckEnabled
public static void setVersionCheckEnabled(boolean enabled) -
getLatestResult
Returns the latest pipeline result.- Returns:
- The latest pipeline result.
-
getDriverMode
public boolean getDriverMode()Returns whether the camera is in driver mode.- Returns:
- Whether the camera is in driver mode.
-
setDriverMode
public void setDriverMode(boolean driverMode) Toggles driver mode.- Parameters:
driverMode
- Whether to set driver mode.
-
takeInputSnapshot
public void takeInputSnapshot()Request the camera to save a new image file from the input camera stream with overlays. Images take up space in the filesystem of the PhotonCamera. Calling it frequently will fill up disk space and eventually cause the system to stop working. Clear out images in /opt/photonvision/photonvision_config/imgSaves frequently to prevent issues. -
takeOutputSnapshot
public void takeOutputSnapshot()Request the camera to save a new image file from the output stream with overlays. Images take up space in the filesystem of the PhotonCamera. Calling it frequently will fill up disk space and eventually cause the system to stop working. Clear out images in /opt/photonvision/photonvision_config/imgSaves frequently to prevent issues. -
getPipelineIndex
public int getPipelineIndex()Returns the active pipeline index.- Returns:
- The active pipeline index.
-
setPipelineIndex
public void setPipelineIndex(int index) Allows the user to select the active pipeline index.- Parameters:
index
- The active pipeline index.
-
getLEDMode
Returns the current LED mode.- Returns:
- The current LED mode.
-
setLED
Sets the LED mode.- Parameters:
led
- The mode to set to.
-
hasTargets
Deprecated.This method should be replaced withPhotonPipelineResult.hasTargets()
Returns whether the latest target result has targets.This method is deprecated;
PhotonPipelineResult.hasTargets()
should be used instead.- Returns:
- Whether the latest target result has targets.
-
getName
Returns the name of the camera. This will return the same value that was given to the constructor as cameraName.- Returns:
- The name of the camera.
-
isConnected
public boolean isConnected()Returns whether the camera is connected and actively returning new data. Connection status is debounced.- Returns:
- True if the camera is actively sending frame data, false otherwise.
-
getCameraMatrix
public Optional<edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N3>> getCameraMatrix() -
getDistCoeffs
public Optional<edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N5,edu.wpi.first.math.numbers.N1>> getDistCoeffs() -
getCameraTable
public final edu.wpi.first.networktables.NetworkTable getCameraTable()Gets the NetworkTable representing this camera's subtable. You probably don't ever need to call this.
-
PhotonPipelineResult.hasTargets()