PhotonVision C++ dev-v2025.3.1-2-gf92cf62a
Loading...
Searching...
No Matches
photon::PhotonCamera Class Reference

Represents a camera that is connected to PhotonVision. More...

#include <photon/PhotonCamera.h>

Public Types

using CameraMatrix = Eigen::Matrix<double, 3, 3>
 
using DistortionMatrix = Eigen::Matrix<double, 8, 1>
 

Public Member Functions

 PhotonCamera (nt::NetworkTableInstance instance, const std::string_view cameraName)
 Constructs a PhotonCamera from a root table.
 
 PhotonCamera (const std::string_view cameraName)
 Constructs a PhotonCamera from the name of the camera.
 
 PhotonCamera (PhotonCamera &&)=default
 
 ~PhotonCamera ()=default
 
std::vector< PhotonPipelineResultGetAllUnreadResults ()
 The list of pipeline results sent by PhotonVision since the last call to GetAllUnreadResults().
 
PhotonPipelineResult GetLatestResult ()
 
void SetDriverMode (bool driverMode)
 Toggles driver mode.
 
bool GetDriverMode () const
 Returns whether the camera is in driver mode.
 
void TakeInputSnapshot (void)
 Request the camera to save a new image file from the input camera stream with overlays.
 
void TakeOutputSnapshot (void)
 Request the camera to save a new image file from the output stream with overlays.
 
void SetPipelineIndex (int index)
 Allows the user to select the active pipeline index.
 
int GetPipelineIndex () const
 Returns the active pipeline index.
 
LEDMode GetLEDMode () const
 Returns the current LED mode.
 
void SetLEDMode (LEDMode led)
 Sets the LED mode.
 
const std::string_view GetCameraName () const
 Returns the name of the camera.
 
bool IsConnected ()
 Returns whether the camera is connected and actively returning new data.
 
std::optional< CameraMatrixGetCameraMatrix ()
 Get the camera calibration matrix, in standard OpenCV form.
 
std::optional< DistortionMatrixGetDistCoeffs ()
 Get the camera calibration distortion coefficients, in OPENCV8 form.
 
std::shared_ptr< nt::NetworkTable > GetCameraTable () const
 

Static Public Member Functions

static void SetVersionCheckEnabled (bool enabled)
 

Public Attributes

bool test = false
 
std::vector< PhotonPipelineResulttestResult
 

Protected Attributes

std::shared_ptr< nt::NetworkTable > mainTable
 
std::shared_ptr< nt::NetworkTable > rootTable
 
nt::RawSubscriber rawBytesEntry
 
nt::IntegerPublisher inputSaveImgEntry
 
nt::IntegerSubscriber inputSaveImgSubscriber
 
nt::IntegerPublisher outputSaveImgEntry
 
nt::IntegerSubscriber outputSaveImgSubscriber
 
nt::IntegerPublisher pipelineIndexPub
 
nt::IntegerSubscriber pipelineIndexSub
 
nt::IntegerPublisher ledModePub
 
nt::IntegerSubscriber ledModeSub
 
nt::StringSubscriber versionEntry
 
nt::DoubleArraySubscriber cameraIntrinsicsSubscriber
 
nt::DoubleArraySubscriber cameraDistortionSubscriber
 
nt::BooleanSubscriber driverModeSubscriber
 
nt::BooleanPublisher driverModePublisher
 
nt::IntegerSubscriber ledModeSubscriber
 
nt::IntegerSubscriber heartbeatSubscriber
 
nt::MultiSubscriber topicNameSubscriber
 
std::string path
 
std::string cameraName
 
frc::Alert disconnectAlert
 
frc::Alert timesyncAlert
 

Detailed Description

Represents a camera that is connected to PhotonVision.

ß

Member Typedef Documentation

◆ CameraMatrix

using photon::PhotonCamera::CameraMatrix = Eigen::Matrix<double, 3, 3>

◆ DistortionMatrix

using photon::PhotonCamera::DistortionMatrix = Eigen::Matrix<double, 8, 1>

Constructor & Destructor Documentation

◆ PhotonCamera() [1/3]

photon::PhotonCamera::PhotonCamera ( nt::NetworkTableInstance instance,
const std::string_view cameraName )
explicit

Constructs a PhotonCamera from a root table.

Parameters
instanceThe NetworkTableInstance to pull data from. This can be a custom instance in simulation, but should usually be the default NTInstance from NetworkTableInstance::getDefault
cameraNameThe name of the camera, as seen in the UI. over.

◆ PhotonCamera() [2/3]

photon::PhotonCamera::PhotonCamera ( const std::string_view cameraName)
explicit

Constructs a PhotonCamera from the name of the camera.

Parameters
cameraNameThe nickname of the camera (found in the PhotonVision UI).

◆ PhotonCamera() [3/3]

photon::PhotonCamera::PhotonCamera ( PhotonCamera && )
default

◆ ~PhotonCamera()

photon::PhotonCamera::~PhotonCamera ( )
default

Member Function Documentation

◆ GetAllUnreadResults()

std::vector< PhotonPipelineResult > photon::PhotonCamera::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!

◆ GetCameraMatrix()

std::optional< CameraMatrix > photon::PhotonCamera::GetCameraMatrix ( )

Get the camera calibration matrix, in standard OpenCV form.

Returns
std::optional<cv::Mat>

◆ GetCameraName()

const std::string_view photon::PhotonCamera::GetCameraName ( ) const

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.

◆ GetCameraTable()

std::shared_ptr< nt::NetworkTable > photon::PhotonCamera::GetCameraTable ( ) const
inline

◆ GetDistCoeffs()

std::optional< DistortionMatrix > photon::PhotonCamera::GetDistCoeffs ( )

Get the camera calibration distortion coefficients, in OPENCV8 form.

Higher order terms are set to zero.

Returns
std::optional<cv::Mat>

◆ GetDriverMode()

bool photon::PhotonCamera::GetDriverMode ( ) const

Returns whether the camera is in driver mode.

Returns
Whether the camera is in driver mode.

◆ GetLatestResult()

PhotonPipelineResult photon::PhotonCamera::GetLatestResult ( )

◆ GetLEDMode()

LEDMode photon::PhotonCamera::GetLEDMode ( ) const

Returns the current LED mode.

Returns
The current LED mode.

◆ GetPipelineIndex()

int photon::PhotonCamera::GetPipelineIndex ( ) const

Returns the active pipeline index.

Returns
The active pipeline index.

◆ IsConnected()

bool photon::PhotonCamera::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.

◆ SetDriverMode()

void photon::PhotonCamera::SetDriverMode ( bool driverMode)

Toggles driver mode.

Parameters
driverModeWhether to set driver mode.

◆ SetLEDMode()

void photon::PhotonCamera::SetLEDMode ( LEDMode led)

Sets the LED mode.

Parameters
ledThe mode to set to.

◆ SetPipelineIndex()

void photon::PhotonCamera::SetPipelineIndex ( int index)

Allows the user to select the active pipeline index.

Parameters
indexThe active pipeline index.

◆ SetVersionCheckEnabled()

static void photon::PhotonCamera::SetVersionCheckEnabled ( bool enabled)
static

◆ TakeInputSnapshot()

void photon::PhotonCamera::TakeInputSnapshot ( void )

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()

void photon::PhotonCamera::TakeOutputSnapshot ( void )

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.

Member Data Documentation

◆ cameraDistortionSubscriber

nt::DoubleArraySubscriber photon::PhotonCamera::cameraDistortionSubscriber
protected

◆ cameraIntrinsicsSubscriber

nt::DoubleArraySubscriber photon::PhotonCamera::cameraIntrinsicsSubscriber
protected

◆ cameraName

std::string photon::PhotonCamera::cameraName
protected

◆ disconnectAlert

frc::Alert photon::PhotonCamera::disconnectAlert
protected

◆ driverModePublisher

nt::BooleanPublisher photon::PhotonCamera::driverModePublisher
protected

◆ driverModeSubscriber

nt::BooleanSubscriber photon::PhotonCamera::driverModeSubscriber
protected

◆ heartbeatSubscriber

nt::IntegerSubscriber photon::PhotonCamera::heartbeatSubscriber
protected

◆ inputSaveImgEntry

nt::IntegerPublisher photon::PhotonCamera::inputSaveImgEntry
protected

◆ inputSaveImgSubscriber

nt::IntegerSubscriber photon::PhotonCamera::inputSaveImgSubscriber
protected

◆ ledModePub

nt::IntegerPublisher photon::PhotonCamera::ledModePub
protected

◆ ledModeSub

nt::IntegerSubscriber photon::PhotonCamera::ledModeSub
protected

◆ ledModeSubscriber

nt::IntegerSubscriber photon::PhotonCamera::ledModeSubscriber
protected

◆ mainTable

std::shared_ptr<nt::NetworkTable> photon::PhotonCamera::mainTable
protected

◆ outputSaveImgEntry

nt::IntegerPublisher photon::PhotonCamera::outputSaveImgEntry
protected

◆ outputSaveImgSubscriber

nt::IntegerSubscriber photon::PhotonCamera::outputSaveImgSubscriber
protected

◆ path

std::string photon::PhotonCamera::path
protected

◆ pipelineIndexPub

nt::IntegerPublisher photon::PhotonCamera::pipelineIndexPub
protected

◆ pipelineIndexSub

nt::IntegerSubscriber photon::PhotonCamera::pipelineIndexSub
protected

◆ rawBytesEntry

nt::RawSubscriber photon::PhotonCamera::rawBytesEntry
protected

◆ rootTable

std::shared_ptr<nt::NetworkTable> photon::PhotonCamera::rootTable
protected

◆ test

bool photon::PhotonCamera::test = false

◆ testResult

std::vector<PhotonPipelineResult> photon::PhotonCamera::testResult

◆ timesyncAlert

frc::Alert photon::PhotonCamera::timesyncAlert
protected

◆ topicNameSubscriber

nt::MultiSubscriber photon::PhotonCamera::topicNameSubscriber
protected

◆ versionEntry

nt::StringSubscriber photon::PhotonCamera::versionEntry
protected

The documentation for this class was generated from the following file: