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
ObjectDetector.h
Go to the documentation of this file.
1
11#ifndef OBJECT_DETECTOR_H
12#define OBJECT_DETECTOR_H
13
14#include "../../interfaces/BasicCamera.hpp"
15#include "../../interfaces/ZEDCamera.hpp"
16#include "./DepthDetection.hpp"
17#include "./TensorflowObjectDetection.hpp"
18
20#include <future>
21#include <shared_mutex>
22#include <vector>
23
25
26
36class ObjectDetector : public AutonomyThread<void>
37{
38 public:
40 // Declare public methods and member variables.
42 ObjectDetector(BasicCamera* pBasicCam, const int nNumDetectedObjectsRetrievalThreads = 5, const bool bUsingGpuMats = false);
43 ObjectDetector(ZEDCamera* pZEDCam, const int nNumDetectedObjectsRetrievalThreads = 5, const bool bUsingGpuMats = false);
44 std::future<bool> RequestDepthDetectionOverlayFrame(cv::Mat& cvFrame);
45 std::future<bool> RequestTensorflowDetectionOverlayFrame(cv::Mat& cvFrame);
46 std::future<bool> RequestDetectedDepthObjects(std::vector<depthobject::DepthObject>& vDepthObjects);
47 std::future<bool> RequestDetectedTensorflowObjects(std::vector<tensorflowobject::TensorflowObject>& vTensorflowObjects);
48 IPS& GetIPS();
49
50 private:
52 // Declare private member variables.
54 // Class member variables.
55
56 Camera<cv::Mat>* m_pCamera;
57 bool m_bUsingZedCamera;
58 bool m_bUsingGpuMats;
59 int m_nNumDetectedObjectsRetrievalThreads;
60 IPS m_IPS;
61
62 // Detected objects storage.
63
64 std::vector<depthobject::DepthObject> m_vDetectedDepthObjects;
65 std::vector<tensorflowobject::TensorflowObject> m_vDetectedTensorObjects;
66
67 // Create frames for storing images and point clouds.
68
69 cv::Mat m_cvNormalFrame;
70 cv::Mat m_cvProcFrame;
71 cv::Mat m_cvDepthMeasure;
72 cv::cuda::GpuMat m_cvGPUNormalFrame;
73 cv::cuda::GpuMat m_cvGPUDepthMeasure;
74
75 // Queues and mutexes for scheduling and copying data to other threads.
76
77 std::queue<containers::FrameFetchContainer<cv::Mat>> m_qDetectedObjectDrawnOverlayFrames;
78 std::queue<containers::DataFetchContainer<std::vector<depthobject::DepthObject>>> m_qDetectedDepthObjectCopySchedule;
79 std::queue<containers::DataFetchContainer<std::vector<tensorflowobject::TensorflowObject>>> m_qDetectedTensorflowObjectCopySchedule;
80 std::shared_mutex m_muPoolScheduleMutex;
81 std::mutex m_muFrameCopyMutex;
82 std::mutex m_muDepthDataCopyMutex;
83 std::mutex m_muTensorflowDataCopyMutex;
84
86 // Declare private methods.
88 void ThreadedContinuousCode() override;
89 void PooledLinearCode() override;
90 void UpdateDetectedObjects(std::vector<depthobject::DepthObject>& vNewlyDetectedObjects);
91 void UpdateDetectedObjects(std::vector<tensorflowobject::TensorflowObject>& vNewlyDetectedObjects);
92};
93
94#endif
Interface class used to easily multithread a child class.
Definition AutonomyThread.hpp:38
This class serves as a middle inheritor between the Camera interface and the BasicCam class....
Definition BasicCamera.hpp:28
This interface class serves as a base for all other classes that will implement and interface with a ...
Definition Camera.hpp:34
This util class provides an easy way to keep track of iterations per second for any body of code.
Definition IPS.hpp:30
This class implements a modular and easy to use object detector for a single camera....
Definition ObjectDetector.h:37
std::future< bool > RequestDepthDetectionOverlayFrame(cv::Mat &cvFrame)
Request a copy of a frame containing the object detection overlays from the depth library.
Definition ObjectDetector.cpp:243
std::future< bool > RequestTensorflowDetectionOverlayFrame(cv::Mat &cvFrame)
Request a copy of a frame containing the object detection overlays from the tensorflow model.
Definition ObjectDetector.cpp:270
void PooledLinearCode() override
This method holds the code that is ran in the thread pool started by the ThreadedLinearCode() method....
Definition ObjectDetector.cpp:158
IPS & GetIPS()
Accessor for the Frame I P S private member.
Definition ObjectDetector.cpp:384
std::future< bool > RequestDetectedTensorflowObjects(std::vector< tensorflowobject::TensorflowObject > &vTensorflowObjects)
Request the most up to date vector of detected objects from our custom tensorflow model.
Definition ObjectDetector.cpp:324
std::future< bool > RequestDetectedDepthObjects(std::vector< depthobject::DepthObject > &vDepthObjects)
Request the most up to date vector of detected objects from OpenCV's Depth algorithm.
Definition ObjectDetector.cpp:297
void ThreadedContinuousCode() override
This code will run continuously in a separate thread. New frames from the given camera are grabbed an...
Definition ObjectDetector.cpp:64
This class serves as a middle inheritor between the Camera interface and the ZEDCam class....
Definition ZEDCamera.hpp:33