PhotonVision C++ v2027.0.0-alpha-2
Loading...
Searching...
No Matches
PhotonTrackedTarget.h
Go to the documentation of this file.
1/*
2 * Copyright (C) Photon Vision.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <utility>
21#include <vector>
22
23#include <wpi/math/geometry/Transform3d.hpp>
24
26
27namespace photon {
28/**
29 * Represents a tracked target within a pipeline.
30 */
33
34 public:
36
37 explicit PhotonTrackedTarget(Base&& data) : Base(data) {}
38
39 template <typename... Args>
40 explicit PhotonTrackedTarget(Args&&... args)
41 : Base{std::forward<Args>(args)...} {}
42
43 /**
44 * Returns the target yaw (positive-left).
45 * @return The target yaw.
46 */
47 double GetYaw() const { return yaw; }
48
49 /**
50 * Returns the target pitch (positive-up)
51 * @return The target pitch.
52 */
53 double GetPitch() const { return pitch; }
54
55 /**
56 * Returns the target area (0-100).
57 * @return The target area.
58 */
59 double GetArea() const { return area; }
60
61 /**
62 * Returns the target skew (counter-clockwise positive).
63 * @return The target skew.
64 */
65 double GetSkew() const { return skew; }
66
67 /**
68 * Get the Fiducial ID of the target currently being tracked,
69 * or -1 if not set.
70 */
71 int GetFiducialId() const { return fiducialId; }
72
73 /**
74 * Get the Fiducial ID of the target currently being tracked,
75 * or -1 if not set.
76 */
77 int GetDetectedObjectClassID() const { return objDetectId; }
78
79 /**
80 * Get the object detection confidence, or -1 if not set. This will be between
81 * 0 and 1, with 1 indicating most confidence, and 0 least.
82 */
84
85 /**
86 * Return a list of the 4 corners in image space (origin top left, x right, y
87 * down), in no particular order, of the minimum area bounding rectangle of
88 * this target
89 */
90 const std::vector<photon::TargetCorner>& GetMinAreaRectCorners() const {
91 return minAreaRectCorners;
92 }
93
94 /**
95 * Return a list of the n corners in image space (origin top left, x right, y
96 * down), in no particular order, detected for this target.
97 * For fiducials, the order is known and is always counter-clock wise around
98 * the tag, like so
99 *
100 * -> +X 3 ----- 2
101 * | | |
102 * V + Y | |
103 * 0 ----- 1
104 */
105 const std::vector<photon::TargetCorner>& GetDetectedCorners() const {
106 return detectedCorners;
107 }
108
109 /**
110 * Get the ratio of best:alternate pose reprojection errors, called ambiguity.
111 * This is between 0 and 1 (0 being no ambiguity, and 1 meaning both have the
112 * same reprojection error). Numbers above 0.2 are likely to be ambiguous. -1
113 * if invalid.
114 */
115 double GetPoseAmbiguity() const { return poseAmbiguity; }
116
117 /**
118 * Get the transform that maps camera space (X = forward, Y = left, Z = up) to
119 * object/fiducial tag space (X forward, Y left, Z up) with the lowest
120 * reprojection error. The ratio between this and the alternate target's
121 * reprojection error is the ambiguity, which is between 0 and 1.
122 * @return The pose of the target relative to the robot.
123 */
124 wpi::math::Transform3d GetBestCameraToTarget() const {
125 return bestCameraToTarget;
126 }
127
128 /**
129 * Get the transform that maps camera space (X = forward, Y = left, Z = up) to
130 * object/fiducial tag space (X forward, Y left, Z up) with the highest
131 * reprojection error
132 */
133 wpi::math::Transform3d GetAlternateCameraToTarget() const {
134 return altCameraToTarget;
135 }
136
137 friend bool operator==(PhotonTrackedTarget const&,
138 PhotonTrackedTarget const&) = default;
139};
140} // namespace photon
141
Represents a tracked target within a pipeline.
Definition PhotonTrackedTarget.h:31
int GetFiducialId() const
Get the Fiducial ID of the target currently being tracked, or -1 if not set.
Definition PhotonTrackedTarget.h:71
const std::vector< photon::TargetCorner > & GetMinAreaRectCorners() const
Return a list of the 4 corners in image space (origin top left, x right, y down), in no particular or...
Definition PhotonTrackedTarget.h:90
PhotonTrackedTarget(Args &&... args)
Definition PhotonTrackedTarget.h:40
PhotonTrackedTarget(Base &&data)
Definition PhotonTrackedTarget.h:37
wpi::math::Transform3d GetBestCameraToTarget() const
Get the transform that maps camera space (X = forward, Y = left, Z = up) to object/fiducial tag space...
Definition PhotonTrackedTarget.h:124
double GetArea() const
Returns the target area (0-100).
Definition PhotonTrackedTarget.h:59
double GetSkew() const
Returns the target skew (counter-clockwise positive).
Definition PhotonTrackedTarget.h:65
double GetPoseAmbiguity() const
Get the ratio of best:alternate pose reprojection errors, called ambiguity.
Definition PhotonTrackedTarget.h:115
float GetDetectedObjectConfidence() const
Get the object detection confidence, or -1 if not set.
Definition PhotonTrackedTarget.h:83
const std::vector< photon::TargetCorner > & GetDetectedCorners() const
Return a list of the n corners in image space (origin top left, x right, y down), in no particular or...
Definition PhotonTrackedTarget.h:105
double GetPitch() const
Returns the target pitch (positive-up)
Definition PhotonTrackedTarget.h:53
wpi::math::Transform3d GetAlternateCameraToTarget() const
Get the transform that maps camera space (X = forward, Y = left, Z = up) to object/fiducial tag space...
Definition PhotonTrackedTarget.h:133
friend bool operator==(PhotonTrackedTarget const &, PhotonTrackedTarget const &)=default
int GetDetectedObjectClassID() const
Get the Fiducial ID of the target currently being tracked, or -1 if not set.
Definition PhotonTrackedTarget.h:77
double GetYaw() const
Returns the target yaw (positive-left).
Definition PhotonTrackedTarget.h:47
Definition VisionEstimation.h:30
Definition PhotonTrackedTargetStruct.h:38
wpi::math::Transform3d altCameraToTarget
Definition PhotonTrackedTargetStruct.h:47
int32_t objDetectId
Definition PhotonTrackedTargetStruct.h:44
std::vector< photon::TargetCorner > minAreaRectCorners
Definition PhotonTrackedTargetStruct.h:49
double poseAmbiguity
Definition PhotonTrackedTargetStruct.h:48
std::vector< photon::TargetCorner > detectedCorners
Definition PhotonTrackedTargetStruct.h:50
double pitch
Definition PhotonTrackedTargetStruct.h:40
int32_t fiducialId
Definition PhotonTrackedTargetStruct.h:43
double yaw
Definition PhotonTrackedTargetStruct.h:39
wpi::math::Transform3d bestCameraToTarget
Definition PhotonTrackedTargetStruct.h:46
double area
Definition PhotonTrackedTargetStruct.h:41
float objDetectConf
Definition PhotonTrackedTargetStruct.h:45
double skew
Definition PhotonTrackedTargetStruct.h:42