11#ifndef OBJECT_DETECTOR_H
12#define OBJECT_DETECTOR_H
14#include "../../interfaces/BasicCamera.hpp"
15#include "../../interfaces/ZEDCamera.hpp"
16#include "../../util/vision/ObjectDetectionUtility.hpp"
17#include "../../util/vision/YOLOModel.hpp"
21#include <shared_mutex>
43 const bool bEnableTracking =
false,
44 const int nDetectorMaxFPS = 30,
45 const bool bEnableRecordingFlag =
false,
46 const int nNumDetectedObjectsRetrievalThreads = 5,
47 const bool bUsingGpuMats =
false);
49 const bool bEnableTracking =
false,
50 const int nDetectorMaxFPS = 30,
51 const bool bEnableRecordingFlag =
false,
52 const int nNumDetectedObjectsRetrievalThreads = 5,
53 const bool bUsingGpuMats =
false);
58 yolomodel::pytorch::PyTorchInterpreter::HardwareDevices eDevice = yolomodel::pytorch::PyTorchInterpreter::HardwareDevices::eCUDA);
64 void EnableTorchDetection(
const float fMinObjectConfidence = 0.4f,
const float fNMSThreshold = 0.6f);
93 std::shared_ptr<Camera<cv::Mat>> m_pCamera;
94 std::shared_ptr<yolomodel::pytorch::PyTorchInterpreter> m_pTorchDetector;
95 std::atomic<float> m_fTorchMinObjectConfidence;
96 std::atomic<float> m_fTorchNMSThreshold;
97 std::atomic_bool m_bTorchInitialized;
98 std::atomic_bool m_bTorchEnabled;
99 std::shared_ptr<tracking::MultiTracker> m_pMultiTracker;
100 bool m_bUsingZedCamera;
101 bool m_bUsingGpuMats;
102 bool m_bCameraIsOpened;
103 bool m_bEnableTracking;
104 int m_nNumDetectedObjectsRetrievalThreads;
105 std::string m_szCameraName;
106 std::atomic_bool m_bEnableRecordingFlag;
110 std::vector<objectdetectutils::Object> m_vNewlyDetectedObjects;
111 std::vector<objectdetectutils::Object> m_vDetectedObjects;
127 std::queue<containers::FrameFetchContainer<cv::Mat>> m_qDetectedObjectDrawnOverlayFramesCopySchedule;
128 std::queue<containers::DataFetchContainer<std::vector<objectdetectutils::Object>>> m_qDetectedObjectCopySchedule;
129 std::shared_mutex m_muPoolScheduleMutex;
130 std::shared_mutex m_muFrameCopyMutex;
131 std::shared_mutex m_muArucoDataCopyMutex;
Interface class used to easily multithread a child class.
Definition AutonomyThread.hpp:38
This class implements a modular and easy to use object detector for a single camera....
Definition ObjectDetector.h:37
std::future< bool > RequestDetectionOverlayFrame(cv::Mat &cvFrame)
Request a copy of the frame containing the detected objects from all detection methods drawn onto the...
Definition ObjectDetector.cpp:393
void SetEnableRecordingFlag(const bool bEnableRecordingFlag)
Set the flag to enable or disable recording of the overlay output.
Definition ObjectDetector.cpp:535
bool GetEnableRecordingFlag() const
Get the flag to enable or disable recording of the overlay output.
Definition ObjectDetector.cpp:606
void UpdateDetectedObjects(std::vector< objectdetectutils::Object > &vNewlyDetectedObjects)
Update the detected objects with the newly detected objects.
Definition ObjectDetector.cpp:657
void PooledLinearCode() override
This method will run in a thread pool. It will be called by the main thread and will run the code wit...
Definition ObjectDetector.cpp:332
void EnableTorchDetection(const float fMinObjectConfidence=0.4f, const float fNMSThreshold=0.6f)
Enable the PyTorch detection method for this ObjectDetector.
Definition ObjectDetector.cpp:479
std::string GetCameraName()
Get the camera name.
Definition ObjectDetector.cpp:620
void DisableTorchDetection()
Set the flag to enable or disable object detection with the torch model.
Definition ObjectDetector.cpp:507
int GetDetectorMaxFPS() const
Get the max FPS of the detector.
Definition ObjectDetector.cpp:591
std::future< bool > RequestDetectedObjects(std::vector< objectdetectutils::Object > &vObjects)
Request a copy of the most update to date vector of the detected objects from all detection methods.
Definition ObjectDetector.cpp:419
bool GetIsReady()
Check if the ObjectDetector is ready to be used.
Definition ObjectDetector.cpp:550
bool InitTorchDetection(const std::string &szModelPath, yolomodel::pytorch::PyTorchInterpreter::HardwareDevices eDevice=yolomodel::pytorch::PyTorchInterpreter::HardwareDevices::eCUDA)
Initialize the PyTorch interpreter for object detection.
Definition ObjectDetector.cpp:446
~ObjectDetector()
Destroy the Object Detector:: Object Detector object.
Definition ObjectDetector.cpp:121
cv::Size GetProcessFrameResolution() const
Get the process frame resolution.
Definition ObjectDetector.cpp:634
void SetDetectorMaxFPS(const int nRecordingFPS)
Set the max FPS of the detector.
Definition ObjectDetector.cpp:521
void ThreadedContinuousCode() override
This method will run continuously in a separate thread. New frames from the given camera are grabbed ...
Definition ObjectDetector.cpp:142
This struct is used by the WaypointHandler to provide an easy way to store all pose data about the ro...
Definition GeospatialOperations.hpp:677