Apollo 11.0
自动驾驶开放平台
efficient_net.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2024 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 <algorithm>
19#include <memory>
20#include <string>
21#include <vector>
22#include <map>
23
24#include "cyber/common/macros.h"
27#include "modules/perception/traffic_light_recognition/recognition/efficient_net/proto/efficient_net_param.pb.h"
28
29namespace apollo {
30namespace perception {
31namespace trafficlight {
32
34public:
52 bool Init(const TrafficLightRecognitorInitOptions& options) override;
53
61 bool Detect(camera::TrafficLightFrame* frame) override;
62
63private:
64 bool InitModel();
65 void Perform(const camera::TrafficLightFrame* frame, std::vector<base::TrafficLightPtr>* lights);
66 void ZeroPadding(
67 const base::RectI& light_roi,
68 base::Image8U* roi_tmp_image,
69 int* dst_width,
70 int* dst_height,
71 const int& provider_w,
72 const int& provider_h);
73 void Prob2Color(const float* output_data, float threshold, base::TrafficLightPtr light);
74
75private:
76 // input/output blobs
77 std::shared_ptr<base::Blob<float>> input_blob_;
78 std::shared_ptr<base::Blob<float>> outputs_cls_;
79 std::shared_ptr<base::Blob<float>> outputs_status_;
80 // image
81 std::shared_ptr<base::Image8U> image_ = nullptr;
82 std::shared_ptr<base::Blob<float>> mean_buffer_;
83 std::shared_ptr<base::Blob<float>> mean_;
84 camera::DataProvider::ImageOptions data_provider_image_option_;
85 // gpu id
86 int gpu_id_;
87 cudaStream_t stream_ = nullptr;
88 EfficientNetParam model_param_;
89 std::shared_ptr<inference::Inference> inference_;
90
91 // image shape
92 int resize_height_;
93 int resize_width_;
94 float unknown_threshold_;
95 float scale_;
96
98};
99
100} // namespace trafficlight
101} // namespace perception
102} // namespace apollo
A wrapper around Blob holders serving as the basic computational unit for images.
Definition image_8u.h:44
~EfficientNetRecognition()=default
Destroy the Traffic Light Recognition object
EfficientNetRecognition()=default
Construct a new Traffic Light Recognition object
bool Init(const TrafficLightRecognitorInitOptions &options) override
Initialize traffic light recognitor parameters.
bool Detect(camera::TrafficLightFrame *frame) override
recogn traffic_light from image.
#define DISALLOW_COPY_AND_ASSIGN(classname)
Definition macros.h:48
std::shared_ptr< TrafficLight > TrafficLightPtr
class register implement
Definition arena_queue.h:37