Apollo 10.0
自动驾驶开放平台
omt_obstacle_tracker.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16#pragma once
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include <boost/circular_buffer.hpp>
23
24#include "modules/perception/camera_tracking/proto/omt.pb.h"
25
33
34namespace apollo {
35namespace perception {
36namespace camera {
37
38struct alignas(16) Hypothesis {
39 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
40 int target;
41 int object;
42 float score;
43
44 Hypothesis() : target(-1), object(-1), score(-1) {}
45
46 Hypothesis(int tar, int obj, float score)
47 : target(tar), object(obj), score(score) {}
48
49 bool operator<(const Hypothesis &b) const { return score < b.score; }
50
51 bool operator>(const Hypothesis &b) const { return score > b.score; }
52};
53
55 public:
56 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
57
58 OMTObstacleTracker() = default;
60
68 bool Init(const ObstacleTrackerInitOptions &options) override;
69
77 bool Process(std::shared_ptr<CameraTrackingFrame> camera_frame);
78
86 bool FeatureExtract(CameraTrackingFrame *frame) override;
87
96 bool Predict(CameraTrackingFrame *frame) override;
97
105 // bool CalSimilarity(CameraTrackingFrame *frame) override;
106
115 bool Associate2D(std::shared_ptr<CameraTrackingFrame> frame) override;
116
125 bool Associate3D(std::shared_ptr<CameraTrackingFrame> frame) override;
126
127 private:
135 float ScoreAppearance(const Target &target, TrackObjectPtr object);
136
144 float ScoreMotion(const Target &target, TrackObjectPtr object);
152 float ScoreShape(const Target &target, TrackObjectPtr object);
160 float ScoreOverlap(const Target &target, TrackObjectPtr track_obj);
165 void ClearTargets();
172 bool CombineDuplicateTargets();
178 void GenerateHypothesis(const TrackObjectPtrs &objects);
185 int CreateNewTarget(const TrackObjectPtrs &objects);
186
187 private:
188 std::shared_ptr<BaseFeatureExtractor> feature_extractor_;
189 OmtParam omt_param_;
190 boost::circular_buffer<std::shared_ptr<CameraTrackingFrame>> frame_buffer_;
191 SimilarMap similar_map_;
192 std::shared_ptr<BaseSimilar> similar_ = nullptr;
193 // Target is one tracked object in a sequence
194 // targets_ is all the tracked objects in a sequence
196 std::vector<bool> used_;
197 ObstacleReference reference_;
198 std::vector<std::vector<float>> kTypeAssociatedCost_;
199 int track_id_ = 0;
200 int frame_num_ = 0;
201 int gpu_id_ = 0;
202 float width_ = 0.0f;
203 float height_ = 0.0f;
204
205 protected:
207};
208
209} // namespace camera
210} // namespace perception
211} // namespace apollo
bool Init(const ObstacleTrackerInitOptions &options) override
initialize omt obstacle tracker with options
bool FeatureExtract(CameraTrackingFrame *frame) override
extract features from the new frame
bool Process(std::shared_ptr< CameraTrackingFrame > camera_frame)
main function for tracking
EIGEN_MAKE_ALIGNED_OPERATOR_NEW OMTObstacleTracker()=default
std::vector< EigenType, Eigen::aligned_allocator< EigenType > > EigenVector
Definition eigen_defs.h:33
std::vector< TrackObjectPtr > TrackObjectPtrs
std::shared_ptr< TrackObject > TrackObjectPtr
class register implement
Definition arena_queue.h:37
Hypothesis(int tar, int obj, float score)
bool operator>(const Hypothesis &b) const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int target
bool operator<(const Hypothesis &b) const