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
TagDetectionHandler Class Reference

The TagDetectionHandler class is responsible for managing all of the different detectors that Autonomy_Software uses for AR tag detection. Whether it be for detection using OpenCV's ArUco or detection using a custom tensorflow model, the detectors are created and stored here. More...

#include <TagDetectionHandler.h>

Collaboration diagram for TagDetectionHandler:

Public Types

enum class  TagDetectors {
  TAGDETECTOR_START , eHeadMainCam , eFrameLeftCam , eFrameRightCam ,
  TAGDETECTOR_END
}
 

Public Member Functions

 TagDetectionHandler ()
 Construct a new TagDetectionHandler::TagDetectionHandler object.
 
 ~TagDetectionHandler ()
 Destroy the TagDetectionHandler::TagDetectionHandler object.
 
void StartAllDetectors ()
 Signals all detectors to start their threads.
 
void StartRecording ()
 Signal the RecordingHandler to start recording video feeds from the TagDetectionHandler.
 
void StopAllDetectors ()
 Signals all detectors to stop their threads.
 
void StopRecording ()
 Signal the RecordingHandler to stop recording video feeds from the TagDetectionHandler.
 
TagDetectorGetTagDetector (TagDetectors eDetectorName)
 Accessor for TagDetector detectors.
 

Private Attributes

TagDetectorm_pTagDetectorMainCam
 
TagDetectorm_pTagDetectorLeftCam
 
TagDetectorm_pTagDetectorRightCam
 
RecordingHandlerm_pRecordingHandler
 

Detailed Description

The TagDetectionHandler class is responsible for managing all of the different detectors that Autonomy_Software uses for AR tag detection. Whether it be for detection using OpenCV's ArUco or detection using a custom tensorflow model, the detectors are created and stored here.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07

Member Enumeration Documentation

◆ TagDetectors

enum class TagDetectionHandler::TagDetectors
strong
45 {
46 TAGDETECTOR_START,
47 eHeadMainCam,
48 eFrameLeftCam,
49 eFrameRightCam,
50 TAGDETECTOR_END
51 };

Constructor & Destructor Documentation

◆ TagDetectionHandler()

TagDetectionHandler::TagDetectionHandler ( )

Construct a new TagDetectionHandler::TagDetectionHandler object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07
23{
24 // Initialize detector for main ZEDCam.
25 m_pTagDetectorMainCam = new TagDetector(globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eHeadMainCam),
26 constants::TAGDETECT_MAINCAM_CORNER_REFINE_MAX_ITER,
27 constants::TAGDETECT_MAINCAM_CORNER_REFINE_METHOD,
28 constants::TAGDETECT_MAINCAM_MARKER_BORDER_BITS,
29 constants::TAGDETECT_MAINCAM_DETECT_INVERTED_MARKER,
30 constants::TAGDETECT_MAINCAM_USE_ARUCO3_DETECTION,
31 constants::TAGDETECT_MAINCAM_MAX_FPS,
32 constants::TAGDETECT_MAINCAM_ENABLE_RECORDING,
33 constants::TAGDETECT_MAINCAM_DATA_RETRIEVAL_THREADS,
34 constants::ZED_MAINCAM_USE_GPU_MAT);
35
36 // Initialize detector for left aruco ZEDCam.
37 m_pTagDetectorLeftCam = new TagDetector(globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eFrameLeftCam),
38 constants::TAGDETECT_LEFTCAM_CORNER_REFINE_MAX_ITER,
39 constants::TAGDETECT_LEFTCAM_CORNER_REFINE_METHOD,
40 constants::TAGDETECT_LEFTCAM_MARKER_BORDER_BITS,
41 constants::TAGDETECT_LEFTCAM_DETECT_INVERTED_MARKER,
42 constants::TAGDETECT_LEFTCAM_USE_ARUCO3_DETECTION,
43 constants::TAGDETECT_LEFTCAM_MAX_FPS,
44 constants::TAGDETECT_LEFTCAM_ENABLE_RECORDING,
45 constants::TAGDETECT_LEFTCAM_DATA_RETRIEVAL_THREADS,
46 false);
47
48 // Initialize detector for right aruco ZEDCam.
49 m_pTagDetectorRightCam = new TagDetector(globals::g_pCameraHandler->GetZED(CameraHandler::ZEDCamName::eFrameRightCam),
50 constants::TAGDETECT_RIGHTCAM_CORNER_REFINE_MAX_ITER,
51 constants::TAGDETECT_RIGHTCAM_CORNER_REFINE_METHOD,
52 constants::TAGDETECT_RIGHTCAM_MARKER_BORDER_BITS,
53 constants::TAGDETECT_RIGHTCAM_DETECT_INVERTED_MARKER,
54 constants::TAGDETECT_RIGHTCAM_USE_ARUCO3_DETECTION,
55 constants::TAGDETECT_RIGHTCAM_MAX_FPS,
56 constants::TAGDETECT_RIGHTCAM_ENABLE_RECORDING,
57 constants::TAGDETECT_RIGHTCAM_DATA_RETRIEVAL_THREADS,
58 false);
59
60 // Check if tensorflow detection is enabled for main ZEDCam.
61 if (constants::TAGDETECT_MAINCAM_ENABLE_DNN)
62 {
63 // Attempt to init tensorflow detection.
64 if (m_pTagDetectorMainCam->InitTensorflowDetection(constants::TAGDETECT_MAINCAM_MODEL_PATH))
65 {
66 // Set tensorflow detection enabled.
67 m_pTagDetectorMainCam->EnableTensorflowDetection(constants::TAGDETECT_MAINCAM_DNN_CONFIDENCE, constants::TAGDETECT_MAINCAM_DNN_NMS_THRESH);
68 }
69 }
70 // Check if tensorflow detection is enabled for left BasicCam.
71 if (constants::TAGDETECT_LEFTCAM_ENABLE_DNN)
72 {
73 // Attempt to init tensorflow detection.
74 if (m_pTagDetectorLeftCam->InitTensorflowDetection(constants::TAGDETECT_LEFTCAM_MODEL_PATH))
75 {
76 // Set tensorflow detection enabled.
77 m_pTagDetectorLeftCam->EnableTensorflowDetection(constants::TAGDETECT_LEFTCAM_DNN_CONFIDENCE, constants::TAGDETECT_LEFTCAM_DNN_NMS_THRESH);
78 }
79 }
80 // Check if tensorflow detection is enabled for right BasicCam.
81 if (constants::TAGDETECT_RIGHTCAM_ENABLE_DNN)
82 {
83 // Attempt to init tensorflow detection.
84 if (m_pTagDetectorRightCam->InitTensorflowDetection(constants::TAGDETECT_RIGHTCAM_MODEL_PATH))
85 {
86 // Set tensorflow detection enabled.
87 m_pTagDetectorRightCam->EnableTensorflowDetection(constants::TAGDETECT_RIGHTCAM_DNN_CONFIDENCE, constants::TAGDETECT_RIGHTCAM_DNN_NMS_THRESH);
88 }
89 }
90
91 // Initialize recording handler for detectors.
92 m_pRecordingHandler = new RecordingHandler(RecordingHandler::RecordingMode::eTagDetectionHandler);
93}
The RecordingHandler class serves to enumerate the cameras available from the CameraHandler and retri...
Definition RecordingHandler.h:35
Run's Aruco detection & camera pose estimation in a multithreading environment. Given a camera,...
Definition TagDetector.h:45
bool InitTensorflowDetection(const std::string szModelPath, yolomodel::tensorflow::TPUInterpreter::PerformanceModes ePerformanceMode=yolomodel::tensorflow::TPUInterpreter::eMax)
Attempt to open the next available TPU hardware and load model at the given path onto the device.
Definition TagDetector.cpp:527
void EnableTensorflowDetection(const float fMinObjectConfidence=0.4f, const float fNMSThreshold=0.6f)
Turn on tensorflow detection with given parameters.
Definition TagDetector.cpp:566
Here is the call graph for this function:

◆ ~TagDetectionHandler()

TagDetectionHandler::~TagDetectionHandler ( )

Destroy the TagDetectionHandler::TagDetectionHandler object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07
103{
104 // Signal and wait for cameras to stop.
105 this->StopAllDetectors();
106
107 // Delete dynamic memory.
108 delete m_pTagDetectorMainCam;
109 delete m_pTagDetectorLeftCam;
110 delete m_pTagDetectorRightCam;
111 delete m_pRecordingHandler;
112
113 // Set dangling pointers to nullptr.
114 m_pTagDetectorMainCam = nullptr;
115 m_pTagDetectorLeftCam = nullptr;
116 m_pTagDetectorRightCam = nullptr;
117 m_pRecordingHandler = nullptr;
118}
void StopAllDetectors()
Signals all detectors to stop their threads.
Definition TagDetectionHandler.cpp:157
Here is the call graph for this function:

Member Function Documentation

◆ StartAllDetectors()

void TagDetectionHandler::StartAllDetectors ( )

Signals all detectors to start their threads.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07
128{
129 // Start ZED maincam detector.
130 m_pTagDetectorMainCam->Start();
131 m_pTagDetectorLeftCam->Start();
132 m_pTagDetectorRightCam->Start();
133
134 // Start the BasicCam aruco eyes.
135}
void Start()
When this method is called, it starts a new thread that runs the code within the ThreadedContinuousCo...
Definition AutonomyThread.hpp:117
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartRecording()

void TagDetectionHandler::StartRecording ( )

Signal the RecordingHandler to start recording video feeds from the TagDetectionHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-12-31
145{
146 // Start recording handler.
147 m_pRecordingHandler->Start();
148}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopAllDetectors()

void TagDetectionHandler::StopAllDetectors ( )

Signals all detectors to stop their threads.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07
158{
159 // Stop recording handler.
160 m_pRecordingHandler->RequestStop();
161 m_pRecordingHandler->Join();
162
163 // Stop ZED detectors.
164 m_pTagDetectorMainCam->RequestStop();
165 m_pTagDetectorLeftCam->RequestStop();
166 m_pTagDetectorRightCam->RequestStop();
167 m_pTagDetectorMainCam->Join();
168 m_pTagDetectorLeftCam->Join();
169 m_pTagDetectorRightCam->Join();
170
171 // Stop BasicCam aruco eye detectors.
172}
void Join()
Waits for thread to finish executing and then closes thread. This method will block the calling code ...
Definition AutonomyThread.hpp:180
void RequestStop()
Signals threads to stop executing user code, terminate. DOES NOT JOIN. This method will not force the...
Definition AutonomyThread.hpp:164
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopRecording()

void TagDetectionHandler::StopRecording ( )

Signal the RecordingHandler to stop recording video feeds from the TagDetectionHandler.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2024-01-01
182{
183 // Stop recording handler.
184 m_pRecordingHandler->RequestStop();
185 m_pRecordingHandler->Join();
186}
Here is the call graph for this function:

◆ GetTagDetector()

TagDetector * TagDetectionHandler::GetTagDetector ( TagDetectors  eDetectorName)

Accessor for TagDetector detectors.

Parameters
eDetectorName- The name of the detector to retrieve. An enum defined in and specific to this class.
Returns
TagDetector* - A pointer to the detector pertaining to the given name.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-10-07
198{
199 // Determine which tag detector should be returned.
200 switch (eDetectorName)
201 {
202 case TagDetectors::eHeadMainCam: return m_pTagDetectorMainCam;
203 case TagDetectors::eFrameLeftCam: return m_pTagDetectorLeftCam;
204 case TagDetectors::eFrameRightCam: return m_pTagDetectorRightCam;
205 default: return m_pTagDetectorMainCam;
206 }
207}
Here is the caller graph for this function:

The documentation for this class was generated from the following files: