Class PhotonCamera

java.lang.Object
org.photonvision.PhotonCamera
All Implemented Interfaces:
AutoCloseable

public class PhotonCamera extends Object implements AutoCloseable
Represents a camera that is connected to PhotonVision.
  • Field Details

  • Constructor Details

    • PhotonCamera

      public PhotonCamera(edu.wpi.first.networktables.NetworkTableInstance instance, String cameraName)
      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::getDefault
      cameraName - The name of the camera, as seen in the UI.
    • PhotonCamera

      public PhotonCamera(String cameraName)
      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 interface AutoCloseable
    • setVersionCheckEnabled

      public static void setVersionCheckEnabled(boolean enabled)
    • getLatestResult

      public PhotonPipelineResult 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

      public VisionLEDMode getLEDMode()
      Returns the current LED mode.
      Returns:
      The current LED mode.
    • setLED

      public void setLED(VisionLEDMode led)
      Sets the LED mode.
      Parameters:
      led - The mode to set to.
    • getName

      public String 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.N8,edu.wpi.first.math.numbers.N1>> getDistCoeffs()
      The camera calibration's distortion coefficients, in OPENCV8 form. Higher-order terms are set to 0
    • 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.