-
Notifications
You must be signed in to change notification settings - Fork 2
/
slanted_stixels.h
141 lines (118 loc) · 3.81 KB
/
slanted_stixels.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#ifndef __SLANTED_STIXELS_H__
#define __SLANTED_STIXELS_H__
#include <opencv2/core.hpp>
/** @brief Stixel geometric class id
*/
enum
{
GEOMETRIC_ID_GROUND = 0,
GEOMETRIC_ID_OBJECT = 1,
GEOMETRIC_ID_SKY = 2,
};
/** @brief Stixel struct
*/
struct Stixel
{
int uL; //!< stixel left x position
int vT; //!< stixel top y position
int vB; //!< stixel bottom y position
int width; //!< stixel width
int geoId; //!< stixel geometric class id
int semId; //!< stixel semantic class id
cv::Vec2f disp; //!< stixel disparity function (slope and intercept)
};
/** @brief CameraParameters struct
*/
struct CameraParameters
{
float fu; //!< focal length x (pixel)
float fv; //!< focal length y (pixel)
float u0; //!< principal point x (pixel)
float v0; //!< principal point y (pixel)
float baseline; //!< baseline (meter)
float height; //!< height position (meter)
float tilt; //!< tilt angle (radian)
// default settings
CameraParameters()
{
fu = 1.f;
fv = 1.f;
u0 = 0.f;
v0 = 0.f;
baseline = 0.2f;
height = 1.f;
tilt = 0.f;
}
};
/** @brief SlantedStixels class.
The class implements the Slanted Stixel computation based on [1][2].
[1] Hernandez-Juarez, Daniel, et al. "Slanted Stixels: A way to represent steep streets." International Journal of Computer Vision 127.11 (2019): 1643-1658.
[2] Hernandez-Juarez, Daniel, et al. "3D Perception with Slanted Stixels on GPU." IEEE Transactions on Parallel and Distributed Systems (2021).
*/
class SlantedStixels
{
public:
enum
{
STIXEL_WIDTH_4 = 4, //!< stixel width
STIXEL_WIDTH_8 = 8 //!< stixel width
};
enum
{
STIXEL_Y_RESOLUTION_4 = 4, //!< stixel vertical resolution
STIXEL_Y_RESOLUTION_8 = 8 //!< stixel vertical resolution
};
/** @brief Parameters struct
*/
struct Parameters
{
// disparity range
int dmin;
int dmax;
// stixel width
int stixelWidth;
// stixel vertical resolution
int stixelYResolution;
// camera parameters
CameraParameters camera;
// geometry id for each class
std::vector<int> geometry;
// default settings
Parameters()
{
// disparity range
dmin = 0;
dmax = 64;
// stixel width
stixelWidth = STIXEL_WIDTH_4;
// stixel vertical resolution
stixelYResolution = STIXEL_Y_RESOLUTION_4;
// camera parameters
camera = CameraParameters();
}
};
/** @brief Creates an instance of SlantedStixels.
@param param Input parameters.
*/
static cv::Ptr<SlantedStixels> create(const Parameters& param = Parameters());
/** @brief Computes slanted stixels from a disparity map and a disparity confidence.
@param disparity Input 32-bit disparity map.
@param confidence Input disparity confidence of the same size and the same type as disparity.
@param stixels Output array of stixels.
*/
virtual void compute(const cv::Mat& disparity, const cv::Mat& confidence,
std::vector<Stixel>& stixels) = 0;
/** @brief Computes slanted stixels from a disparity map and a disparity confidence.
@param disparity Input 32-bit disparity map.
@param confidence Input disparity confidence of the same size and the same type as disparity.
@param predict Input 32-bit 3-dimensional semantic segmentation scores.
@param stixels Output array of stixels.
*/
virtual void compute(const cv::Mat& disparity, const cv::Mat& confidence, const cv::Mat& predict,
std::vector<Stixel>& stixels) = 0;
/** @brief Sets parameters to SlantedStixels.
@param param Input parameters.
*/
virtual void setParameters(const Parameters& param) = 0;
};
#endif // !__SLANTED_STIXELS_H__