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
OpenBasicCam.hpp
Go to the documentation of this file.
1
11
16
17
36{
37 // Initialize basic cam.
38 std::shared_ptr<BasicCamera> ExampleBasicCam1 = std::make_unique<BasicCam>(0, 1280, 720, 60, PIXEL_FORMATS::eBGR, 0, 0, false);
39 // Start basic cam.
40 ExampleBasicCam1->Start();
41
42 // Declare mats to store images in.
43 cv::Mat cvNormalFrame1;
44 cv::Mat cvNormalFrame;
45
46 // Declare FPS counter.
47 IPS FPS = IPS();
48
49 // Loop forever, or until user hits ESC.
50 while (true)
51 {
52 // Grab normal frame from camera.
53 std::future<bool> fuCopyStatus1 = ExampleBasicCam1->RequestFrameCopy(cvNormalFrame1);
54 std::future<bool> fuCopyStatus2 = ExampleBasicCam1->RequestFrameCopy(cvNormalFrame2);
55
56 // Show first frame copy.
57 if (fuCopyStatus1.get() && !cvNormalFrame1.empty())
58 {
59 // Print info.
60 LOG_INFO(logging::g_qConsoleLogger,
61 "BasicCam Getter FPS: {} | 1% Low: {}",
62 ExampleBasicCam1->GetIPS().GetAverageIPS(),
63 ExampleBasicCam1->GetIPS().Get1PercentLow());
64
65 // Put FPS on normal frame.
66 cv::putText(cvNormalFrame1,
67 std::to_string(ExampleBasicCam1->GetIPS().GetExactIPS()),
68 cv::Point(50, 50),
70 1,
71 cv::Scalar(255, 255, 255));
72
73 // Display frame.
74 cv::imshow("BasicCamExample Frame1", cvNormalFrame1);
75 }
76
77 // Show second frame copy.
78 if (fuCopyStatus2.get() && !cvNormalFrame2.empty())
79 {
80 // Print info.
81 LOG_INFO(logging::g_qConsoleLogger,
82 "BasicCam Getter FPS: {} | 1% Low: {}",
83 ExampleBasicCam1->GetIPS().GetAverageIPS(),
84 ExampleBasicCam1->GetIPS().Get1PercentLow());
85
86 // Put FPS on normal frame.
87 cv::putText(cvNormalFrame2,
88 std::to_string(ExampleBasicCam1->GetIPS().GetExactIPS()),
89 cv::Point(50, 50),
91 1,
92 cv::Scalar(255, 255, 255));
93
94 // Display frame.
95 cv::imshow("BasicCamExample Frame2", cvNormalFrame2);
96 }
97
98 // Tick FPS counter.
99 FPS.Tick();
100 // Print FPS of main loop.
101 LOG_INFO(logging::g_qConsoleLogger, "Main FPS: {}", FPS.GetAverageIPS());
102
103 char chKey = cv::waitKey(1);
104 if (chKey == 27) // Press 'Esc' key to exit
105 break;
106 }
107
108 // Close all OpenCV windows.
110
112 // Cleanup.
114 // Stop camera threads.
115 globals::g_pCameraHandler->StopAllCameras();
116}
Defines functions and objects used project wide.
Implements Logging for Autonomy.
Defines the BasicCam class.
This file is a utility used to check if any file from the example directory has been included....
void RunExample()
This example demonstrates the proper way to interact with the CameraHandler. A pointer to a BasicCam ...
Definition OpenBasicCam.hpp:35
This util class provides an easy way to keep track of iterations per second for any body of code.
Definition IPS.hpp:30
double GetAverageIPS() const
Calculates the average iterations per second.
Definition IPS.hpp:180
void Tick()
This method is used to update the iterations per second counter and recalculate all of the IPS metric...
Definition IPS.hpp:138
bool empty() const
Point2i Point
Scalar_< double > Scalar
void imshow(const String &winname, InputArray mat)
int waitKey(int delay=0)
void destroyAllWindows()
void putText(InputOutputArray img, const String &text, Point org, int fontFace, double fontScale, Scalar color, int thickness=1, int lineType=LINE_8, bool bottomLeftOrigin=false)
FONT_HERSHEY_COMPLEX