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
Camera.hpp
Go to the documentation of this file.
1
11#ifndef CAMERA_HPP
12#define CAMERA_HPP
13
14#include "../util/vision/FetchContainers.hpp"
15#include "./AutonomyThread.hpp"
16
18#include <atomic>
19#include <future>
20#include <shared_mutex>
21
23
24
32template<class T>
33class Camera : public AutonomyThread<void>
34{
35 public:
36 // Declare public methods and member variables.
37
51 Camera(const int nPropResolutionX,
52 const int nPropResolutionY,
53 const int nPropFramesPerSecond,
54 const PIXEL_FORMATS ePropPixelFormat,
55 const double dPropHorizontalFOV,
56 const double dPropVerticalFOV,
57 const bool bEnableRecordingFlag,
58 const int nNumFrameRetrievalThreads = 5)
59 {
60 // Initialize member variables.
61 m_nPropResolutionX = nPropResolutionX;
62 m_nPropResolutionY = nPropResolutionY;
63 m_nPropFramesPerSecond = nPropFramesPerSecond;
64 m_ePropPixelFormat = ePropPixelFormat;
65 m_dPropHorizontalFOV = dPropHorizontalFOV;
66 m_dPropVerticalFOV = dPropVerticalFOV;
67 m_bEnableRecordingFlag = bEnableRecordingFlag;
68 m_nNumFrameRetrievalThreads = nNumFrameRetrievalThreads;
69 }
70
71
78 virtual ~Camera() {}
79
80
88 cv::Size GetPropResolution() const { return cv::Size(m_nPropResolutionX, m_nPropResolutionY); }
89
90
98 int GetPropFramesPerSecond() const { return m_nPropFramesPerSecond; }
99
100
109 PIXEL_FORMATS GetPropPixelFormat() const { return m_ePropPixelFormat; }
110
111
119 double GetPropHorizontalFOV() const { return m_dPropHorizontalFOV; }
120
121
129 double GetPropVerticalFOV() const { return m_dPropVerticalFOV; }
130
131
140 bool GetEnableRecordingFlag() const { return m_bEnableRecordingFlag; }
141
142
150 void SetEnableRecordingFlag(const bool bEnableRecordingFlag) { m_bEnableRecordingFlag = bEnableRecordingFlag; }
151
152
161 virtual bool GetCameraIsOpen() = 0; // This is where the code to check if the camera is currently open goes.
162
163 protected:
164 // Declare protected methods and member variables.
165 int m_nPropResolutionX;
166 int m_nPropResolutionY;
167 int m_nPropFramesPerSecond;
168 int m_nNumFrameRetrievalThreads;
169 PIXEL_FORMATS m_ePropPixelFormat;
170 double m_dPropHorizontalFOV;
171 double m_dPropVerticalFOV;
172 std::atomic_bool m_bEnableRecordingFlag;
173
174 // Queues and mutexes for scheduling and copying camera frames and data to other threads.
175 std::queue<containers::FrameFetchContainer<T>> m_qFrameCopySchedule;
176 std::shared_mutex m_muPoolScheduleMutex;
177 std::shared_mutex m_muFrameCopyMutex;
178
179 // Declare interface class pure virtual functions. (These must be overriden by inheritor.)
180 virtual std::future<bool> RequestFrameCopy(T& tFrame) = 0; // This is where the code to retrieve an image from the camera is put.
181
182 private:
183 // Declare private methods and member variables.
184};
185#endif
Interface class used to easily multithread a child class.
Definition AutonomyThread.hpp:38
This interface class serves as a base for all other classes that will implement and interface with a ...
Definition Camera.hpp:34
void SetEnableRecordingFlag(const bool bEnableRecordingFlag)
Mutator for the Enable Recording Flag private member.
Definition Camera.hpp:150
Camera(const int nPropResolutionX, const int nPropResolutionY, const int nPropFramesPerSecond, const PIXEL_FORMATS ePropPixelFormat, const double dPropHorizontalFOV, const double dPropVerticalFOV, const bool bEnableRecordingFlag, const int nNumFrameRetrievalThreads=5)
Construct a new Camera object.
Definition Camera.hpp:51
cv::Size GetPropResolution() const
Accessor for the Prop Resolution private member.
Definition Camera.hpp:88
virtual ~Camera()
Destroy the Camera object.
Definition Camera.hpp:78
int GetPropFramesPerSecond() const
Accessor for the Prop Frames Per Second private member.
Definition Camera.hpp:98
bool GetEnableRecordingFlag() const
Accessor for the Enable Recording Flag private member.
Definition Camera.hpp:140
virtual bool GetCameraIsOpen()=0
Accessor for the Camera Is Open private member.
double GetPropVerticalFOV() const
Accessor for the Prop Vertical F O V private member.
Definition Camera.hpp:129
PIXEL_FORMATS GetPropPixelFormat() const
Accessor for the Prop Pixel Format private member.
Definition Camera.hpp:109
double GetPropHorizontalFOV() const
Accessor for the Prop Horizontal F O V private member.
Definition Camera.hpp:119
Size2i Size