Apollo 11.0
自动驾驶开放平台
util.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
18namespace apollo {
19namespace perception {
20namespace lidar {
21
22enum class MetaType {
23 META_UNKNOWN = 0,
24 META_SMALLMOT = 1,
25 META_BIGMOT = 2,
26 META_NONMOT = 3,
29};
30
31const double kPI = 3.1415926535897932384626433832795;
32
33inline int F2I(float val, float ori, float scale) {
34 return static_cast<int>(std::floor((ori - val) * scale));
35}
36
37// for axis rotated case
38inline void GroupPc2Pixel(float pc_x, float pc_y, float scale, float range,
39 int* x, int* y) {
40 float fx = (range - (0.707107f * (pc_x + pc_y))) * scale;
41 float fy = (range - (0.707107f * (pc_x - pc_y))) * scale;
42 *x = fx < 0 ? -1 : static_cast<int>(fx);
43 *y = fy < 0 ? -1 : static_cast<int>(fy);
44}
45
46// for axis aligned case
47inline int Pc2Pixel(float in_pc, float in_range, float out_size) {
48 float inv_res = 0.5f * out_size / in_range;
49 return static_cast<int>(std::floor((in_range - in_pc) * inv_res));
50}
51
52inline float Pixel2Pc(int in_pixel, float in_size, float out_range) {
53 float res = 2.0f * out_range / in_size;
54 return out_range - (static_cast<float>(in_pixel) + 0.5f) * res;
55}
56
57} // namespace lidar
58} // namespace perception
59} // namespace apollo
int Pc2Pixel(float in_pc, float in_range, float out_size)
Definition util.h:47
int F2I(float val, float ori, float scale)
Definition util.h:33
float Pixel2Pc(int in_pixel, float in_size, float out_range)
Definition util.h:52
const double kPI
Definition util.h:31
void GroupPc2Pixel(float pc_x, float pc_y, float scale, float range, int *x, int *y)
Definition util.h:38
class register implement
Definition arena_queue.h:37