Apollo 11.0
自动驾驶开放平台
detection.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 <map>
19#include <memory>
20#include <string>
21#include <vector>
22
23#include "modules/perception/traffic_light_detection/detector/caffe_detection/proto/model_param.pb.h"
24
25#include "cyber/common/macros.h"
32
33namespace apollo {
34namespace perception {
35namespace trafficlight {
36
38public:
56 bool Init(const TrafficLightDetectorInitOptions &options) override;
57
65 bool Detect(camera::TrafficLightFrame *frame) override;
77 const std::vector<base::RectI> &crop_box_list,
78 const std::vector<float> &resize_scale_list_col,
79 const std::vector<float> &resize_scale_list_row,
80 std::vector<base::TrafficLightPtr> *lights);
87 void ApplyNMS(std::vector<base::TrafficLightPtr> *lights, double iou_thresh = 0.6);
96 bool Inference(std::vector<base::TrafficLightPtr> *lights, camera::DataProvider *data_provider);
102 const std::vector<base::TrafficLightPtr> &getDetectedBoxes() {
103 return detected_bboxes_;
104 }
105
106private:
107 trafficlight::ModelParam detection_param_;
108 std::string detection_root_dir;
109
110 camera::DataProvider::ImageOptions data_provider_image_option_;
111 std::shared_ptr<inference::Inference> rt_net_ = nullptr;
112 std::shared_ptr<base::Image8U> image_ = nullptr;
113 std::shared_ptr<base::Blob<float>> param_blob_;
114 std::shared_ptr<base::Blob<float>> mean_buffer_;
115 std::shared_ptr<IGetBox> crop_;
116 std::vector<base::TrafficLightPtr> detected_bboxes_;
117 std::vector<base::TrafficLightPtr> selected_bboxes_;
118 std::vector<std::string> net_inputs_;
119 std::vector<std::string> net_outputs_;
120 Select select_;
121 int max_batch_size_;
122 int param_blob_length_;
123 float mean_[3];
124 std::vector<base::RectI> crop_box_list_;
125 std::vector<float> resize_scale_list_;
126 int gpu_id_;
127
129}; // class TrafficLightDetection
130
131} // namespace trafficlight
132} // namespace perception
133} // namespace apollo
bool Inference(std::vector< base::TrafficLightPtr > *lights, camera::DataProvider *data_provider)
Model inference process.
Definition detection.cc:134
bool Detect(camera::TrafficLightFrame *frame) override
Detect traffic light from image.
Definition detection.cc:207
bool Init(const TrafficLightDetectorInitOptions &options) override
Initialize traffic light detector parameters.
Definition detection.cc:38
TrafficLightDetection()
Construct a new traffic light detection object.
Definition detection.cc:35
const std::vector< base::TrafficLightPtr > & getDetectedBoxes()
Get the detected boxes object.
Definition detection.h:102
bool SelectOutputBoxes(const std::vector< base::RectI > &crop_box_list, const std::vector< float > &resize_scale_list_col, const std::vector< float > &resize_scale_list_row, std::vector< base::TrafficLightPtr > *lights)
Dump output of inference results.
Definition detection.cc:264
void ApplyNMS(std::vector< base::TrafficLightPtr > *lights, double iou_thresh=0.6)
Filter overlapping boxes using NMS.
Definition detection.cc:346
~TrafficLightDetection()=default
Destroy the traffic light detection object.
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
class register implement
Definition arena_queue.h:37