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