Apollo  v5.5.0
Open source self driving car software
darkSCNN_lane_postprocessor.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 <string>
19 #include <vector>
20 #include "opencv2/opencv.hpp"
21 
27 #include "modules/perception/camera/lib/lane/common/darkSCNN.pb.h"
28 #include "modules/perception/camera/lib/lane/postprocessor/darkSCNN/darkSCNN_postprocessor.pb.h"
30 
31 namespace apollo {
32 namespace perception {
33 namespace camera {
34 
36  public:
38 
40 
41  bool Init(const LanePostprocessorInitOptions& options =
42  LanePostprocessorInitOptions()) override;
43 
44  // @brief: detect lane from image.
45  // @param [in]: options
46  // @param [in/out]: frame
47  // detected lanes should be filled, required,
48  // 3D information of lane can be filled, optional.
49  bool Process2D(const LanePostprocessorOptions& options,
50  CameraFrame* frame) override;
51  // convert image point to the camera coordinate
52  // & fit the line using polynomial
53  bool Process3D(const LanePostprocessorOptions& options,
54  CameraFrame* frame) override;
55 
56  void SetIm2CarHomography(Eigen::Matrix3d homography_im2car) override {
57  trans_mat_ = homography_im2car.cast<float>();
58  trans_mat_inv = trans_mat_.inverse();
59  }
60 
61  std::string Name() const override;
62 
63  std::vector<std::vector<LanePointInfo>> GetLanelinePointSet();
64  std::vector<LanePointInfo> GetAllInferLinePointSet();
65 
66  private:
67  void ConvertImagePoint2Camera(CameraFrame* frame);
68  // @brief: fit camera lane line using polynomial
69  void PolyFitCameraLaneline(CameraFrame* frame);
70 
71  private:
72  int input_offset_x_ = 0;
73  int input_offset_y_ = 312;
74  int lane_map_width_ = 640;
75  int lane_map_height_ = 480;
76 
77  // this is actually the search range at the original image resolution
78  int roi_height_ = 768;
79  int roi_start_ = 312;
80  int roi_width_ = 1920;
81 
82  // minimum number to fit a curve
83  size_t minNumPoints_ = 8;
84 
85  int64_t time_1 = 0;
86  int64_t time_2 = 0;
87  int64_t time_3 = 0;
88  int time_num = 0;
89 
90  float max_longitudinal_distance_ = 300.0f;
91  float min_longitudinal_distance_ = 0.0f;
92 
93  // number of lane type (13)
94  int lane_type_num_;
95 
96  lane::DarkSCNNLanePostprocessorParam lane_postprocessor_param_;
97 
98  private:
99  Eigen::Matrix<float, 3, 3> trans_mat_;
100  Eigen::Matrix<float, 3, 3> trans_mat_inv;
101  // xy points for the ground plane, uv points for image plane
102  std::vector<std::vector<Eigen::Matrix<float, 2, 1>>> xy_points;
103  std::vector<std::vector<Eigen::Matrix<float, 2, 1>>> uv_points;
104 };
105 
106 } // namespace camera
107 } // namespace perception
108 } // namespace apollo
Definition: camera_frame.h:33
std::vector< std::vector< LanePointInfo > > GetLanelinePointSet()
bool Process3D(const LanePostprocessorOptions &options, CameraFrame *frame) override
Definition: blob.h:72
virtual ~DarkSCNNLanePostprocessor()
Definition: darkSCNN_lane_postprocessor.h:39
Definition: darkSCNN_lane_postprocessor.h:35
bool Process2D(const LanePostprocessorOptions &options, CameraFrame *frame) override
void SetIm2CarHomography(Eigen::Matrix3d homography_im2car) override
Definition: darkSCNN_lane_postprocessor.h:56
bool Init(const LanePostprocessorInitOptions &options=LanePostprocessorInitOptions()) override
std::vector< LanePointInfo > GetAllInferLinePointSet()
Definition: base_lane_postprocessor.h:36
Definition: base_lane_postprocessor.h:34
DarkSCNNLanePostprocessor()
Definition: darkSCNN_lane_postprocessor.h:37
Definition: base_lane_postprocessor.h:29