Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
common.hpp
1 /****************************************************************************
2  *
3  * Copyright 2025 Auterion AG. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  ****************************************************************************/
32 
33 #pragma once
34 
35 #include <Eigen/Dense>
36 #include <opencv2/core/mat.hpp>
37 #include <opencv2/core/types.hpp>
38 #include <optional>
39 #include <rclcpp/rclcpp.hpp>
40 
41 namespace auterion {
47  UNKNOWN = 0, // Used for constructors and error handling
48  INACTIVE = 1, // No tracking is active
49  TRACKING = 2, // Actively tracking a target with good confidence
50  DEGRADED = 3, // Tracking with reduced confidence
51  LOST = 4 // Target was being tracked but has been lost
52 };
53 
59 std::ostream& operator<<(std::ostream& os, const TrackingState& state);
60 
66  public:
67  enum class Frame {
68  Camera,
69  Body, // equal to FMU
70  FMU, // equal to Body
71  World, // equal to ENU
72  ENU // equal to World
73  };
74 
75  TrackingResult(const cv::Point& object_center, const cv::Size& object_size,
76  const float confidence = 1.f, TrackingState state = TrackingState::UNKNOWN);
77 
78  ~TrackingResult();
79 
80  TrackingResult& withConfidence(const float confidence);
81 
82  TrackingResult& withObjectDirection(const Eigen::Vector3f& direction, Frame frame);
83 
84  inline cv::Point getObjectCenter() const { return _object_center; }
85  inline cv::Size getObjectSize() const { return _object_size; }
86  inline float getConfidence() const { return _confidence; }
87  inline TrackingState getTrackingState() const { return _tracking_state; }
88  Eigen::Vector3f getObjectDirection(Frame frame = Frame::Camera) const;
89 
90  private:
91  cv::Size _object_size;
92  cv::Point _object_center;
93  Eigen::Vector3f _object_direction_camera_frame;
95  Eigen::Vector3f _object_direction_body_frame;
97  Eigen::Vector3f _object_direction_world_frame;
99  float _confidence;
101  _tracking_state;
102 };
103 
115  cv::Point2d normalized_point;
119  std::optional<rclcpp::Time>
121 
130  timestamp(std::nullopt) {}
131 
143  timestamp(std::nullopt) {}
144 };
145 } // namespace auterion
Camera client to subscribe to a camera image stream.
Definition: camera.hpp:307
Represents the result of an image tracking operation.
Definition: common.hpp:65
std::ostream & operator<<(std::ostream &os, const TrackingState &state)
Overloaded << operator to stringify the TrackingState enum.
TrackingState
Tracking state enum to represent different tracking states.
Definition: common.hpp:46
Represents the tracking selection as received by AMC.
Definition: common.hpp:114
std::optional< rclcpp::Time > timestamp
Optional timestamp for the tracking selection (not currently used).
Definition: common.hpp:120
cv::Size2d normalized_window_size
Definition: common.hpp:117
TrackingSelection(cv::Point2d normalized_point)
Constructor for creating a tracking selection with a point only.
Definition: common.hpp:127
cv::Point2d normalized_point
Definition: common.hpp:115
TrackingSelection(cv::Point2d normalized_point, cv::Size2d normalized_window_size)
Constructor for creating a tracking selection with a point and a window size. This should be used whe...
Definition: common.hpp:140