Apollo  6.0
Open source self driving car software
classify.h
Go to the documentation of this file.
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 <memory>
19 #include <string>
20 #include <vector>
21 
26 #include "modules/perception/camera/lib/traffic_light/detector/recognition/proto/recognition.pb.h"
28 
29 namespace apollo {
30 namespace perception {
31 namespace camera {
32 
34  public:
35  ClassifyBySimple() = default;
36  ~ClassifyBySimple() = default;
37 
38  void Init(const traffic_light::recognition::ClassifyParam& model_config,
39  const int gpu_id, const std::string work_root);
40 
41  void Perform(const CameraFrame* frame,
42  std::vector<base::TrafficLightPtr>* lights);
43 
44  private:
45  void Prob2Color(const float* out_put_data, float threshold,
46  base::TrafficLightPtr light);
47  std::shared_ptr<inference::Inference> rt_net_ = nullptr;
48  DataProvider::ImageOptions data_provider_image_option_;
49  std::shared_ptr<base::Image8U> image_ = nullptr;
50  std::shared_ptr<base::Blob<float>> mean_buffer_;
51  std::shared_ptr<base::Blob<float>> mean_;
52  std::vector<std::string> net_inputs_;
53  std::vector<std::string> net_outputs_;
54  int resize_width_;
55  int resize_height_;
56  float unknown_threshold_;
57  float scale_;
58  int gpu_id_ = 0;
59 };
60 
61 } // namespace camera
62 } // namespace perception
63 } // namespace apollo
Definition: camera_frame.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::shared_ptr< TrafficLight > TrafficLightPtr
Definition: traffic_light.h:88
void Perform(const CameraFrame *frame, std::vector< base::TrafficLightPtr > *lights)
Image< uchar > * threshold(Image< T > *src, int t)
Definition: imutil.h:63
void Init(const traffic_light::recognition::ClassifyParam &model_config, const int gpu_id, const std::string work_root)