Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
tagdetectutils Namespace Reference

Namespace containing functions to assist in tag detection. More...

Functions

void LoadDetectedTags (std::vector< arucotag::ArucoTag > &vDetectedArucoTags, std::vector< tensorflowtag::TensorflowTag > &vDetectedTensorflowTags, const std::vector< TagDetector * > &vTagDetectors, bool bUnique=false)
 Aggregates all detected tags from each provided tag detector for both OpenCV and Tensorflow detection.
 
bool FindArucoTagByID (int nID, arucotag::ArucoTag &stIdentifiedArucoTag, const std::vector< TagDetector * > &vTagDetectors)
 Find a tag in the rover's vision with the specified ID, using OpenCV detection.
 

Detailed Description

Namespace containing functions to assist in tag detection.

Author
Jason Pittman (jspen.nosp@m.cerp.nosp@m.ittma.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-10-07

Function Documentation

◆ LoadDetectedTags()

void tagdetectutils::LoadDetectedTags ( std::vector< arucotag::ArucoTag > &  vDetectedArucoTags,
std::vector< tensorflowtag::TensorflowTag > &  vDetectedTensorflowTags,
const std::vector< TagDetector * > &  vTagDetectors,
bool  bUnique = false 
)
inline

Aggregates all detected tags from each provided tag detector for both OpenCV and Tensorflow detection.

Note
When using bUnique, if you wish to prioritize one tag detector's detections over another put that tag detector earlier in the vTagDetectors.
Parameters
vDetectedArucoTags- Reference vector that will hold all of the aggregated detected Aruco tags.
vDetectedTensorflowTags- Reference vector that will hold all of the aggregated detected Tensorflow tags.
vTagDetectors- Vector of pointers to tag detectors that will be used to request their detected tags.
bUnique- Ensure vDetectedArucoTags is a unique list of tags (unique by ID).
Author
JSpencerPittman (jspen.nosp@m.cerp.nosp@m.ittma.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-07
54 {
55 // Number of tag detectors.
56 size_t siNumTagDetectors = vTagDetectors.size();
57
58 // Initialize vectors to store detected tags temporarily.
59 std::vector<std::vector<arucotag::ArucoTag>> vDetectedArucoTagBuffers(siNumTagDetectors);
60 std::vector<std::vector<tensorflowtag::TensorflowTag>> vDetectedTensorflowTagBuffers(siNumTagDetectors);
61
62 // Initialize vectors to store detected tags futures.
63 std::vector<std::future<bool>> vDetectedArucoTagsFuture;
64 std::vector<std::future<bool>> vDetectedTensorflowTagsFuture;
65
66 // Request tags from each detector.
67 for (size_t siIdx = 0; siIdx < siNumTagDetectors; ++siIdx)
68 {
69 // Check if this tag detector is ready.
70 if (vTagDetectors[siIdx]->GetIsReady())
71 {
72 // Request detected Aruco tags from detector.
73 vDetectedArucoTagsFuture.emplace_back(vTagDetectors[siIdx]->RequestDetectedArucoTags(vDetectedArucoTagBuffers[siIdx]));
74 // Request detected Tensorflow tags from detector.
75 vDetectedTensorflowTagsFuture.emplace_back(vTagDetectors[siIdx]->RequestDetectedTensorflowTags(vDetectedTensorflowTagBuffers[siIdx]));
76 }
77 }
78
79 // Ensure all requests have been fulfilled.
80 // Then transfer tags from the buffer to vDetectedArucoTags and vDetectedTensorflowTags for the user to access.
81 for (size_t siIdx = 0; siIdx < vDetectedArucoTagsFuture.size(); ++siIdx)
82 {
83 // Wait for the request to be fulfilled.
84 vDetectedArucoTagsFuture[siIdx].get();
85 vDetectedTensorflowTagsFuture[siIdx].get();
86
87 // Loop through the detected Aruco tags and add them to the vDetectedArucoTags vector.
88 for (const arucotag::ArucoTag& tTag : vDetectedArucoTagBuffers[siIdx])
89 {
90 vDetectedArucoTags.emplace_back(tTag);
91 }
92
93 // Loop through the detected Tensorflow tags and add them to the vDetectedTensorflowTags vector.
94 for (const tensorflowtag::TensorflowTag& tTag : vDetectedTensorflowTagBuffers[siIdx])
95 {
96 vDetectedTensorflowTags.emplace_back(tTag);
97 }
98 }
99
100 if (bUnique)
101 {
102 // Remove all Aruco tags with a duplicate ID.
103 std::set<int> setIds;
104 size_t szIdx = 0;
105 while (szIdx < vDetectedArucoTags.size())
106 {
107 // Tag was detected by another tag detector.
108 if (setIds.count(vDetectedArucoTags[szIdx].nID))
109 {
110 vDetectedArucoTags.erase(vDetectedArucoTags.begin() + szIdx);
111 }
112 else
113 {
114 setIds.insert(vDetectedArucoTags[szIdx].nID);
115 ++szIdx;
116 }
117 }
118 }
119 }
Represents a single ArUco tag. Stores all information about a specific tag detection.
Definition ArucoDetection.hpp:44
Represents a single ArUco tag. Stores all information about a specific tag detection.
Definition TensorflowTagDetection.hpp:43
Here is the caller graph for this function:

◆ FindArucoTagByID()

bool tagdetectutils::FindArucoTagByID ( int  nID,
arucotag::ArucoTag stIdentifiedArucoTag,
const std::vector< TagDetector * > &  vTagDetectors 
)
inline

Find a tag in the rover's vision with the specified ID, using OpenCV detection.

Parameters
nID- The ID of the tag being looked for.
stIdentifiedArucoTag- Reference to save the identified tag.
vTagDetectors- Vector of pointers to tag detectors that will be used to request their detected tags.
Returns
true - The tag was found.
false - The tag was not found.
Author
JSpencerPittman (jspen.nosp@m.cerp.nosp@m.ittma.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-03-08
134 {
135 // Load all detected tags in the rover's vision.
136 std::vector<arucotag::ArucoTag> vDetectedArucoTags;
137 std::vector<tensorflowtag::TensorflowTag> vDetectedTensorflowTags;
138 LoadDetectedTags(vDetectedArucoTags, vDetectedTensorflowTags, vTagDetectors, true);
139
140 // Find the tag with the corresponding id.
141 for (const arucotag::ArucoTag& tTag : vDetectedArucoTags)
142 {
143 // Is this the tag being searched for.
144 if (tTag.nID == nID)
145 {
146 stIdentifiedArucoTag = tTag;
147 return true;
148 }
149 }
150
151 // The tag was not found by the tag detectors.
152 return false;
153 }
void LoadDetectedTags(std::vector< arucotag::ArucoTag > &vDetectedArucoTags, std::vector< tensorflowtag::TensorflowTag > &vDetectedTensorflowTags, const std::vector< TagDetector * > &vTagDetectors, bool bUnique=false)
Aggregates all detected tags from each provided tag detector for both OpenCV and Tensorflow detection...
Definition TagDetectionUtilty.hpp:50
Here is the call graph for this function:
Here is the caller graph for this function: