Apollo 10.0
自动驾驶开放平台
yolox3d_obstacle_detector.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 <map>
20#include <memory>
21#include <string>
22#include <utility>
23#include <vector>
24
25#include <opencv2/imgproc.hpp>
26#include <opencv2/opencv.hpp>
27
28#include "modules/perception/camera_detection_multi_stage/detector/yolox3d/proto/model_param.pb.h"
29
34
35namespace apollo {
36namespace perception {
37namespace camera {
38
40 public:
43 if (stream_ != nullptr) {
44 cudaStreamDestroy(stream_);
45 }
46 }
47
54 bool Init(const ObstacleDetectorInitOptions &options =
56
61 bool Detect(onboard::CameraFrame *frame) override;
62
68 std::string Name() const override { return "Yolox3DObstacleDetector"; }
69
70 protected:
78 bool Preprocess(const base::Image8U *image, base::BlobPtr<float> input_blob);
79
86 void LoadInputShape(const yolox3d::ModelParam &model_param);
87
94 void LoadParam(const yolox3d::ModelParam &model_param);
102 void Yolo3DInference(const base::Image8U *image, base::ObjectPtr obj);
111 bool Init3DNetwork(const common::ModelInfo &model_info,
112 const std::string &model_path);
113
114 private:
116 yolox3d::ModelParam model_param_;
118
119 std::shared_ptr<inference::Inference> net_3D_;
120 FILE *file_;
121
122 int gpu_id_ = 0;
123 cudaStream_t stream_ = nullptr;
124
125 // yolo input image size
126 int width_ = 0;
127 int height_ = 0;
128 // image size of raw image
129 int image_width_ = 0;
130 int image_height_ = 0;
131 float confidence_threshold_ = 0.f;
132
133 float border_ratio_ = 0.f;
134 cv::Mat img_;
135};
136
137} // namespace camera
138} // namespace perception
139} // namespace apollo
A wrapper around Blob holders serving as the basic computational unit for images.
Definition image_8u.h:44
bool Init(const ObstacleDetectorInitOptions &options=ObstacleDetectorInitOptions()) override
Necessary, Init yolox3d model params normal, but now use pipline instead
std::string Name() const override
return detector name
bool Detect(onboard::CameraFrame *frame) override
Detect stage
bool Init3DNetwork(const common::ModelInfo &model_info, const std::string &model_path)
Init model inference
void LoadInputShape(const yolox3d::ModelParam &model_param)
Resize model input picture size according to the config file
void LoadParam(const yolox3d::ModelParam &model_param)
Load yolo libtorch model params from model file
bool Preprocess(const base::Image8U *image, base::BlobPtr< float > input_blob)
Preprocess of image before inference, resize input data blob and fill image data to blob
void Yolo3DInference(const base::Image8U *image, base::ObjectPtr obj)
Load yolo3D libtorch model params from model file
std::shared_ptr< Object > ObjectPtr
Definition object.h:127
std::shared_ptr< Blob< Dtype > > BlobPtr
Definition blob.h:313
class register implement
Definition arena_queue.h:37