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

This class implements and interfaces with the most common USB cameras and features. It is designed in such a way that multiple other classes/threads can safely call any method of an object of this class withing resource corruption or slowdown of the camera. More...

#include <BasicCam.h>

Inheritance diagram for BasicCam:
Collaboration diagram for BasicCam:

Public Member Functions

 BasicCam (const std::string szCameraPath, 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=10)
 Construct a new Basic Cam:: Basic Cam object.
 
 BasicCam (const int nCameraIndex, 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=10)
 Construct a new Basic Cam:: Basic Cam object. Overloaded for dev/video indexes.
 
 ~BasicCam ()
 Destroy the Basic Cam:: Basic Cam object.
 
std::future< bool > RequestFrameCopy (cv::Mat &cvFrame) override
 Puts a frame pointer into a queue so a copy of a frame from the camera can be written to it. Remember, this code will be ran in whatever, class/thread calls it.
 
bool GetCameraIsOpen () override
 Accessor for the camera open status.
 
std::string GetCameraLocation () const override
 Accessor for the cameras path or video index.
 
- Public Member Functions inherited from BasicCamera
 BasicCamera (const std::string szCameraPath, 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)
 Construct a new Basic Camera object.
 
 BasicCamera (const int nCameraIndex, 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)
 Construct a new Basic Camera object. Overloaded for dev/video indexes.
 
virtual ~BasicCamera ()
 Destroy the Basic Camera object.
 
- Public Member Functions inherited from Camera< cv::Mat >
 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.
 
virtual ~Camera ()
 Destroy the Camera object.
 
cv::Size GetPropResolution () const
 Accessor for the Prop Resolution private member.
 
int GetPropFramesPerSecond () const
 Accessor for the Prop Frames Per Second private member.
 
PIXEL_FORMATS GetPropPixelFormat () const
 Accessor for the Prop Pixel Format private member.
 
double GetPropHorizontalFOV () const
 Accessor for the Prop Horizontal F O V private member.
 
double GetPropVerticalFOV () const
 Accessor for the Prop Vertical F O V private member.
 
bool GetEnableRecordingFlag () const
 Accessor for the Enable Recording Flag private member.
 
void SetEnableRecordingFlag (const bool bEnableRecordingFlag)
 Mutator for the Enable Recording Flag private member.
 
- Public Member Functions inherited from AutonomyThread< void >
 AutonomyThread ()
 Construct a new Autonomy Thread object.
 
virtual ~AutonomyThread ()
 Destroy the Autonomy Thread object. If the parent object or main thread is destroyed or exited while this thread is still running, a race condition will occur. Stopping and joining the thread here insures that the main program can't exit if the user forgot to stop and join the thread.
 
void Start ()
 When this method is called, it starts a new thread that runs the code within the ThreadedContinuousCode method. This is the users main code that will run the important and continuous code for the class.
 
void RequestStop ()
 Signals threads to stop executing user code, terminate. DOES NOT JOIN. This method will not force the thread to exit, if the user code is not written properly and contains WHILE statement or any other long-executing or blocking code, then the thread will not exit until the next iteration.
 
void Join ()
 Waits for thread to finish executing and then closes thread. This method will block the calling code until thread is finished.
 
bool Joinable () const
 Check if the code within the thread and all pools created by it are finished executing and the thread is ready to be closed.
 
AutonomyThreadState GetThreadState () const
 Accessor for the Threads State private member.
 
IPSGetIPS ()
 Accessor for the Frame I P S private member.
 

Private Member Functions

void ThreadedContinuousCode () override
 The code inside this private method runs in a separate thread, but still has access to this*. This method continuously get new frames from the OpenCV VideoCapture object and stores it in a member variable. Then a thread pool is started and joined once per iteration to mass copy the frames and/or measure to any other thread waiting in the queues.
 
void PooledLinearCode () override
 This method holds the code that is ran in the thread pool started by the ThreadedLinearCode() method. It copies the data from the different data objects to references of the same type stored in a vector queued up by the Grab methods.
 

Private Attributes

cv::VideoCapture m_cvCamera
 
bool m_bCameraReopenAlreadyChecked
 
cv::Mat m_cvFrame
 

Additional Inherited Members

- Public Types inherited from AutonomyThread< void >
enum  AutonomyThreadState
 
- Protected Member Functions inherited from AutonomyThread< void >
void RunPool (const unsigned int nNumTasksToQueue, const unsigned int nNumThreads=2, const bool bForceStopCurrentThreads=false)
 When this method is called, it starts/adds tasks to a thread pool that runs nNumTasksToQueue copies of the code within the PooledLinearCode() method using nNumThreads number of threads. This is meant to be used as an internal utility of the child class to further improve parallelization. Default value for nNumThreads is 2.
 
void RunDetachedPool (const unsigned int nNumTasksToQueue, const unsigned int nNumThreads=2, const bool bForceStopCurrentThreads=false)
 When this method is called, it starts a thread pool full of threads that don't return std::futures (like a placeholder for the thread return type). This means the thread will not have a return type and there is no way to determine if the thread has finished other than calling the Join() method. Only use this if you want to 'set and forget'. It will be faster as it doesn't return futures. Runs PooledLinearCode() method code. This is meant to be used as an internal utility of the child class to further improve parallelization.
 
void ParallelizeLoop (const int nNumThreads, const N tTotalIterations, F &&tLoopFunction)
 Given a ref-qualified looping function and an arbitrary number of iterations, this method will divide up the loop and run each section in a thread pool. This function must not return anything. This method will block until the loop has completed.
 
void ClearPoolQueue ()
 Clears any tasks waiting to be ran in the queue, tasks currently running will remain running.
 
void JoinPool ()
 Waits for pool to finish executing tasks. This method will block the calling code until thread is finished.
 
bool PoolJoinable () const
 Check if the internal pool threads are done executing code and the queue is empty.
 
void SetMainThreadIPSLimit (int nMaxIterationsPerSecond=0)
 Mutator for the Main Thread Max I P S private member.
 
int GetPoolNumOfThreads ()
 Accessor for the Pool Num Of Threads private member.
 
int GetPoolQueueLength ()
 Accessor for the Pool Queue Size private member.
 
std::vector< void > GetPoolResults ()
 Accessor for the Pool Results private member. The action of getting results will destroy and remove them from this object. This method blocks if the thread is not finished, so no need to call JoinPool() before getting results.
 
int GetMainThreadMaxIPS () const
 Accessor for the Main Thread Max I P S private member.
 
- Protected Attributes inherited from BasicCamera
int m_nCameraIndex
 
std::string m_szCameraPath
 
bool m_bCameraIsConnectedOnVideoIndex
 
- Protected Attributes inherited from Camera< cv::Mat >
int m_nPropResolutionX
 
int m_nPropResolutionY
 
int m_nPropFramesPerSecond
 
int m_nNumFrameRetrievalThreads
 
PIXEL_FORMATS m_ePropPixelFormat
 
double m_dPropHorizontalFOV
 
double m_dPropVerticalFOV
 
std::atomic_bool m_bEnableRecordingFlag
 
std::queue< containers::FrameFetchContainer< cv::Mat > > m_qFrameCopySchedule
 
std::shared_mutex m_muPoolScheduleMutex
 
std::shared_mutex m_muFrameCopyMutex
 
- Protected Attributes inherited from AutonomyThread< void >
IPS m_IPS
 

Detailed Description

This class implements and interfaces with the most common USB cameras and features. It is designed in such a way that multiple other classes/threads can safely call any method of an object of this class withing resource corruption or slowdown of the camera.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-21

Constructor & Destructor Documentation

◆ BasicCam() [1/2]

BasicCam::BasicCam ( const std::string  szCameraPath,
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 = 10 
)

Construct a new Basic Cam:: Basic Cam object.

Parameters
szCameraPath- The file path to the camera hardware.
nPropResolutionX- X res of camera.
nPropResolutionY- Y res of camera.
nPropFramesPerSecond- FPS camera is running at.
ePropPixelFormat- The pixel layout/format of the image.
dPropHorizontalFOV- The horizontal field of view.
dPropVerticalFOV- The vertical field of view.
bEnableRecordingFlag- Whether or not this camera should be recorded.
nNumFrameRetrievalThreads- The number of threads to use for frame queueing and copying.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-20
39 :
40 BasicCamera(szCameraPath,
41 nPropResolutionX,
42 nPropResolutionY,
43 nPropFramesPerSecond,
44 ePropPixelFormat,
45 dPropHorizontalFOV,
46 dPropVerticalFOV,
47 bEnableRecordingFlag,
48 nNumFrameRetrievalThreads)
49{
50 // Initialize the OpenCV mat to a black/empty image the size of the camera resolution.
51 m_cvFrame = cv::Mat::zeros(nPropResolutionY, nPropResolutionX, CV_8UC4);
52
53 // Set video cap properties.
54 m_cvCamera.set(cv::CAP_PROP_FRAME_WIDTH, nPropResolutionX);
55 m_cvCamera.set(cv::CAP_PROP_FRAME_HEIGHT, nPropResolutionY);
56 m_cvCamera.set(cv::CAP_PROP_FPS, nPropFramesPerSecond);
57
58 // Initialize other member variables.
59 m_bCameraReopenAlreadyChecked = false;
60
61 // Attempt to open camera with OpenCV's VideoCapture and print if successfully opened or not.
62 if (m_cvCamera.open(szCameraPath))
63 {
64 // Submit logger message.
65 LOG_INFO(logging::g_qSharedLogger, "Camera {} at path/URL {} has been successfully opened.", m_cvCamera.getBackendName(), szCameraPath);
66 }
67 else
68 {
69 // Submit logger message.
70 LOG_ERROR(logging::g_qSharedLogger, "Unable to open camera at path/URL {}", szCameraPath);
71 }
72
73 // Set max FPS of the ThreadedContinuousCode method.
74 this->SetMainThreadIPSLimit(nPropFramesPerSecond);
75}
void SetMainThreadIPSLimit(int nMaxIterationsPerSecond=0)
Mutator for the Main Thread Max I P S private member.
Definition AutonomyThread.hpp:467
This class serves as a middle inheritor between the Camera interface and the BasicCam class....
Definition BasicCamera.hpp:28
static CV_NODISCARD_STD MatExpr zeros(int rows, int cols, int type)
String getBackendName() const
virtual bool open(const String &filename, int apiPreference=CAP_ANY)
virtual bool set(int propId, double value)
CAP_PROP_FRAME_WIDTH
CAP_PROP_FRAME_HEIGHT
CAP_PROP_FPS
Here is the call graph for this function:

◆ BasicCam() [2/2]

BasicCam::BasicCam ( const int  nCameraIndex,
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 = 10 
)

Construct a new Basic Cam:: Basic Cam object. Overloaded for dev/video indexes.

Parameters
nCameraIndex- The video index that the camera is connected on.
nPropResolutionX- X res of camera.
nPropResolutionY- Y res of camera.
nPropFramesPerSecond- FPS camera is running at.
ePropPixelFormat- The pixel layout/format of the image.
dPropHorizontalFOV- The horizontal field of view.
dPropVerticalFOV- The vertical field of view.
bEnableRecordingFlag- Whether or not this camera should be recorded.
nNumFrameRetrievalThreads- The number of threads to use for frame queueing and copying.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-20
102 :
103 BasicCamera(nCameraIndex,
104 nPropResolutionX,
105 nPropResolutionY,
106 nPropFramesPerSecond,
107 ePropPixelFormat,
108 dPropHorizontalFOV,
109 dPropVerticalFOV,
110 bEnableRecordingFlag,
111 nNumFrameRetrievalThreads)
112{
113 // Initialize the OpenCV mat to a black/empty image the size of the camera resolution.
114 m_cvFrame = cv::Mat::zeros(nPropResolutionY, nPropResolutionX, CV_8UC4);
115
116 // Set video cap properties.
117 m_cvCamera.set(cv::CAP_PROP_FRAME_WIDTH, nPropResolutionX);
118 m_cvCamera.set(cv::CAP_PROP_FRAME_HEIGHT, nPropResolutionY);
119 m_cvCamera.set(cv::CAP_PROP_FPS, nPropFramesPerSecond);
120
121 // Initialize other member variables.
122 m_bCameraReopenAlreadyChecked = false;
123
124 // Attempt to open camera with OpenCV's VideoCapture.
125 m_cvCamera.open(m_nCameraIndex);
126 // Check if the camera was successfully opened.
127 if (m_cvCamera.isOpened())
128 {
129 // Submit logger message.
130 LOG_INFO(logging::g_qSharedLogger, "Camera {} at video index {} has been successfully opened.", m_cvCamera.getBackendName(), m_nCameraIndex);
131 }
132 else
133 {
134 // Submit logger message.
135 LOG_ERROR(logging::g_qSharedLogger, "Unable to open camera at video index {}", m_nCameraIndex);
136 }
137
138 // Set max FPS of the ThreadedContinuousCode method.
139 this->SetMainThreadIPSLimit(nPropFramesPerSecond);
140}
virtual bool isOpened() const
Here is the call graph for this function:

◆ ~BasicCam()

BasicCam::~BasicCam ( )

Destroy the Basic Cam:: Basic Cam object.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-20
150{
151 // Stop threaded code.
152 this->RequestStop();
153 this->Join();
154
155 // Release camera capture object.
156 m_cvCamera.release();
157
158 // Check if camera was connected on a video index.
159 if (m_bCameraIsConnectedOnVideoIndex)
160 {
161 // Submit logger message.
162 LOG_INFO(logging::g_qSharedLogger, "Basic camera at video index {} has been successfully closed.", m_nCameraIndex);
163 }
164 else
165 {
166 // Submit logger message.
167 LOG_INFO(logging::g_qSharedLogger, "Basic camera at path/URL {} has been successfully closed.", m_szCameraPath);
168 }
169}
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
virtual void release()
Here is the call graph for this function:

Member Function Documentation

◆ RequestFrameCopy()

std::future< bool > BasicCam::RequestFrameCopy ( cv::Mat cvFrame)
overridevirtual

Puts a frame pointer into a queue so a copy of a frame from the camera can be written to it. Remember, this code will be ran in whatever, class/thread calls it.

Parameters
cvFrame- A reference to the cv::Mat to store the frame in.
Returns
std::future<bool> - A future that should be waited on before the passed in frame is used. Value will be true if frame was successfully retrieved.
Author
ClayJay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-09

Implements BasicCamera.

325{
326 // Assemble the FrameFetchContainer.
327 containers::FrameFetchContainer<cv::Mat> stContainer(cvFrame, m_ePropPixelFormat);
328
329 // Acquire lock on frame copy queue.
330 std::unique_lock<std::shared_mutex> lkScheduler(m_muPoolScheduleMutex);
331 // Append frame fetch container to the schedule queue.
332 m_qFrameCopySchedule.push(stContainer);
333 // Release lock on the frame schedule queue.
334 lkScheduler.unlock();
335
336 // Return the future from the promise stored in the container.
337 return stContainer.pCopiedFrameStatus->get_future();
338}
This struct is used to carry references to camera frames for scheduling and copying....
Definition FetchContainers.hpp:89

◆ GetCameraIsOpen()

bool BasicCam::GetCameraIsOpen ( )
overridevirtual

Accessor for the camera open status.

Returns
true - The camera has been successfully opened.
false - The camera has not been successfully opened.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-20

Implements Camera< cv::Mat >.

350{
351 // Get camera status from OpenCV.
352 return this->GetThreadState() == AutonomyThreadState::eRunning && m_cvCamera.isOpened();
353}
AutonomyThreadState GetThreadState() const
Accessor for the Threads State private member.
Definition AutonomyThread.hpp:214
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCameraLocation()

std::string BasicCam::GetCameraLocation ( ) const
overridevirtual

Accessor for the cameras path or video index.

Returns
std::string - The path or index of the camera.
Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-08-20

Reimplemented from BasicCamera.

364{
365 // Check if camera location is a hardware path or video index.
366 if (m_bCameraIsConnectedOnVideoIndex)
367 {
368 // If video index, return index integer.
369 return std::to_string(m_nCameraIndex);
370 }
371 else
372 {
373 // If video path, return path string.
374 return m_szCameraPath;
375 }
376}
Here is the caller graph for this function:

◆ ThreadedContinuousCode()

void BasicCam::ThreadedContinuousCode ( )
overrideprivatevirtual

The code inside this private method runs in a separate thread, but still has access to this*. This method continuously get new frames from the OpenCV VideoCapture object and stores it in a member variable. Then a thread pool is started and joined once per iteration to mass copy the frames and/or measure to any other thread waiting in the queues.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-16

Reimplemented from BasicCamera.

184{
185 // Check if camera is NOT open.
186 if (!m_cvCamera.isOpened())
187 {
188 // If this is the first iteration of the thread the camera probably isn't present so stop thread to save resources.
189 if (this->GetThreadState() == AutonomyThreadState::eStarting)
190 {
191 // Shutdown threads for this BasicCam.
192 this->RequestStop();
193
194 // Submit logger message.
195 LOG_CRITICAL(logging::g_qSharedLogger, "Camera start was attempted for BasicCam at {}/{}, but camera was never opened!", m_nCameraIndex, m_szCameraPath);
196 }
197 else
198 {
199 // Create instance variables.
200 bool bCameraReopened = false;
201 std::chrono::time_point tmCurrentTime = std::chrono::system_clock::now();
202 // Convert time point to seconds since epoch
203 int nTimeSinceEpoch = std::chrono::duration_cast<std::chrono::seconds>(tmCurrentTime.time_since_epoch()).count();
204
205 // Only try to reopen camera every 5 seconds.
206 if (nTimeSinceEpoch % 5 == 0 && !m_bCameraReopenAlreadyChecked)
207 {
208 // Check if camera was opened with an index or path.
209 if (m_nCameraIndex == -1)
210 {
211 // Attempt to reopen camera.
212 bCameraReopened = m_cvCamera.open(m_szCameraPath);
213 }
214 else
215 {
216 // Attempt to reopen camera.
217 bCameraReopened = m_cvCamera.open(m_nCameraIndex);
218 }
219
220 // Check if camera was reopened.
221 if (bCameraReopened)
222 {
223 // Submit logger message.
224 LOG_INFO(logging::g_qSharedLogger, "Camera {}/{} has been reconnected and reopened!", m_nCameraIndex, m_szCameraPath);
225 }
226 else
227 {
228 // Submit logger message.
229 LOG_WARNING(logging::g_qSharedLogger, "Attempt to reopen Camera {}/{} has failed! Trying again in 5 seconds...", m_nCameraIndex, m_szCameraPath);
230 // Sleep for five seconds.
231 }
232
233 // Set toggle.
234 m_bCameraReopenAlreadyChecked = true;
235 }
236 else if (nTimeSinceEpoch % 5 != 0)
237 {
238 // Reset toggle.
239 m_bCameraReopenAlreadyChecked = false;
240 }
241 }
242 }
243 else
244 {
245 // Check if new frame was computed successfully.
246 if (m_cvCamera.read(m_cvFrame))
247 {
248 // Resize the frame.
249 cv::resize(m_cvFrame, m_cvFrame, cv::Size(m_nPropResolutionX, m_nPropResolutionY), 0.0, 0.0, constants::BASICCAM_RESIZE_INTERPOLATION_METHOD);
250 }
251 else
252 {
253 // Submit logger message.
254 LOG_ERROR(logging::g_qSharedLogger, "Unable to read new frame for camera {}, {}! Closing camera...", m_nCameraIndex, m_szCameraPath);
255 // Release camera capture.
256 m_cvCamera.release();
257
258 // Fill camera frame member variable with zeros. This ensures a non-corrupt, black image.
259 m_cvFrame = cv::Mat::zeros(m_nPropResolutionY, m_nPropResolutionX, CV_8UC3);
260 }
261 }
262
263 // Acquire a shared_lock on the frame copy queue.
264 std::shared_lock<std::shared_mutex> lkSchedulers(m_muPoolScheduleMutex);
265 // Check if the frame copy queue is empty.
266 if (!m_qFrameCopySchedule.empty())
267 {
268 // Start the thread pool to store multiple copies of the sl::Mat into the given cv::Mats.
269 this->RunDetachedPool(m_qFrameCopySchedule.size(), m_nNumFrameRetrievalThreads);
270 // Wait for thread pool to finish.
271 this->JoinPool();
272 // Release lock on frame copy queue.
273 lkSchedulers.unlock();
274 }
275}
void RunDetachedPool(const unsigned int nNumTasksToQueue, const unsigned int nNumThreads=2, const bool bForceStopCurrentThreads=false)
When this method is called, it starts a thread pool full of threads that don't return std::futures (l...
Definition AutonomyThread.hpp:336
void JoinPool()
Waits for pool to finish executing tasks. This method will block the calling code until thread is fin...
Definition AutonomyThread.hpp:439
virtual bool read(OutputArray image)
void resize(InputArray src, OutputArray dst, Size dsize, double fx=0, double fy=0, int interpolation=INTER_LINEAR)
Here is the call graph for this function:

◆ PooledLinearCode()

void BasicCam::PooledLinearCode ( )
overrideprivatevirtual

This method holds the code that is ran in the thread pool started by the ThreadedLinearCode() method. It copies the data from the different data objects to references of the same type stored in a vector queued up by the Grab methods.

Author
clayjay3 (clayt.nosp@m.onra.nosp@m.ycowe.nosp@m.n@gm.nosp@m.ail.c.nosp@m.om)
Date
2023-09-16

Reimplemented from BasicCamera.

288{
289 // Acquire mutex for getting frames out of the queue.
290 std::unique_lock<std::shared_mutex> lkFrameQueue(m_muFrameCopyMutex);
291 // Check if the queue is empty.
292 if (!m_qFrameCopySchedule.empty())
293 {
294 // Get frame container out of queue.
295 containers::FrameFetchContainer<cv::Mat> stContainer = m_qFrameCopySchedule.front();
296 // Pop out of queue.
297 m_qFrameCopySchedule.pop();
298 // Release lock.
299 lkFrameQueue.unlock();
300
301 // Copy frame to data container.
302 *stContainer.pFrame = m_cvFrame.clone();
303 // Signal future that the frame has been successfully retrieved.
304 stContainer.pCopiedFrameStatus->set_value(true);
305 }
306 else
307 {
308 // Release lock.
309 lkFrameQueue.unlock();
310 }
311}
CV_NODISCARD_STD Mat clone() const
Here is the call graph for this function:

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