Apollo 10.0
自动驾驶开放平台
yolo_obstacle_detector.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 "modules/perception/camera_detection_multi_stage/detector/yolo/proto/model_param.pb.h"
23
27
28namespace apollo {
29namespace perception {
30namespace camera {
31
33 public:
36 if (stream_ != nullptr) {
37 cudaStreamDestroy(stream_);
38 }
39 }
47 bool Init(const ObstacleDetectorInitOptions &options =
56 bool Detect(onboard::CameraFrame *frame) override;
62 std::string Name() const override { return "YoloObstacleDetector"; }
63
64 protected:
65 void LoadInputShape(const yolo::ModelParam &model_param);
66 void LoadParam(const yolo::ModelParam &model_param);
67 void InitYoloBlob();
68
69 private:
71 yolo::ModelParam model_param_;
72
73 std::vector<base::ObjectSubType> types_;
74 std::vector<float> expands_;
75 std::vector<float> anchors_;
76
77 NMSParam nms_;
78 MinDims min_dims_;
79 cudaStream_t stream_;
80 int height_ = 0;
81 int width_ = 0;
82 int offset_y_ = 0;
83 int gpu_id_ = 0;
84 int obj_k_ = kMaxObjSize;
85
86 int ori_cycle_ = 1;
87 float confidence_threshold_ = 0.f;
88 float light_vis_conf_threshold_ = 0.f;
89 float light_swt_conf_threshold_ = 0.f;
90
91 YoloBlobs yolo_blobs_;
92
93 std::shared_ptr<base::Blob<bool>> overlapped_ = nullptr;
94 std::shared_ptr<base::Blob<int>> idx_sm_ = nullptr;
95
96 bool with_box3d_ = false;
97 bool with_frbox_ = false;
98 bool with_lights_ = false;
99 bool with_ratios_ = false;
100 bool with_area_id_ = false;
101 float border_ratio_ = 0.f;
102};
103
104} // namespace camera
105} // namespace perception
106} // namespace apollo
bool Detect(onboard::CameraFrame *frame) override
Get obstacles detection result, detector main part
bool Init(const ObstacleDetectorInitOptions &options=ObstacleDetectorInitOptions()) override
Load obstacle detector configs
std::string Name() const override
ObstacleDetector name
void LoadInputShape(const yolo::ModelParam &model_param)
void LoadParam(const yolo::ModelParam &model_param)
class register implement
Definition arena_queue.h:37