15#include "../../interfaces/BasicCamera.hpp"
16#include "../../interfaces/ZEDCamera.hpp"
17#include "../../util/vision/BoundingBoxTracking.h"
18#include "../../util/vision/TagDetectionUtilty.hpp"
19#include "../../util/vision/YOLOModel.hpp"
23#include <shared_mutex>
52 const int nArucoCornerRefinementMaxIterations = 30,
54 const int nArucoMarkerBorderBits = 1,
55 const bool bArucoDetectInvertedMarkers =
false,
56 const bool bUseAruco3Detection =
false,
57 const bool bEnableTracking =
false,
58 const int nDetectorMaxFPS = 30,
59 const bool bEnableRecordingFlag =
false,
60 const int nNumDetectedTagsRetrievalThreads = 5,
61 const bool bUsingGpuMats =
false);
63 const int nArucoCornerRefinementMaxIterations = 30,
65 const int nArucoMarkerBorderBits = 1,
66 const bool bArucoDetectInvertedMarkers =
false,
67 const bool bUseAruco3Detection =
false,
68 const bool bEnableTracking =
false,
69 const int nDetectorMaxFPS = 30,
70 const bool bEnableRecordingFlag =
false,
71 const int nNumDetectedTagsRetrievalThreads = 5,
72 const bool bUsingGpuMats =
false);
78 yolomodel::pytorch::PyTorchInterpreter::HardwareDevices eDevice = yolomodel::pytorch::PyTorchInterpreter::HardwareDevices::eCUDA);
84 void EnableTorchDetection(
const float fMinObjectConfidence = 0.4f,
const float fNMSThreshold = 0.6f);
113 std::shared_ptr<Camera<cv::Mat>> m_pCamera;
117 std::shared_ptr<yolomodel::pytorch::PyTorchInterpreter> m_pTorchDetector;
118 std::atomic<float> m_fTorchMinObjectConfidence;
119 std::atomic<float> m_fTorchNMSThreshold;
120 std::atomic_bool m_bTorchInitialized;
121 std::atomic_bool m_bTorchEnabled;
122 std::shared_ptr<tracking::MultiTracker> m_pMultiTracker;
123 bool m_bUsingZedCamera;
124 bool m_bUsingGpuMats;
125 bool m_bCameraIsOpened;
126 bool m_bEnableTracking;
127 int m_nNumDetectedTagsRetrievalThreads;
128 std::string m_szCameraName;
129 std::atomic_bool m_bEnableRecordingFlag;
133 std::vector<tagdetectutils::ArucoTag> m_vNewlyDetectedTags;
134 std::vector<tagdetectutils::ArucoTag> m_vDetectedArucoTags;
144 cv::Mat m_cvLastGoodDetectionOverlayFrame;
150 std::queue<containers::FrameFetchContainer<cv::Mat>> m_qDetectionOverlayFramesCopySchedule;
151 std::queue<containers::FrameFetchContainer<cv::Mat>> m_qLastGoodDetectionOverlayFramesCopySchedule;
152 std::queue<containers::DataFetchContainer<std::vector<tagdetectutils::ArucoTag>>> m_qDetectedArucoTagCopySchedule;
153 std::shared_mutex m_muPoolScheduleMutex;
154 std::shared_mutex m_muDetectionOverlayCopyMutex;
155 std::shared_mutex m_muLastGoodDetectionOverlayCopyMutex;
156 std::shared_mutex m_muArucoDataCopyMutex;
Interface class used to easily multithread a child class.
Definition AutonomyThread.hpp:40
Run's Aruco detection & camera pose estimation in a multithreading environment. Given a camera,...
Definition TagDetector.h:46
bool GetEnableRecordingFlag() const
Accessor for the Enable Recording Flag private member.
Definition TagDetector.cpp:737
int GetDetectorMaxFPS() const
Accessor for the desired max FPS for this detector.
Definition TagDetector.cpp:722
void SetDetectorMaxFPS(const int nRecordingFPS)
Mutator for the desired max FPS for this detector.
Definition TagDetector.cpp:653
std::future< bool > RequestDetectionOverlayFrame(cv::Mat &cvFrame)
Request a copy of a frame containing the tag detection overlays from the aruco and torch library.
Definition TagDetector.cpp:496
void SetEnableRecordingFlag(const bool bEnableRecordingFlag)
Mutator for the Enable Recording Flag private member.
Definition TagDetector.cpp:667
void EnableTorchDetection(const float fMinObjectConfidence=0.4f, const float fNMSThreshold=0.6f)
Turn on torch detection with given parameters.
Definition TagDetector.cpp:611
std::future< bool > RequestDetectedArucoTags(std::vector< tagdetectutils::ArucoTag > &vArucoTags)
Request the most up to date vector of detected tags from OpenCV's Aruco algorithm.
Definition TagDetector.cpp:550
~TagDetector()
Destroy the Tag Detector:: Tag Detector object.
Definition TagDetector.cpp:157
bool InitTorchDetection(const std::string &szModelPath, yolomodel::pytorch::PyTorchInterpreter::HardwareDevices eDevice=yolomodel::pytorch::PyTorchInterpreter::HardwareDevices::eCUDA)
Attempt to open the next available Torch hardware and load model at the given path onto the device.
Definition TagDetector.cpp:578
std::string GetCameraName()
Accessor for the camera name or path that this TagDetector is tied to.
Definition TagDetector.cpp:750
cv::Size GetProcessFrameResolution() const
Accessor for the resolution of the process image used for tag detection.
Definition TagDetector.cpp:763
void UpdateDetectedTags(std::vector< tagdetectutils::ArucoTag > &vNewlyDetectedTags)
Updates the detected torch tags including tracking the detected tags over time and removing tags that...
Definition TagDetector.cpp:787
std::future< bool > RequestLastGoodOverlayFrame(cv::Mat &cvFrame)
Request a copy of a frame containing the last good tag detection overlays from the aruco and torch li...
Definition TagDetector.cpp:523
void DisableTorchDetection()
Set flag to stop tag detection with the torch model.
Definition TagDetector.cpp:639
void ThreadedContinuousCode() override
This code will run continuously in a separate thread. New frames from the given camera are grabbed an...
Definition TagDetector.cpp:176
void PooledLinearCode() override
This method holds the code that is ran in the thread pool started by the ThreadedLinearCode() method....
Definition TagDetector.cpp:408
bool GetIsReady()
Accessor for the status of this TagDetector.
Definition TagDetector.cpp:681
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:708