Class PhotonCamera
java.lang.Object
org.photonvision.PhotonCamera
- All Implemented Interfaces:
AutoCloseable
Represents a camera that is connected to PhotonVision.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPhotonCamera(String cameraName) Constructs a PhotonCamera from the name of the camera.PhotonCamera(org.wpilib.networktables.NetworkTableInstance instance, String cameraName) Constructs a PhotonCamera from a root table. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The list of pipeline results sent by PhotonVision since the last call to getAllUnreadResults().Optional<org.wpilib.math.linalg.Matrix<org.wpilib.math.numbers.N3, org.wpilib.math.numbers.N3>> final org.wpilib.networktables.NetworkTableGets the NetworkTable representing this camera's subtable.Optional<org.wpilib.math.linalg.Matrix<org.wpilib.math.numbers.N8, org.wpilib.math.numbers.N1>> Returns the camera calibration's distortion coefficients, in OPENCV8 form.booleanReturns whether the camera is in driver mode.booleanintDeprecated, 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.intReturns the active pipeline index.booleanReturns whether the camera is connected and actively returning new data.voidsetDriverMode(boolean driverMode) Toggles driver mode.voidsetEnabled(boolean enabled) Sets whether the camera is enabled, default is true.voidsetFPSLimit(int fps) Sets the FPS limit on the camera.voidsetLED(VisionLEDMode led) Sets the LED mode.voidsetPipelineIndex(int index) Allows the user to select the active pipeline index.static voidsetVersionCheckEnabled(boolean enabled) Sets whether or not coprocessor version checks will occur.voidRequest the camera to save a new image file from the input camera stream with overlays.voidRequest 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
- Specified by:
closein interfaceAutoCloseable
-
setVersionCheckEnabled
Sets whether or not coprocessor version checks will occur. Setting this to true will silence all console warnings about coproccessor connection, so be careful when enabling this and ensure all your coprocessors are communicating to the robot properly and everything has matching versions.- Parameters:
enabled- Whether or not to enable coprocessor version checks
-
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!- Returns:
- The list of pipeline results
-
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!- Returns:
- The latest pipeline result
-
getDriverMode
Returns whether the camera is in driver mode.- Returns:
- Whether the camera is in driver mode.
-
setDriverMode
Toggles driver mode.- Parameters:
driverMode- Whether to set driver mode.
-
getFPSLimit
- Returns:
- The current FPS limit.
-
setFPSLimit
Sets the FPS limit on the camera.A negative FPS limit is treated as no FPS limit, and will run as fast as possible.
Otherwise, will limit processing to at most the provided FPS limit
- Parameters:
fps- The FPS limit to set.
-
setEnabled
Sets whether the camera is enabled, default is true.- Parameters:
enabled- Whether to enable the camera.
-
getEnabled
- Returns:
- Whether the camera is enabled.
-
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
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
Returns the active pipeline index.- Returns:
- The active pipeline index.
-
setPipelineIndex
Allows the user to select the active pipeline index.- Parameters:
index- The active pipeline index.
-
getLEDMode
-
setLED
-
getName
-
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<org.wpilib.math.linalg.Matrix<org.wpilib.math.numbers.N3, org.wpilib.math.numbers.N3>> getCameraMatrix() -
getDistCoeffs
public Optional<org.wpilib.math.linalg.Matrix<org.wpilib.math.numbers.N8, org.wpilib.math.numbers.N1>> getDistCoeffs()Returns the camera calibration's distortion coefficients, in OPENCV8 form. Higher-order terms are set to 0- Returns:
- The distortion coefficients in a 8x1 matrix, if they are published by the camera. Empty otherwise.
-
getCameraTable
Gets the NetworkTable representing this camera's subtable. You probably don't ever need to call this.
-