![]() |
PhotonVision C++ v2026.2.2
|
#include <photon/simulation/PhotonCameraSim.h>
Public Member Functions | |
| PhotonCameraSim (PhotonCamera *camera) | |
| Constructs a handle for simulating PhotonCamera values. | |
| PhotonCameraSim (PhotonCamera *camera, const SimCameraProperties &props, const frc::AprilTagFieldLayout &tagLayout=frc::AprilTagFieldLayout::LoadField(frc::AprilTagField::kDefaultField)) | |
| Constructs a handle for simulating PhotonCamera values. | |
| PhotonCameraSim (PhotonCamera *camera, const SimCameraProperties &props, double minTargetAreaPercent, units::meter_t maxSightRange) | |
| Constructs a handle for simulating PhotonCamera values. | |
| PhotonCamera * | GetCamera () |
| Returns the camera being simulated. | |
| double | GetMinTargetAreaPercent () |
| Returns the minimum percentage (0 - 100) a detected target must take up of the camera's image to be processed. | |
| double | GetMinTargetAreaPixels () |
| Returns the minimum number of pixels a detected target must take up in the camera's image to be processed. | |
| units::meter_t | GetMaxSightRange () |
| Returns the maximum distance at which the target is illuminated to your camera. | |
| const cs::CvSource & | GetVideoSimRaw () |
| const cv::Mat & | GetVideoSimFrameRaw () |
| bool | CanSeeTargetPose (const frc::Pose3d &camPose, const VisionTargetSim &target) |
| Determines if this target's pose should be visible to the camera without considering its projected image points. | |
| bool | CanSeeCorner (const std::vector< cv::Point2f > &points) |
| Determines if all target points are inside the camera's image. | |
| std::optional< uint64_t > | ConsumeNextEntryTime () |
| Determine if this camera should process a new frame based on performance metrics and the time since the last update. | |
| void | SetMinTargetAreaPercent (double areaPercent) |
| Sets the minimum percentage (0 - 100) a detected target must take up of the camera's image to be processed. | |
| void | SetMinTargetAreaPixels (double areaPx) |
| Sets the minimum number of pixels a detected target must take up in the camera's image to be processed. | |
| void | SetMaxSightRange (units::meter_t range) |
| Sets the maximum distance at which the target is illuminated to your camera. | |
| void | EnableRawStream (bool enabled) |
| Sets whether the raw video stream simulation is enabled. | |
| void | EnableDrawWireframe (bool enabled) |
| Sets whether a wireframe of the field is drawn to the raw video stream. | |
| void | SetWireframeResolution (double resolution) |
| Sets the resolution of the drawn wireframe if enabled. | |
| void | EnabledProcessedStream (double enabled) |
| Sets whether the processed video stream simulation is enabled. | |
| PhotonPipelineResult | Process (units::second_t latency, const frc::Pose3d &cameraPose, std::vector< VisionTargetSim > targets) |
| void | SubmitProcessedFrame (const PhotonPipelineResult &result) |
| void | SubmitProcessedFrame (const PhotonPipelineResult &result, uint64_t ReceiveTimestamp) |
Public Attributes | |
| SimCameraProperties | prop |
|
explicit |
Constructs a handle for simulating PhotonCamera values.
Processing simulated targets through this class will change the associated PhotonCamera's results.
WARNING: This constructor's camera has a 90 deg FOV with no simulated lag!
By default, the minimum target area is 100 pixels and there is no maximum sight range.
| camera | The camera to be simulated |
| photon::PhotonCameraSim::PhotonCameraSim | ( | PhotonCamera * | camera, |
| const SimCameraProperties & | props, | ||
| const frc::AprilTagFieldLayout & | tagLayout = frc::AprilTagFieldLayout::LoadField(frc::AprilTagField::kDefaultField) ) |
Constructs a handle for simulating PhotonCamera values.
Processing simulated targets through this class will change the associated PhotonCamera's results.
By default, the minimum target area is 100 pixels and there is no maximum sight range.
| camera | The camera to be simulated |
| prop | Properties of this camera such as FOV and FPS |
| tagLayout | The AprilTagFieldLayout used to solve for tag positions. |
| photon::PhotonCameraSim::PhotonCameraSim | ( | PhotonCamera * | camera, |
| const SimCameraProperties & | props, | ||
| double | minTargetAreaPercent, | ||
| units::meter_t | maxSightRange ) |
Constructs a handle for simulating PhotonCamera values.
Processing simulated targets through this class will change the associated PhotonCamera's results.
| camera | The camera to be simulated |
| prop | Properties of this camera such as FOV and FPS |
| minTargetAreaPercent | The minimum percentage (0 - 100) a detected target must take up of the camera's image to be processed. Match this with your contour filtering settings in the PhotonVision GUI. |
| maxSightRange | Maximum distance at which the target is illuminated to your camera. Note that minimum target area of the image is separate from this. |
| bool photon::PhotonCameraSim::CanSeeCorner | ( | const std::vector< cv::Point2f > & | points | ) |
Determines if all target points are inside the camera's image.
| points | The target's 2d image points |
| bool photon::PhotonCameraSim::CanSeeTargetPose | ( | const frc::Pose3d & | camPose, |
| const VisionTargetSim & | target ) |
Determines if this target's pose should be visible to the camera without considering its projected image points.
Does not account for image area.
| camPose | Camera's 3d pose |
| target | Vision target containing pose and shape |
| std::optional< uint64_t > photon::PhotonCameraSim::ConsumeNextEntryTime | ( | ) |
Determine if this camera should process a new frame based on performance metrics and the time since the last update.
This returns an Optional which is either empty if no update should occur or a Long of the timestamp in microseconds of when the frame which should be received by NT. If a timestamp is returned, the last frame update time becomes that timestamp.
|
inline |
Sets whether the processed video stream simulation is enabled.
| enabled | Whether or not to enable the processed video stream |
|
inline |
Sets whether a wireframe of the field is drawn to the raw video stream.
Note: This will dramatically increase loop times.
| enabled | Whether or not to enable the wireframe in the raw video stream |
|
inline |
Sets whether the raw video stream simulation is enabled.
Note: This may increase loop times.
| enabled | Whether or not to enable the raw video stream |
|
inline |
Returns the camera being simulated.
|
inline |
Returns the maximum distance at which the target is illuminated to your camera.
Note that minimum target area of the image is separate from this.
|
inline |
Returns the minimum percentage (0 - 100) a detected target must take up of the camera's image to be processed.
|
inline |
Returns the minimum number of pixels a detected target must take up in the camera's image to be processed.
|
inline |
|
inline |
| PhotonPipelineResult photon::PhotonCameraSim::Process | ( | units::second_t | latency, |
| const frc::Pose3d & | cameraPose, | ||
| std::vector< VisionTargetSim > | targets ) |
|
inline |
Sets the maximum distance at which the target is illuminated to your camera.
Note that minimum target area of the image is separate from this.
| rangeMeters | The distance |
|
inline |
Sets the minimum percentage (0 - 100) a detected target must take up of the camera's image to be processed.
| areaPercent | The percentage |
|
inline |
Sets the minimum number of pixels a detected target must take up in the camera's image to be processed.
| areaPx | The number of pixels |
|
inline |
Sets the resolution of the drawn wireframe if enabled.
Drawn line segments will be subdivided into smaller segments based on a threshold set by the resolution.
| resolution | Resolution as a fraction(0 - 1) of the video frame's diagonal length in pixels |
| void photon::PhotonCameraSim::SubmitProcessedFrame | ( | const PhotonPipelineResult & | result | ) |
| void photon::PhotonCameraSim::SubmitProcessedFrame | ( | const PhotonPipelineResult & | result, |
| uint64_t | ReceiveTimestamp ) |
| SimCameraProperties photon::PhotonCameraSim::prop |