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
(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()
The list of pipeline results sent by PhotonVision since the last call to getAllUnreadResults().final NetworkTable
Gets the NetworkTable representing this camera's subtable.The camera calibration's distortion coefficients, in OPENCV8 form.boolean
Returns whether the camera is in driver mode.Deprecated, for removal: This API element is subject to removal in a future version.Returns the current LED mode.getName()
Returns the name of the camera.int
Returns the active pipeline index.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) -
getAllUnreadResults
The list of pipeline results sent by PhotonVision since the last call to getAllUnreadResults(). Calling this function clears the internal FIFO queue, and multiple calls to getAllUnreadResults() will return different (potentially empty) result arrays. Be careful to call this exactly ONCE per loop of your robot code! FIFO depth is limited to 20 changes, so make sure to call this frequently enough to avoid old results being discarded, too! -
getLatestResult
Deprecated, for removal: This API element is subject to removal in a future version.Returns the latest pipeline result. This is simply the most recent result Received via NT. Calling this multiple times will always return the most recent result.Replaced by
getAllUnreadResults()
over getLatestResult, as this function can miss results, or provide duplicate ones! -
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.
-
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
-
getDistCoeffs
The camera calibration's distortion coefficients, in OPENCV8 form. Higher-order terms are set to 0 -
getCameraTable
Gets the NetworkTable representing this camera's subtable. You probably don't ever need to call this.
-