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
OpenSIMZEDCam.hpp
1
11
12#include "../../../src/AutonomyConstants.h"
13#include "../../../src/AutonomyGlobals.h"
14#include "../../../src/AutonomyLogging.h"
15#include "../../../src/AutonomyNetworking.h"
16#include "../../../src/util/ExampleChecker.h"
17#include "../../../src/vision/cameras/sim/SIMZEDCam.h"
18
20
22
23
32void RunExample()
33{
34 // Create a new SIMZEDCam object.
35 std::unique_ptr<SIMZEDCam> pZEDCam = std::make_unique<SIMZEDCam>("ws://192.168.69.48:80", 1280, 720, 60, 90.0, 60.0, true);
36 pZEDCam->Start();
37
38 // Create a cv::Mat to store the frame.
39 cv::Mat cvFrame;
40 cv::Mat cvDepthImage;
41 cv::Mat cvDepthMeasure;
42
43 while (true)
44 {
45 std::future<bool> fuFrame = pZEDCam->RequestFrameCopy(cvFrame);
46 std::future<bool> fuDepthImage = pZEDCam->RequestDepthCopy(cvDepthImage, false);
47 std::future<bool> fuDepthMeasure = pZEDCam->RequestDepthCopy(cvDepthMeasure, true);
48
49 // Wait for the frame to be copied.
50 if (fuFrame.get() && !cvFrame.empty())
51 {
52 // Convert the frame to a supported type and display it.
53 cv::imshow("Frame", cvFrame);
54 }
55
56 // Wait for the depth image to be copied.
57 if (fuDepthImage.get() && !cvDepthImage.empty())
58 {
59 // Convert the frame to a supported type and display it.
60 cv::imshow("Depth Image", cvDepthImage);
61 }
62
63 // Wait for the depth measure to be copied.
64 if (fuDepthMeasure.get() && !cvDepthMeasure.empty())
65 {
66 // Display the depth measure.
67 cv::imshow("Depth Measure", cvDepthMeasure);
68
69 // Print out depth value at center of image.
70 LOG_INFO(logging::g_qSharedLogger, "Depth at center of image: {}", cvDepthMeasure.at<uint16_t>(cvDepthMeasure.rows / 2, cvDepthMeasure.cols / 2));
71 }
72
73 // Print camera FPS stat.
74 // LOG_INFO(logging::g_qSharedLogger, "Camera FPS: {}", pZEDCam->GetIPS().GetExactIPS());
75
76 // OpenCV display pause and check if while loop should exit.
77 char chKey = cv::waitKey(1);
78 if (chKey == 27) // Press 'Esc' key to exit
79 break;
80 }
81
82 // Stop the camera.
83 pZEDCam->RequestStop();
84 pZEDCam->Join();
85}
void RunExample()
Example function to demonstrate the usage of LiDARHandler.
Definition GeoPlanner.hpp:25
_Tp & at(int i0=0)
bool empty() const
void imshow(const String &winname, InputArray mat)
int waitKey(int delay=0)
::uint16_t uint16_t