Skip to content

photonlibpy.photonCamera

PhotonCamera

__init__(cameraName)

Constructs a PhotonCamera from the name of the camera.

Parameters:

Name Type Description Default
cameraName str

The nickname of the camera (found in the PhotonVision UI).

required

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!

getDriverMode()

Returns whether the camera is in driver mode.

Returns:

Type Description
bool

Whether the camera is in driver mode.

getLEDMode()

Returns the current LED mode.

Returns:

Type Description
VisionLEDMode

The current LED mode.

getLatestResult()

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 :meth:.getAllUnreadResults over getLatestResult, as this function can miss results, or provide duplicate ones! TODO implement the thing that will take this ones place...

getName()

Returns the name of the camera. This will return the same value that was given to the constructor as cameraName.

Returns:

Type Description
str

The name of the camera.

getPipelineIndex()

Returns the active pipeline index.

Returns:

Type Description
int

The active pipeline index.

isConnected()

Returns whether the camera is connected and actively returning new data. Connection status is debounced.

Returns:

Type Description
bool

True if the camera is actively sending frame data, false otherwise.

setDriverMode(driverMode)

Toggles driver mode.

Parameters:

Name Type Description Default
driverMode bool

Whether to set driver mode.

required

setLEDMode(led)

Sets the LED mode.

Parameters:

Name Type Description Default
led VisionLEDMode

The mode to set to.

required

setPipelineIndex(index)

Allows the user to select the active pipeline index.

Parameters:

Name Type Description Default
index int

The active pipeline index.

required

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.