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

The CameraHandler class is responsible for managing all of the camera feeds that Autonomy_Software uses for computer vision. Whether it be a USB webcam, a MJPEG stream, or a ZED camera, this class is responsible for initializing that camera and configuring it. More...

#include <CameraHandler.h>

Collaboration diagram for CameraHandler:

Public Types

enum class  ZEDCamName {
  ZEDCAM_START , eHeadMainCam , eFrameLeftCam , eFrameRightCam ,
  ZEDCAM_END
}
 
enum class  BasicCamName { BASICCAM_START , eHeadGroundCam , BASICCAM_END }
 

Public Member Functions

 CameraHandler ()
 Construct a new Camera Handler Thread:: Camera Handler Thread object.
 
 ~CameraHandler ()
 Destroy the Camera Handler Thread:: Camera Handler Thread object.
 
void StartAllCameras ()
 Signals all cameras to start their threads.
 
void StartRecording ()
 Signal the RecordingHandler to start recording video feeds from the CameraHandler.
 
void StopAllCameras ()
 Signals all cameras to stop their threads.
 
void StopRecording ()
 Signal the RecordingHandler to stop recording video feeds from the CameraHandler.
 
ZEDCameraGetZED (ZEDCamName eCameraName)
 Accessor for ZED cameras.
 
BasicCameraGetBasicCam (BasicCamName eCameraName)
 Accessor for Basic cameras.
 

Private Attributes

ZEDCameram_pMainCam
 
ZEDCameram_pLeftCam
 
ZEDCameram_pRightCam
 
BasicCameram_pGroundCam
 
RecordingHandlerm_pRecordingHandler
 

Detailed Description

The CameraHandler class is responsible for managing all of the camera feeds that Autonomy_Software uses for computer vision. Whether it be a USB webcam, a MJPEG stream, or a ZED camera, this class is responsible for initializing that camera and configuring it.

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

Member Enumeration Documentation

◆ ZEDCamName

enum class CameraHandler::ZEDCamName
strong
52 {
53 ZEDCAM_START,
54 eHeadMainCam,
55 eFrameLeftCam,
56 eFrameRightCam,
57 ZEDCAM_END
58 };

◆ BasicCamName

enum class CameraHandler::BasicCamName
strong
61 {
62 BASICCAM_START,
63 eHeadGroundCam,
64 BASICCAM_END
65 };

Constructor & Destructor Documentation

◆ CameraHandler()

CameraHandler::CameraHandler ( )

Construct a new Camera Handler Thread:: Camera Handler Thread object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
26{
27 // Check if we are in simulation mode.
28 if (!constants::MODE_SIM)
29 {
30 // Initialize main ZED camera.
31 m_pMainCam = new ZEDCam(constants::ZED_MAINCAM_RESOLUTIONX,
32 constants::ZED_MAINCAM_RESOLUTIONY,
33 constants::ZED_MAINCAM_FPS,
34 constants::ZED_MAINCAM_HORIZONTAL_FOV,
35 constants::ZED_MAINCAM_VERTICAL_FOV,
36 constants::ZED_MAINCAM_ENABLE_RECORDING,
37 constants::ZED_DEFAULT_MINIMUM_DISTANCE,
38 constants::ZED_DEFAULT_MAXIMUM_DISTANCE,
39 constants::ZED_MAINCAM_USE_GPU_MAT,
40 constants::ZED_MAINCAM_USE_HALF_PRECISION_DEPTH,
41 constants::ZED_MAINCAM_FUSION_MASTER,
42 constants::ZED_MAINCAM_FRAME_RETRIEVAL_THREADS,
43 constants::ZED_MAINCAM_SERIAL);
44 }
45 else
46 {
47 m_pMainCam = new SIMZEDCam("ws://" + constants::SIM_IP_ADDRESS + ":80",
48 constants::ZED_MAINCAM_RESOLUTIONX,
49 constants::ZED_MAINCAM_RESOLUTIONY,
50 constants::ZED_MAINCAM_FPS,
51 constants::ZED_MAINCAM_HORIZONTAL_FOV,
52 constants::ZED_MAINCAM_VERTICAL_FOV,
53 constants::ZED_MAINCAM_ENABLE_RECORDING,
54 constants::ZED_MAINCAM_FRAME_RETRIEVAL_THREADS,
55 constants::ZED_MAINCAM_SERIAL);
56 }
57
58 // Initialize left ZED camera.
59 m_pLeftCam = new ZEDCam(constants::ZED_LEFTCAM_RESOLUTIONX,
60 constants::ZED_LEFTCAM_RESOLUTIONY,
61 constants::ZED_LEFTCAM_FPS,
62 constants::ZED_LEFTCAM_HORIZONTAL_FOV,
63 constants::ZED_LEFTCAM_VERTICAL_FOV,
64 constants::ZED_LEFTCAM_ENABLE_RECORDING,
65 constants::ZED_DEFAULT_MINIMUM_DISTANCE,
66 constants::ZED_DEFAULT_MAXIMUM_DISTANCE,
67 constants::ZED_LEFTCAM_USE_GPU_MAT,
68 constants::ZED_LEFTCAM_USE_HALF_PRECISION_DEPTH,
69 constants::ZED_LEFTCAM_FUSION_MASTER,
70 constants::ZED_LEFTCAM_FRAME_RETRIEVAL_THREADS,
71 constants::ZED_LEFTCAM_SERIAL);
72
73 // Initialize right ZED camera.
74 m_pRightCam = new ZEDCam(constants::ZED_RIGHTCAM_RESOLUTIONX,
75 constants::ZED_RIGHTCAM_RESOLUTIONY,
76 constants::ZED_RIGHTCAM_FPS,
77 constants::ZED_RIGHTCAM_HORIZONTAL_FOV,
78 constants::ZED_RIGHTCAM_VERTICAL_FOV,
79 constants::ZED_RIGHTCAM_ENABLE_RECORDING,
80 constants::ZED_DEFAULT_MINIMUM_DISTANCE,
81 constants::ZED_DEFAULT_MAXIMUM_DISTANCE,
82 constants::ZED_RIGHTCAM_USE_GPU_MAT,
83 constants::ZED_RIGHTCAM_USE_HALF_PRECISION_DEPTH,
84 constants::ZED_RIGHTCAM_FUSION_MASTER,
85 constants::ZED_RIGHTCAM_FRAME_RETRIEVAL_THREADS,
86 constants::ZED_RIGHTCAM_SERIAL);
87
88 // Initialize ground eye.
89 m_pGroundCam = new BasicCam(constants::BASICCAM_GROUNDCAM_INDEX,
90 constants::BASICCAM_GROUNDCAM_RESOLUTIONX,
91 constants::BASICCAM_GROUNDCAM_RESOLUTIONY,
92 constants::BASICCAM_GROUNDCAM_FPS,
93 constants::BASICCAM_GROUNDCAM_PIXELTYPE,
94 constants::BASICCAM_GROUNDCAM_HORIZONTAL_FOV,
95 constants::BASICCAM_GROUNDCAM_VERTICAL_FOV,
96 constants::BASICCAM_GROUNDCAM_ENABLE_RECORDING,
97 constants::BASICCAM_GROUNDCAM_FRAME_RETRIEVAL_THREADS);
98
99 // Initialize recording handler for cameras.
100 m_pRecordingHandler = new RecordingHandler(RecordingHandler::RecordingMode::eCameraHandler);
101}
This class implements and interfaces with the most common USB cameras and features....
Definition BasicCam.h:33
The RecordingHandler class serves to enumerate the cameras available from the CameraHandler and retri...
Definition RecordingHandler.h:35
This class implements and interfaces with the SIM cameras and data. It is designed in such a way that...
Definition SIMZEDCam.h:34
This class implements and interfaces with the most common ZEDSDK cameras and features....
Definition ZEDCam.h:31

◆ ~CameraHandler()

CameraHandler::~CameraHandler ( )

Destroy the Camera Handler Thread:: Camera Handler Thread object.

Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-17
111{
112 // Signal and wait for cameras to stop.
113 this->StopAllCameras();
114
115 // Delete dynamic memory.
116 delete m_pMainCam;
117 delete m_pLeftCam;
118 delete m_pRightCam;
119 delete m_pGroundCam;
120 delete m_pRecordingHandler;
121
122 // Set dangling pointers to nullptr.
123 m_pMainCam = nullptr;
124 m_pLeftCam = nullptr;
125 m_pRightCam = nullptr;
126 m_pGroundCam = nullptr;
127 m_pRecordingHandler = nullptr;
128}
void StopAllCameras()
Signals all cameras to stop their threads.
Definition CameraHandler.cpp:168
Here is the call graph for this function:

Member Function Documentation

◆ StartAllCameras()

void CameraHandler::StartAllCameras ( )

Signals all cameras 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-09-09
138{
139 // Start ZED cams.
140 m_pMainCam->Start();
141 m_pLeftCam->Start();
142 m_pRightCam->Start();
143
144 // Start basic cams.
145 m_pGroundCam->Start();
146}
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 CameraHandler::StartRecording ( )

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

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

◆ StopAllCameras()

void CameraHandler::StopAllCameras ( )

Signals all cameras 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-03
169{
170 // Stop recording handler.
171 m_pRecordingHandler->RequestStop();
172 m_pRecordingHandler->Join();
173
174 // Stop ZED cams.
175 m_pMainCam->RequestStop();
176 m_pLeftCam->RequestStop();
177 m_pRightCam->RequestStop();
178 m_pMainCam->Join();
179 m_pLeftCam->Join();
180 m_pRightCam->Join();
181
182 // Stop basic cams.
183 m_pGroundCam->RequestStop();
184 m_pGroundCam->Join();
185}
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 CameraHandler::StopRecording ( )

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

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

◆ GetZED()

ZEDCamera * CameraHandler::GetZED ( ZEDCamName  eCameraName)

Accessor for ZED cameras.

Parameters
eCameraName- The name of the camera to retrieve. An enum defined in and specific to this class.
Returns
ZEDCamera* - A pointer to the zed camera 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-09-01
211{
212 // Determine which camera should be returned.
213 switch (eCameraName)
214 {
215 case ZEDCamName::eHeadMainCam: return m_pMainCam; // Return the ZEDCam in the autonomy head.
216 case ZEDCamName::eFrameLeftCam: return m_pLeftCam; // Return the ZEDCam on the left side of the rover frame.
217 case ZEDCamName::eFrameRightCam: return m_pRightCam; // Return the ZEDCam on the right side of the rover frame.
218 default: return m_pMainCam;
219 }
220}
Here is the caller graph for this function:

◆ GetBasicCam()

BasicCamera * CameraHandler::GetBasicCam ( BasicCamName  eCameraName)

Accessor for Basic cameras.

Parameters
eCameraName- The name of the camera to retrieve. An enum defined in and specific to this class.
Returns
BasicCamera* - A pointer to the basic camera 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-09-01
232{
233 // Determine which camera should be returned.
234 switch (eCameraName)
235 {
236 case BasicCamName::eHeadGroundCam: return m_pGroundCam; // Return the ground fisheye cam in the autonomy head.
237 default: return m_pGroundCam;
238 }
239}
Here is the caller graph for this function:

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