Apollo 10.0
自动驾驶开放平台
apollo::perception::camera::CaddnObstacleDetector类 参考

#include <caddn_obstacle_detector.h>

类 apollo::perception::camera::CaddnObstacleDetector 继承关系图:
apollo::perception::camera::CaddnObstacleDetector 的协作图:

Public 成员函数

 CaddnObstacleDetector ()=default
 
virtual ~CaddnObstacleDetector ()=default
 
bool Init (const ObstacleDetectorInitOptions &options=ObstacleDetectorInitOptions()) override
 Init function for CaddnObstacleDetector
 
bool Detect (onboard::CameraFrame *frame) override
 Main part to detect obstacle
 
std::string Name () const override
 Interface for obstacle detector name
 
- Public 成员函数 继承自 apollo::perception::camera::BaseObstacleDetector
 BaseObstacleDetector ()=default
 
virtual ~BaseObstacleDetector ()=default
 
virtual bool Detect (CameraFrame *frame)=0
 Interface for obstacle detector main part
 
virtual bool InitNetwork (const common::ModelInfo &model_info, const std::string &model_root)
 Interface for network initialization
 
 BaseObstacleDetector ()=default
 
virtual ~BaseObstacleDetector ()=default
 
virtual bool Detect (CameraFrame *frame)=0
 Interface for obstacle detector main part
 
virtual bool InitNetwork (const common::ModelInfo &model_info, const std::string &model_root)
 Interface for network initialization
 
 BaseObstacleDetector ()=default
 
virtual ~BaseObstacleDetector ()=default
 
virtual bool InitNetwork (const common::ModelInfo &model_info, const std::string &model_root)
 Interface for network initialization
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::perception::camera::BaseObstacleDetector
 DISALLOW_COPY_AND_ASSIGN (BaseObstacleDetector)
 
 DISALLOW_COPY_AND_ASSIGN (BaseObstacleDetector)
 
 DISALLOW_COPY_AND_ASSIGN (BaseObstacleDetector)
 
- Protected 属性 继承自 apollo::perception::camera::BaseObstacleDetector
int gpu_id_ = 0
 
std::shared_ptr< inference::Inferencenet_
 

详细描述

在文件 caddn_obstacle_detector.h33 行定义.

构造及析构函数说明

◆ CaddnObstacleDetector()

apollo::perception::camera::CaddnObstacleDetector::CaddnObstacleDetector ( )
default

◆ ~CaddnObstacleDetector()

virtual apollo::perception::camera::CaddnObstacleDetector::~CaddnObstacleDetector ( )
virtualdefault

成员函数说明

◆ Detect()

bool apollo::perception::camera::CaddnObstacleDetector::Detect ( onboard::CameraFrame frame)
overridevirtual

Main part to detect obstacle

参数
framecamera frame
返回
true
false

实现了 apollo::perception::camera::BaseObstacleDetector.

在文件 caddn_obstacle_detector.cc131 行定义.

131 {
132 if (frame == nullptr) {
133 return false;
134 }
135
136 // Inputs
137 auto model_inputs = model_param_.info().inputs();
138 auto input_image_blob = net_->get_blob(model_inputs[0].name());
139 auto input_cam2img_blob = net_->get_blob(model_inputs[1].name());
140 auto input_lidar2cam_blob = net_->get_blob(model_inputs[2].name());
141
142 const auto &camera_k_matrix = options_.intrinsic;
143 float *input_cam_intrinsic = input_cam2img_blob->mutable_cpu_data();
144 for (size_t i = 0; i < 3; ++i) {
145 for (size_t j = 0; j < 4; ++j) {
146 if (3 == j) {
147 input_cam_intrinsic[i * 4 + j] = 0.0;
148 } else {
149 input_cam_intrinsic[i * 4 + j] = camera_k_matrix(i, j);
150 }
151 }
152 }
153
154 float *input_lidar2cam_data = input_lidar2cam_blob->mutable_cpu_data();
155 for (int i = 0; i < 16; ++i) {
156 input_lidar2cam_data[i] = lidar_to_cam_[i];
157 }
158
159 DataProvider::ImageOptions image_options;
160 image_options.target_color = base::Color::BGR;
161 std::shared_ptr<base::Image8U> image = std::make_shared<base::Image8U>();
162 frame->data_provider->GetImage(image_options, image.get());
163
164 Preprocess(image.get(), input_image_blob);
165
166 // Infer
167 net_->Infer();
168
169 // Outputs
170 auto model_outputs = model_param_.info().outputs();
171 auto out_detections = net_->get_blob(model_outputs[0].name());
172 auto out_labels = net_->get_blob(model_outputs[1].name());
173 auto out_scores = net_->get_blob(model_outputs[2].name());
174
175 // todo(daohu527): The caddn model currently does not output tracking features
176 // appearance features for tracking
177 // frame->feature_blob = net_->get_blob(model_outputs[3].name());
178
179 GetCaddnObjects(&frame->detected_objects, model_param_, types_,
180 out_detections, out_labels, out_scores);
181
182 return true;
183}
std::shared_ptr< inference::Inference > net_
void GetCaddnObjects(std::vector< base::ObjectPtr > *objects, const caddn::ModelParam &model_param, const std::vector< base::ObjectSubType > &types, const base::BlobPtr< float > &boxes, const base::BlobPtr< float > &labels, const base::BlobPtr< float > &scores)
Get the Caddn Objects objects from Blob

◆ Init()

bool apollo::perception::camera::CaddnObstacleDetector::Init ( const ObstacleDetectorInitOptions options = ObstacleDetectorInitOptions())
overridevirtual

Init function for CaddnObstacleDetector

参数
optionsconfiguration options
返回
true
false

实现了 apollo::perception::camera::BaseObstacleDetector.

在文件 caddn_obstacle_detector.cc73 行定义.

73 {
74 options_ = options;
75 std::string config_file =
76 GetConfigFile(options_.config_path, options_.config_file);
77 if (!cyber::common::GetProtoFromFile(config_file, &model_param_)) {
78 AERROR << "Read model param failed!";
79 return false;
80 }
81
82 InitImageSize(model_param_);
83 InitParam(model_param_);
84 InitTypes(model_param_);
85
86 const auto &model_info = model_param_.info();
87 std::string model_path = GetModelPath(model_info.name());
88 if (!InitNetwork(model_param_.info(), model_path)) {
89 AERROR << "Init network failed!";
90 return false;
91 }
92 return true;
93}
virtual bool InitNetwork(const common::ModelInfo &model_info, const std::string &model_root)
Interface for network initialization
#define AERROR
Definition log.h:44
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::string GetConfigFile(const std::string &config_path, const std::string &config_file)
Definition util.cc:80
std::string GetModelPath(const std::string &model_name)
Get the model path by model name, search from APOLLO_MODEL_PATH
Definition util.cc:44

◆ Name()

std::string apollo::perception::camera::CaddnObstacleDetector::Name ( ) const
inlineoverridevirtual

Interface for obstacle detector name

返回
std::string

实现了 apollo::perception::camera::BaseObstacleDetector.

在文件 caddn_obstacle_detector.h55 行定义.

55{ return "CaddnObstacleDetector"; }

该类的文档由以下文件生成: