Auterion App SDK
Auterion SDK is a library that can be used by AuterionOS apps to communicate with the system.
tracking_interface.hpp
1 /****************************************************************************
2  *
3  * Copyright 2024 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/Eigen>
36 #include <auterion_sdk/auterion.hpp>
37 #include <auterion_sdk/camera/camera.hpp>
38 #include <auterion_sdk/tracking/common.hpp>
39 #include <opencv2/core/mat.hpp>
40 #include <opencv2/core/types.hpp>
41 #include <optional>
42 
43 namespace auterion {
48 class TrackingInterfaceImpl;
49 
56  public:
57  using ImageCallback = std::function<void(const auterion::Image& image)>;
58  using CameraInfoCallback =
59  std::function<void(const sensor_msgs::msg::CameraInfo::SharedPtr& camera_info)>;
60  using TrackSelectionCallback = std::function<void(const TrackingSelection& selection)>;
61  using TrackStopCallback = std::function<void(void)>;
62  using TrackZoomChangeCallback = std::function<void(const int change)>;
63  using TrackAdjustmentCallback = std::function<void(const TrackingAdjustment& adjustment)>;
64 
65  // Deprecated alias for backwards compatibility
66  using TrackingKeyControl
67  [[deprecated("TrackingKeyControl has been renamed. Please use TrackingAdjustment.")]] =
68  TrackingAdjustment;
69  using TrackKeyControlCallback [[deprecated(
70  "TrackKeyControlCallback has been renamed. Please use TrackAdjustmentCallback.")]] =
71  TrackAdjustmentCallback;
72 
82  TrackingInterface(auterion::SDK& sdk, std::shared_ptr<auterion::Camera> camera = nullptr);
83 
95  [[deprecated(
96  "'camera_descriptor' not used anymore. This will be removed in some later "
97  "release.")]] TrackingInterface(auterion::SDK& sdk,
98  std::optional<auterion::CameraDescriptor>
99  camera_descriptor);
100 
102 
107  [[deprecated(
108  "Replace by equal function in camera interface. This will be removed in some later "
109  "release.")]] void
110  subscribeImage(const ImageCallback& callback);
111 
116  [[deprecated(
117  "Replace by equal function in camera interface. This will be removed in some later "
118  "release.")]] void
119  subscribeCameraInfo(const CameraInfoCallback& callback);
120 
125  void subscribeTrackingSelection(const TrackSelectionCallback& callback);
126 
131  void subscribeTrackingOff(const TrackStopCallback& callback);
132 
137  void subscribeTrackingZoomChange(const TrackZoomChangeCallback& callback);
138 
144  void subscribeTrackingAdjustment(const TrackAdjustmentCallback& callback);
145 
146  [[deprecated(
147  "subscribeKeyControl has been renamed. Please use subscribeTrackingAdjustment.")]] void
148  subscribeKeyControl(const TrackKeyControlCallback& callback) {
149  subscribeTrackingAdjustment(callback);
150  }
151 
161  void updateImage(const cv::Mat& image, const auterion::ImageHeader::Encoding& encoding,
162  const std::optional<cv::Rect>& displayed_region = std::nullopt,
163  const std::optional<TrackingResult>& tracking_result = std::nullopt);
164 
175  void updateImage(const cv::Mat& image, const auterion::ImageHeader::Encoding& encoding,
176  const TrackingResult& tracking_result);
177 
182  // TODO create an overload with plain/simple types?
183  void updateResult(TrackingResult& tracking_result) const;
184 
199  [[deprecated(
200  "Replace by equal function in camera interface. This will be removed in some later "
201  "release.")]] bool
202  getPoseBodyCamera(Eigen::Vector3d& t_body_camera, Eigen::Quaterniond& q_body_camera) const;
203 
204  private:
205  std::shared_ptr<TrackingInterfaceImpl> _impl;
206 };
207 
209 } // namespace auterion
Contains image data with a specific encoding.
Definition: camera.hpp:213
SDK execution class. All callbacks are called on the same thread.
Definition: auterion.hpp:97
Provides an API to react to tracking related events, and update the current tracking status.
Definition: tracking_interface.hpp:55
bool getPoseBodyCamera(Eigen::Vector3d &t_body_camera, Eigen::Quaterniond &q_body_camera) const
Get the pose of the camera with respect to the body frame.
void subscribeImage(const ImageCallback &callback)
Subscribes to incoming images.
void subscribeCameraInfo(const CameraInfoCallback &callback)
Subscribes to camera information data.
void subscribeTrackingZoomChange(const TrackZoomChangeCallback &callback)
Subscribes to the tracking zoom change events.
void updateImage(const cv::Mat &image, const auterion::ImageHeader::Encoding &encoding, const std::optional< cv::Rect > &displayed_region=std::nullopt, const std::optional< TrackingResult > &tracking_result=std::nullopt)
Updates image for connected systems to display and publishes the tracking result over MAVLink to be r...
void subscribeTrackingOff(const TrackStopCallback &callback)
Subscribes to the tracking off events.
void subscribeTrackingAdjustment(const TrackAdjustmentCallback &callback)
Subscribes to the tracking adjustment events.
TrackingInterface(auterion::SDK &sdk, std::optional< auterion::CameraDescriptor > camera_descriptor)
[Deprecated] Constructor that selects a camera based on a provided descriptor.
TrackingInterface(auterion::SDK &sdk, std::shared_ptr< auterion::Camera > camera=nullptr)
Constructor that accepts a camera object.
void subscribeTrackingSelection(const TrackSelectionCallback &callback)
Subscribes to tracking selection requests.
void updateResult(TrackingResult &tracking_result) const
Updates the tracking result for connected systems.
void updateImage(const cv::Mat &image, const auterion::ImageHeader::Encoding &encoding, const TrackingResult &tracking_result)
Updates image for connected systems to display and publishes the tracking result over MAVLink to be r...
Represents the result of an image tracking operation.
Definition: common.hpp:84
Encoding
Image encoding, following FourCC.
Definition: camera.hpp:71
Represents the tracking selection as received by AMC.
Definition: common.hpp:133