40 inline void LoadDetectedTags(std::vector<tagdetectutils::ArucoTag>& vDetectedArucoTags,
const std::vector<std::shared_ptr<TagDetector>>& vTagDetectors)
43 size_t siNumTagDetectors = vTagDetectors.size();
46 std::vector<std::vector<tagdetectutils::ArucoTag>> vDetectedArucoTagBuffers(siNumTagDetectors);
49 std::vector<std::future<bool>> vDetectedArucoTagsFuture;
52 for (
size_t siIdx = 0; siIdx < siNumTagDetectors; ++siIdx)
55 if (vTagDetectors[siIdx]->GetIsReady())
58 vDetectedArucoTagsFuture.emplace_back(vTagDetectors[siIdx]->RequestDetectedArucoTags(vDetectedArucoTagBuffers[siIdx]));
64 for (
size_t siIdx = 0; siIdx < vDetectedArucoTagsFuture.size(); ++siIdx)
67 vDetectedArucoTagsFuture[siIdx].get();
72 vDetectedArucoTags.emplace_back(tTag);
94 const int nTargetTagID =
static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::ANY))
97 std::vector<tagdetectutils::ArucoTag> vDetectedArucoTags;
100 std::string szIdentifiedTags =
"";
103 std::chrono::system_clock::time_point tmCurrentTime = std::chrono::system_clock::now();
111 double dTagTotalAge = std::fabs(std::chrono::duration_cast<std::chrono::milliseconds>(tmCurrentTime - stCandidate.tmCreation).count() / 1000.0);
113 double dArea = stCandidate.pBoundingBox->area();
115 double dAreaPercentage = (dArea / (stCandidate.cvImageResolution.width * stCandidate.cvImageResolution.height)) * 100.0;
118 if (stCandidate.dStraightLineDistance <= 0.0)
124 if (stCandidate.eDetectionMethod == tagdetectutils::TagDetectionMethod::eOpenCV)
127 szIdentifiedTags +=
"\tArUco ID: " + std::to_string(stCandidate.nID) +
" Tag Age: " + std::to_string(dTagTotalAge) +
128 "s Tag Screen Percentage: " + std::to_string(dAreaPercentage) +
"%\n";
130 if (stCandidate.nID == nTargetTagID ||
static_cast<int>(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::ANY))
133 if (dAreaPercentage < constants::BBOX_MIN_SCREEN_PERCENTAGE || dTagTotalAge < constants::BBOX_MIN_LIFETIME_THRESHOLD)
139 if (dArea > stArucoBestTag.pBoundingBox->area())
142 stArucoBestTag = stCandidate;
146 else if (stCandidate.eDetectionMethod == tagdetectutils::TagDetectionMethod::eTorch)
149 szIdentifiedTags +=
"\tTorch Class: " + stCandidate.szClassName +
" Tag Age: " + std::to_string(dTagTotalAge) +
150 "s Tag Screen Percentage: " + std::to_string(dAreaPercentage) +
"%\n";
152 if (dAreaPercentage < constants::BBOX_MIN_SCREEN_PERCENTAGE || dTagTotalAge < constants::BBOX_MIN_LIFETIME_THRESHOLD)
158 if (dArea > stTorchBestTag.pBoundingBox->area())
161 stTorchBestTag = stCandidate;
167 if (stArucoBestTag.nID != -1 || stTorchBestTag.dConfidence != 0.0)
170 LOG_DEBUG(logging::g_qSharedLogger,
"TagDetectionChecker: Identified tags:\n{}", szIdentifiedTags);
174 stArucoTarget = stArucoBestTag;
175 stTorchTarget = stTorchBestTag;
177 return static_cast<int>(vDetectedArucoTags.size());
int IdentifyTargetMarker(const std::vector< std::shared_ptr< TagDetector > > &vTagDetectors, tagdetectutils::ArucoTag &stArucoTarget, tagdetectutils::ArucoTag &stTorchTarget, const int nTargetTagID=static_cast< int >(manifest::Autonomy::AUTONOMYWAYPOINTTYPES::ANY))
Identify a target marker in the rover's vision, using OpenCV detection.
Definition TagDetectionChecker.hpp:91
void LoadDetectedTags(std::vector< tagdetectutils::ArucoTag > &vDetectedArucoTags, const std::vector< std::shared_ptr< TagDetector > > &vTagDetectors)
Aggregates all detected tags from each provided tag detector for both OpenCV and Tensorflow detection...
Definition TagDetectionChecker.hpp:40
Represents a single ArUco tag. Combines attributes from TorchTag, TensorflowTag, and the original Aru...
Definition TagDetectionUtilty.hpp:59