Apollo 11.0
自动驾驶开放平台
lr_classifier.h
浏览该文件的文档.
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 <algorithm>
19#include <cmath>
20#include <cstdlib>
21#include <iostream>
22#include <limits>
23#include <map>
24#include <string>
25#include <tuple>
26#include <unordered_set>
27#include <vector>
28
29#include "Eigen/Core"
30
32
33namespace apollo {
34namespace perception {
35namespace lidar {
36
38public:
39 LRClassifier() = default;
47 bool init() {
48 _lr_parameters.resize(3, 4);
49 _lr_parameters.coeffRef(0, 0) = 0.0510903f;
50 _lr_parameters.coeffRef(0, 1) = -1.00989f;
51 _lr_parameters.coeffRef(0, 2) = -1.6537f;
52 _lr_parameters.coeffRef(0, 3) = 0.130055f;
53 _lr_parameters.coeffRef(1, 0) = 0.266469f;
54 _lr_parameters.coeffRef(1, 1) = -0.538964f;
55 _lr_parameters.coeffRef(1, 2) = -0.291611f;
56 _lr_parameters.coeffRef(1, 3) = -0.070701f;
57 _lr_parameters.coeffRef(2, 0) = 0.497949f;
58 _lr_parameters.coeffRef(2, 1) = -0.504843f;
59 _lr_parameters.coeffRef(2, 2) = -0.152141f;
60 _lr_parameters.coeffRef(2, 3) = -1.38024f;
61 return true;
62 }
70 // point cloud should be rotated
71 float x_max = -std::numeric_limits<float>::max();
72 float y_max = -std::numeric_limits<float>::max();
73 float z_max = -std::numeric_limits<float>::max();
74 float x_min = std::numeric_limits<float>::max();
75 float y_min = std::numeric_limits<float>::max();
76 float z_min = std::numeric_limits<float>::max();
77 for (size_t i = 0; i < cloud->size(); ++i) {
78 auto pt = (*cloud)[i];
79 x_min = std::min(x_min, pt.x);
80 x_max = std::max(x_max, pt.x);
81 y_min = std::min(y_min, pt.y);
82 y_max = std::max(y_max, pt.y);
83 z_min = std::min(z_min, pt.z);
84 z_max = std::max(z_max, pt.z);
85 }
86 Eigen::Vector3f fea = {x_max - x_min, y_max - y_min, z_max - z_min};
87 Eigen::VectorXf response = fea.transpose() * _lr_parameters;
88 int type = 0;
89 response.maxCoeff(&type);
90 return _labels[type];
91 }
92
93private:
94 Eigen::MatrixXf _lr_parameters;
95 std::vector<std::string> _labels = {"unknown", "nonMot", "pedestrian", "smallMot"};
96};
97
98} // namespace lidar
99} // namespace perception
100} // namespace apollo
std::string GetLabel(base::PointFCloudConstPtr cloud)
Get the label of object
std::shared_ptr< const PointFCloud > PointFCloudConstPtr
class register implement
Definition arena_queue.h:37