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
TensorflowObjectDetection.hpp
1
12#ifndef TENSORFLOW_OBJECT_DETECTION_HPP
13#define TENSORFLOW_OBJECT_DETECTION_HPP
14
15#include "../../AutonomyConstants.h"
16#include "../../AutonomyLogging.h"
17#include "../../util/GeospatialOperations.hpp"
18
20#include <opencv2/opencv.hpp>
21#include <vector>
22
24
25
34{
35
44 {
45 public:
46 // Declare public struct member attributes.
47 cv::Point2f CornerTL; // The top left corner of the bounding box.
48 cv::Point2f CornerTR; // The top right corner of the bounding box.
49 cv::Point2f CornerBL; // The bottom left corner of the bounding box.
50 cv::Point2f CornerBR; // The bottom right corner of bounding box.
51 std::vector<cv::Point2f*> vCorners = {&CornerTL, &CornerTR, &CornerBL, &CornerBR}; // Provide an easy method for getting all corners.
52 geoops::UTMCoordinate stLocation; // The absolute position of the object stored in a UTM coordinate.
53 int nID; // ID of the tag.
54 double dConfidence; // The detection confidence of the object reported from the tensorflow model.
55 double dStraightLineDistance; // Distance between the object and the camera.
56 double dYawAngle; // This is the yaw angle so roll and pitch are ignored.
57 };
58
59
69 {
70 // Average of the four corners
71 cv::Point2f cvCenter(0, 0);
72
73 // Loop through each corner of the object.
74 for (cv::Point2f* cvCorner : stObject.vCorners)
75 {
76 // Add each object x, y to the center x, y.
77 cvCenter.x += cvCorner->x;
78 cvCenter.y += cvCorner->y;
79 }
80 // Divide by number of corners.
81 cvCenter.x /= 4;
82 cvCenter.y /= 4;
83
84 // Return a copy of the center point of the object.
85 return cvCenter;
86 }
87
88
99 inline std::vector<TensorflowObject> Detect(const cv::Mat& cvFrame)
100 {
101 // TODO: Write different util classes to easily open and inference new models. Then put object detection specific inferencing here.
102 cvFrame.empty();
103 return std::vector<TensorflowObject>();
104 }
105} // namespace tensorflowobject
106
107#endif
bool empty() const
Namespace containing functions related to tensorflow object detection operations on images.
Definition TensorflowObjectDetection.hpp:34
std::vector< TensorflowObject > Detect(const cv::Mat &cvFrame)
Detect objects in the given image using a tensorflow model.
Definition TensorflowObjectDetection.hpp:99
cv::Point2f FindObjectCenter(const TensorflowObject &stObject)
Given an TensorflowObject struct find the center point of the corners.
Definition TensorflowObjectDetection.hpp:68
This struct stores/contains information about a UTM coordinate.
Definition GeospatialOperations.hpp:244
Represents a single depth object detection from a tensorflow model. Stores all information about a sp...
Definition TensorflowObjectDetection.hpp:44