Autoware.Auto
greedy_roi_associator.hpp
Go to the documentation of this file.
1 // Copyright 2021 Apex.AI, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef TRACKING__GREEDY_ROI_ASSOCIATOR_HPP_
15 #define TRACKING__GREEDY_ROI_ASSOCIATOR_HPP_
16 
17 #include <autoware_auto_perception_msgs/msg/classified_roi_array.hpp>
18 #include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
19 #include <geometry/common_2d.hpp>
23 #include <tf2/buffer_core.h>
24 #include <tracking/projection.hpp>
28 
29 #include <string>
30 #include <unordered_set>
31 #include <vector>
32 
33 namespace autoware
34 {
35 namespace perception
36 {
37 namespace tracking
38 {
40 struct TRACKING_PUBLIC IOUHeuristic
41 {
50  template<template<typename ...> class Iterable1T,
51  template<typename ...> class Iterable2T, typename Point1T, typename Point2T>
53  const Iterable1T<Point1T> & shape1, const Iterable2T<Point2T> & shape2) const
54  {
56  }
57 };
58 
60 {
63 };
64 
67 class TRACKING_PUBLIC GreedyRoiAssociator
68 {
69 public:
71 
75  explicit GreedyRoiAssociator(
76  const GreedyRoiAssociatorConfig & config,
77  const tf2::BufferCore & tf_buffer);
78 
84  AssociatorResult assign(
85  const autoware_auto_perception_msgs::msg::ClassifiedRoiArray & rois,
86  const TrackedObjects & tracks) const;
87 
95  AssociatorResult assign(
96  const autoware_auto_perception_msgs::msg::ClassifiedRoiArray & rois,
98 
99 private:
100  // Handles extrapolation exception alone. Caller responsible for all else
101  geometry_msgs::msg::TransformStamped lookup_transform_handler(
102  const std::string & target_frame,
103  const std::string & source_frame,
104  const tf2::TimePoint & stamp) const;
105 
106  // Scan the ROIs to find the best matching roi for a given shape by projecting it onto image
107  // frame
108  std::size_t project_and_match_detection(
109  const std::vector<geometry_msgs::msg::Point32> & object_shape_in_camera_frame,
110  const std::unordered_set<std::size_t> & available_roi_indices,
111  const autoware_auto_perception_msgs::msg::ClassifiedRoiArray & rois) const;
112 
113  CameraModel m_camera;
114  IOUHeuristic m_iou_func{};
115  float32_t m_iou_threshold{0.1F};
116  const tf2::BufferCore & m_tf_buffer;
117 
118  static const std::chrono::milliseconds kTfTooOld;
119 };
120 
121 namespace details
122 {
124 class TRACKING_PUBLIC ShapeTransformer
125 {
126 public:
127  explicit ShapeTransformer(const geometry_msgs::msg::Transform & tf);
128  using Point32 = geometry_msgs::msg::Point32;
134  std::vector<Point32> operator()(
135  const autoware_auto_perception_msgs::msg::Shape & shape,
136  const geometry_msgs::msg::Point & centroid,
137  const geometry_msgs::msg::Quaternion & orientation) const;
138 
139 private:
141 };
142 } // namespace details
143 } // namespace tracking
144 } // namespace perception
145 } // namespace autoware
146 
147 #endif // TRACKING__GREEDY_ROI_ASSOCIATOR_HPP_
autoware::perception::tracking::GreedyRoiAssociatorConfig::iou_threshold
float32_t iou_threshold
Definition: greedy_roi_associator.hpp:62
autoware::perception::tracking::TrackedObjects
A collection of tracked objects.
Definition: include/tracking/tracked_object.hpp:158
autoware::perception::tracking::GreedyRoiAssociator
Class to associate the detections and tracks in euclidean space to ROIs in image space on a first-com...
Definition: greedy_roi_associator.hpp:67
autoware::perception::tracking::details::ShapeTransformer::Point32
geometry_msgs::msg::Point32 Point32
Definition: greedy_roi_associator.hpp:128
autoware::perception::tracking::GreedyRoiAssociator::float32_t
autoware::common::types::float32_t float32_t
Definition: greedy_roi_associator.hpp:70
autoware::common::lidar_utils::StaticTransformer
Transform to apply a constant transform to given points.
Definition: point_cloud_utils.hpp:237
autoware::perception::tracking::CameraIntrinsics
Camera intrinsic parameters.
Definition: projection.hpp:47
point_cloud_utils.hpp
This class defines common functions and classes to work with pointclouds.
common_2d.hpp
This file includes common functionality for 2D geometry, such as dot products.
visibility_control.hpp
projection.hpp
autoware::perception::tracking::GreedyRoiAssociatorConfig::intrinsics
CameraIntrinsics intrinsics
Definition: greedy_roi_associator.hpp:61
tracker_types.hpp
autoware
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24
intersection.hpp
autoware::perception::tracking::AssociatorResult
Struct to store results after the assignment is done.
Definition: tracker_types.hpp:40
motion::planning::recordreplay_planner_nodes::Transform
geometry_msgs::msg::TransformStamped Transform
Definition: recordreplay_planner_node.hpp:56
motion::motion_testing_nodes::TransformStamped
geometry_msgs::msg::TransformStamped TransformStamped
Definition: motion_testing_publisher.hpp:37
autoware::common::geometry::convex_intersection_over_union_2d
common::types::float32_t convex_intersection_over_union_2d(const Iterable1T< PointT > &polygon1, const Iterable2T< PointT > &polygon2)
Compute the intersection over union of two 2d convex polygons. If any of the polygons span a zero are...
Definition: intersection.hpp:292
autoware::perception::tracking::GreedyRoiAssociatorConfig
Definition: greedy_roi_associator.hpp:59
autoware::perception::tracking::CameraModel
This model represents a camera in 3D space and can project 3D shapes into an image.
Definition: projection.hpp:60
autoware::common::types::float32_t
float float32_t
Definition: types.hpp:45
tracked_object.hpp
This file defines the multi_object_tracking class.
autoware::perception::tracking::details::ShapeTransformer
Transform a 3D prism shape msg into a transformed vector points.
Definition: greedy_roi_associator.hpp:124
Point
geometry_msgs::msg::Point32 Point
Definition: cluster2d.cpp:28
autoware::perception::tracking::IOUHeuristic::operator()
common::types::float32_t operator()(const Iterable1T< Point1T > &shape1, const Iterable2T< Point2T > &shape2) const
Get the match score of a projection and a roi.
Definition: greedy_roi_associator.hpp:52
template_utils.hpp
autoware::perception::tracking::IOUHeuristic
Simple heuristic functor that returns the IoU between two shapes.
Definition: greedy_roi_associator.hpp:40
DetectedObjects
autoware_auto_perception_msgs::msg::DetectedObjects DetectedObjects
Definition: euclidean_cluster_node.cpp:39