PhotonVision C++ v2026.2.2
Loading...
Searching...
No Matches
photon::VideoSimUtil Namespace Reference

Functions

static cv::Mat Get36h11TagImage (int id)
 
static std::unordered_map< int, cv::Mat > LoadAprilTagImages ()
 
static std::vector< cv::Point2f > GetImageCorners (const cv::Size &size)
 Gets the points representing the corners of this image.
 
static std::vector< cv::Point2f > Get36h11MarkerPts (int scale)
 Gets the points representing the marker(black square) corners.
 
static std::vector< cv::Point2f > Get36h11MarkerPts ()
 Gets the points representing the marker(black square) corners.
 
static void UpdateVideoProp (cs::CvSource &video, const SimCameraProperties &prop)
 Updates the properties of this cs::CvSource video stream with the given camera properties.
 
static void Warp165h5TagImage (int tagId, const std::vector< cv::Point2f > &dstPoints, bool antialiasing, cv::Mat &destination)
 Warps the image of a specific 36h11 AprilTag onto the destination image at the given points.
 
static double GetScaledThickness (double thickness480p, const cv::Mat &destination)
 Given a line thickness in a 640x480 image, try to scale to the given destination image resolution.
 
static void DrawInscribedEllipse (const std::vector< cv::Point2f > &dstPoints, const cv::Scalar &color, cv::Mat &destination)
 Draw a filled ellipse in the destination image.
 
static void DrawPoly (const std::vector< cv::Point2f > &dstPoints, int thickness, const cv::Scalar &color, bool isClosed, cv::Mat &destination)
 
static void DrawTagDetection (int id, const std::vector< cv::Point2f > &dstPoints, cv::Mat &destination)
 Draws a contour around the given points and text of the id onto the destination image.
 
static std::vector< std::vector< frc::Translation3d > > GetFieldWallLines ()
 The translations used to draw the field side walls and driver station walls.
 
static std::vector< std::vector< frc::Translation3d > > GetFieldFloorLines (int subdivisions)
 The translations used to draw the field floor subdivisions (not the floor outline).
 
static std::vector< std::vector< cv::Point2f > > PolyFrom3dLines (const RotTrlTransform3d &camRt, const SimCameraProperties &prop, const std::vector< frc::Translation3d > &trls, double resolution, bool isClosed, cv::Mat &destination)
 Convert 3D lines represented by the given series of translations into a polygon(s) in the camera's image.
 
static void DrawFieldWireFrame (const RotTrlTransform3d &camRt, const SimCameraProperties &prop, double resolution, double wallThickness, const cv::Scalar &wallColor, int floorSubdivisions, double floorThickness, const cv::Scalar &floorColor, cv::Mat &destination)
 Draw a wireframe of the field to the given image.
 

Variables

static constexpr int kNumTags36h11 = 40
 
static constexpr units::meter_t fieldLength {16.54175_m}
 
static constexpr units::meter_t fieldWidth {8.0137_m}
 
static const std::unordered_map< int, cv::Mat > kTag36h11Images
 
static const std::vector< cv::Point2f > kTag36h11MarkPts = Get36h11MarkerPts()
 

Function Documentation

◆ DrawFieldWireFrame()

static void photon::VideoSimUtil::DrawFieldWireFrame ( const RotTrlTransform3d & camRt,
const SimCameraProperties & prop,
double resolution,
double wallThickness,
const cv::Scalar & wallColor,
int floorSubdivisions,
double floorThickness,
const cv::Scalar & floorColor,
cv::Mat & destination )
static

Draw a wireframe of the field to the given image.

Parameters
camRtThe change in basis from world coordinates to camera coordinates. See RotTrlTransform3d#makeRelativeTo(frc::Pose3d).
propThe simulated camera's properties.
resolutionResolution as a fraction(0 - 1) of the video frame's diagonal length in pixels. Line segments will be subdivided if they exceed this resolution.
wallThicknessThickness of the lines used for drawing the field walls in pixels. This is scaled by #getScaledThickness(double, cv::Mat).
wallColorColor of the lines used for drawing the field walls.
floorSubdivisionsA NxN "grid" is created from the floor where this parameter is N, which defines the floor lines.
floorThicknessThickness of the lines used for drawing the field floor grid in pixels. This is scaled by #getScaledThickness(double, cv::Mat).
floorColorColor of the lines used for drawing the field floor grid.
destinationThe destination image to draw to.

◆ DrawInscribedEllipse()

static void photon::VideoSimUtil::DrawInscribedEllipse ( const std::vector< cv::Point2f > & dstPoints,
const cv::Scalar & color,
cv::Mat & destination )
static

Draw a filled ellipse in the destination image.

Parameters
dstPointsThe points in the destination image representing the rectangle in which the ellipse is inscribed.
colorThe color of the ellipse. This is a scalar with BGR values (0-255)
destinationThe destination image to draw onto. The image should be in the BGR color space.

◆ DrawPoly()

static void photon::VideoSimUtil::DrawPoly ( const std::vector< cv::Point2f > & dstPoints,
int thickness,
const cv::Scalar & color,
bool isClosed,
cv::Mat & destination )
static

◆ DrawTagDetection()

static void photon::VideoSimUtil::DrawTagDetection ( int id,
const std::vector< cv::Point2f > & dstPoints,
cv::Mat & destination )
static

Draws a contour around the given points and text of the id onto the destination image.

Parameters
idFiducial ID number to draw
dstPointsPoints representing the four corners of the tag marker(black square) in the destination image.
destinationThe destination image to draw onto. The image should be in the BGR color space.

◆ Get36h11MarkerPts() [1/2]

static std::vector< cv::Point2f > photon::VideoSimUtil::Get36h11MarkerPts ( )
static

Gets the points representing the marker(black square) corners.

Returns
The points

◆ Get36h11MarkerPts() [2/2]

static std::vector< cv::Point2f > photon::VideoSimUtil::Get36h11MarkerPts ( int scale)
static

Gets the points representing the marker(black square) corners.

Parameters
scaleThe scale of the tag image (10*scale x 10*scale image)
Returns
The points

◆ Get36h11TagImage()

static cv::Mat photon::VideoSimUtil::Get36h11TagImage ( int id)
static

◆ GetFieldFloorLines()

static std::vector< std::vector< frc::Translation3d > > photon::VideoSimUtil::GetFieldFloorLines ( int subdivisions)
static

The translations used to draw the field floor subdivisions (not the floor outline).

It is a vector of vectors because the translations are not all connected.

Parameters
subdivisionsHow many "subdivisions" along the width/length of the floor. E.g. 3 subdivisions would mean 2 lines along the length and 2 lines along the width creating a 3x3 "grid".

◆ GetFieldWallLines()

static std::vector< std::vector< frc::Translation3d > > photon::VideoSimUtil::GetFieldWallLines ( )
static

The translations used to draw the field side walls and driver station walls.

It is a vector of vectors because the translations are not all connected.

◆ GetImageCorners()

static std::vector< cv::Point2f > photon::VideoSimUtil::GetImageCorners ( const cv::Size & size)
static

Gets the points representing the corners of this image.

Because image pixels are accessed through a cv::Mat, the point (0,0) actually represents the center of the top-left pixel and not the actual top-left corner.

Order of corners returned is: [BL, BR, TR, TL]

Parameters
sizeSize of image
Returns
The corners

◆ GetScaledThickness()

static double photon::VideoSimUtil::GetScaledThickness ( double thickness480p,
const cv::Mat & destination )
static

Given a line thickness in a 640x480 image, try to scale to the given destination image resolution.

Parameters
thickness480pA hypothetical line thickness in a 640x480 image
destinationThe destination image to scale to
Returns
Scaled thickness which cannot be less than 1

◆ LoadAprilTagImages()

static std::unordered_map< int, cv::Mat > photon::VideoSimUtil::LoadAprilTagImages ( )
static

◆ PolyFrom3dLines()

static std::vector< std::vector< cv::Point2f > > photon::VideoSimUtil::PolyFrom3dLines ( const RotTrlTransform3d & camRt,
const SimCameraProperties & prop,
const std::vector< frc::Translation3d > & trls,
double resolution,
bool isClosed,
cv::Mat & destination )
static

Convert 3D lines represented by the given series of translations into a polygon(s) in the camera's image.

Parameters
camRtThe change in basis from world coordinates to camera coordinates. See RotTrlTransform3d#makeRelativeTo(Pose3d).
propThe simulated camera's properties.
trlsA sequential series of translations defining the polygon to be drawn.
resolutionResolution as a fraction(0 - 1) of the video frame's diagonal length in pixels. Line segments will be subdivided if they exceed this resolution.
isClosedIf the final translation should also draw a line to the first translation.
destinationThe destination image that is being drawn to.
Returns
A list of polygons(which are an array of points)

◆ UpdateVideoProp()

static void photon::VideoSimUtil::UpdateVideoProp ( cs::CvSource & video,
const SimCameraProperties & prop )
static

Updates the properties of this cs::CvSource video stream with the given camera properties.

◆ Warp165h5TagImage()

static void photon::VideoSimUtil::Warp165h5TagImage ( int tagId,
const std::vector< cv::Point2f > & dstPoints,
bool antialiasing,
cv::Mat & destination )
static

Warps the image of a specific 36h11 AprilTag onto the destination image at the given points.

Parameters
tagIdThe id of the specific tag to warp onto the destination image
dstPointsPoints(4) in destination image where the tag marker(black square) corners should be warped onto.
antialiasingIf antialiasing should be performed by automatically supersampling/interpolating the warped image. This should be used if better stream quality is desired or target detection is being done on the stream, but can hurt performance.
destinationThe destination image to place the warped tag image onto.

Variable Documentation

◆ fieldLength

units::meter_t photon::VideoSimUtil::fieldLength {16.54175_m}
staticconstexpr

◆ fieldWidth

units::meter_t photon::VideoSimUtil::fieldWidth {8.0137_m}
staticconstexpr

◆ kNumTags36h11

int photon::VideoSimUtil::kNumTags36h11 = 40
staticconstexpr

◆ kTag36h11Images

const std::unordered_map<int, cv::Mat> photon::VideoSimUtil::kTag36h11Images
static
Initial value:
=
static std::unordered_map< int, cv::Mat > LoadAprilTagImages()
Definition VideoSimUtil.h:69

◆ kTag36h11MarkPts

const std::vector<cv::Point2f> photon::VideoSimUtil::kTag36h11MarkPts = Get36h11MarkerPts()
static