Apollo 11.0
自动驾驶开放平台
bev_obstacle_detector.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2022 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 <string>
19#include <vector>
20
21#include "Eigen/Core"
22#include "opencv2/opencv.hpp"
23
24#include "modules/perception/camera_detection_bev/detector/petr/proto/model_param.pb.h"
25
30
31namespace apollo {
32namespace perception {
33namespace camera {
34
36 public:
38 virtual ~BEVObstacleDetector() = default;
46 bool Init(const ObstacleDetectorInitOptions &options =
55 bool Detect(CameraFrame *frame) override;
56
57 std::string Name() const override { return "BEVObstacleDetector"; }
58
59 private:
60 bool InitTypes(const petr::ModelParam &model_param);
61
62 void InitImageSize(const petr::ModelParam &model_param);
63
64 bool ImagePreprocess(const CameraFrame *frame,
65 base::BlobPtr<float> input_img_blob);
66
67 bool ImageExtrinsicPreprocess(base::BlobPtr<float> input_img2lidar_blob);
68
69 bool Nuscenes2Apollo(std::vector<base::ObjectPtr> *objects);
70
71 void Mat2Vec(const cv::Mat &im, float *data);
72
73 private:
74 int height_;
75 int width_;
76 int img_height_crop_ = 320;
77 int img_width_crop_ = 800;
78
79 std::vector<float> k_data_{
80 -1.40307297e-03, 9.07780395e-06, 4.84838307e-01, -5.43047376e-02,
81 -1.40780103e-04, 1.25770375e-05, 1.04126692e+00, 7.67668605e-01,
82 -1.02884378e-05, -1.41007011e-03, 1.02823459e-01, -3.07415128e-01,
83 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00,
84 -9.39000631e-04, -7.65239349e-07, 1.14073277e+00, 4.46270645e-01,
85 1.04998052e-03, 1.91798881e-05, 2.06218868e-01, 7.42717385e-01,
86 1.48074005e-05, -1.40855671e-03, 7.45946690e-02, -3.16081315e-01,
87 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00,
88 -7.0699735e-04, 4.2389297e-07, -5.5183989e-01, -5.3276348e-01,
89 -1.2281288e-03, 2.5626015e-05, 1.0212017e+00, 6.1102939e-01,
90 -2.2421273e-05, -1.4170362e-03, 9.3639769e-02, -3.0863306e-01,
91 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 1.0000000e+00,
92 2.2227580e-03, 2.5312484e-06, -9.7261822e-01, 9.0684637e-02,
93 1.9360810e-04, 2.1347081e-05, -1.0779887e+00, -7.9227984e-01,
94 4.3742721e-06, -2.2310747e-03, 1.0842450e-01, -2.9406491e-01,
95 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 1.0000000e+00,
96 5.97175560e-04, -5.88774265e-06, -1.15893924e+00, -4.49921310e-01,
97 -1.28312141e-03, 3.58297058e-07, 1.48300052e-01, 1.14334166e-01,
98 -2.80917516e-06, -1.41527120e-03, 8.37693438e-02, -2.36765608e-01,
99 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00,
100 3.6048229e-04, 3.8333174e-06, 7.9871160e-01, 4.3321830e-01,
101 1.3671946e-03, 6.7484652e-06, -8.4722507e-01, 1.9411178e-01,
102 7.5027779e-06, -1.4139183e-03, 8.2083985e-02, -2.4505949e-01,
103 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 1.0000000e+00};
104
105 petr::ModelParam model_param_;
106 ObstacleDetectorInitOptions options_;
107 std::vector<base::ObjectSubType> types_;
108};
109
110} // namespace camera
111} // namespace perception
112} // namespace apollo
bool Detect(CameraFrame *frame) override
Get obstacles detection result
std::string Name() const override
Interface for obstacle detector name
bool Init(const ObstacleDetectorInitOptions &options=ObstacleDetectorInitOptions()) override
Init ObstacleDetector constructor.
std::shared_ptr< Blob< Dtype > > BlobPtr
Definition blob.h:313
class register implement
Definition arena_queue.h:37