Apollo  6.0
Open source self driving car software
smoke_obstacle_detector.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2020 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 <utility>
22 #include <vector>
23 
24 #include "cyber/common/file.h"
30 #include "modules/perception/camera/lib/obstacle/detector/smoke/proto/smoke.pb.h"
36 
37 namespace apollo {
38 namespace perception {
39 namespace camera {
40 
42  public:
45  if (stream_ != nullptr) {
46  cudaStreamDestroy(stream_);
47  }
48  }
49 
50  bool Init(const ObstacleDetectorInitOptions &options =
51  ObstacleDetectorInitOptions()) override;
52 
53  bool Detect(const ObstacleDetectorOptions &options,
54  CameraFrame *frame) override;
55  std::string Name() const override { return "SmokeObstacleDetector"; }
56 
57  protected:
58  void LoadInputShape(const smoke::ModelParam &model_param);
59  void LoadParam(const smoke::SmokeParam &smoke_param);
60  bool InitNet(const smoke::SmokeParam &smoke_param,
61  const std::string &model_root);
62  void InitSmokeBlob(const smoke::NetworkParam &net_param);
63  bool InitFeatureExtractor(const std::string &root_dir);
64 
65  private:
66  std::shared_ptr<BaseFeatureExtractor> feature_extractor_;
67  smoke::SmokeParam smoke_param_;
68  std::shared_ptr<base::BaseCameraModel> base_camera_model_ = nullptr;
69  std::shared_ptr<inference::Inference> inference_;
70  std::vector<base::ObjectSubType> types_;
71  std::vector<float> expands_;
72  std::vector<float> anchors_;
73 
74  SmokeNMSParam nms_;
75  cudaStream_t stream_ = nullptr;
76  int height_ = 0;
77  int width_ = 0;
78  int offset_y_ = 0;
79  int gpu_id_ = 0;
80  // int obj_k_ = kMaxObjSize;
81  int obj_k_ = 1000;
82 
83  int ori_cycle_ = 1;
84  float confidence_threshold_ = 0.f;
85  float light_vis_conf_threshold_ = 0.f;
86  float light_swt_conf_threshold_ = 0.f;
87  SmokeMinDims min_dims_;
88  SmokeBlobs smoke_blobs_;
89 
90  std::shared_ptr<base::Image8U> image_ = nullptr;
91  std::shared_ptr<base::Blob<bool>> overlapped_ = nullptr;
92  std::shared_ptr<base::Blob<int>> idx_sm_ = nullptr;
93 
94  bool with_box3d_ = false;
95  bool with_frbox_ = false;
96  bool with_lights_ = false;
97  bool with_ratios_ = false;
98  bool with_area_id_ = false;
99  float border_ratio_ = 0.f;
100 };
101 
102 } // namespace camera
103 } // namespace perception
104 } // namespace apollo
virtual ~SmokeObstacleDetector()
Definition: smoke_obstacle_detector.h:44
Definition: camera_frame.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: base_obstacle_detector.h:37
std::string Name() const override
Definition: smoke_obstacle_detector.h:55
Definition: base_obstacle_detector.h:39
void LoadInputShape(const smoke::ModelParam &model_param)
bool Detect(const ObstacleDetectorOptions &options, CameraFrame *frame) override
void InitSmokeBlob(const smoke::NetworkParam &net_param)
void LoadParam(const smoke::SmokeParam &smoke_param)
Definition: region_output.h:64
bool InitFeatureExtractor(const std::string &root_dir)
SmokeObstacleDetector()
Definition: smoke_obstacle_detector.h:43
Definition: base_obstacle_detector.h:30
bool Init(const ObstacleDetectorInitOptions &options=ObstacleDetectorInitOptions()) override
Definition: region_output.h:75
Definition: region_output.h:72
bool InitNet(const smoke::SmokeParam &smoke_param, const std::string &model_root)
Definition: smoke_obstacle_detector.h:41