-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathVoxelization.hpp
More file actions
310 lines (273 loc) · 12.3 KB
/
Copy pathVoxelization.hpp
File metadata and controls
310 lines (273 loc) · 12.3 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// SPDX-License-Identifier: BSD-3-Clause-Clear
#ifndef QC_NODE_VOXELIZATION_HPP
#define QC_NODE_VOXELIZATION_HPP
#include "QC/Node/NodeBase.hpp"
namespace QC
{
namespace Node
{
/** @brief The QCNode Voxelization Version */
#define QCNODE_VOXELIZATION_VERSION_MAJOR 2U
#define QCNODE_VOXELIZATION_VERSION_MINOR 1U
#define QCNODE_VOXELIZATION_VERSION_PATCH 0U
#define QCNODE_VOXELIZATION_VERSION \
( ( QCNODE_VOXELIZATION_VERSION_MAJOR << 16U ) | ( QCNODE_VOXELIZATION_VERSION_MINOR << 8U ) | \
QCNODE_VOXELIZATION_VERSION_PATCH )
/**
* @brief Represents the Voxelization implementation used by NodeVoxelization
*/
#define VOXELIZATION_PILLAR_COORDS_DIM 4u
/**
* @brief Represents the Voxelization implementation used by NodeVoxelization
*
* This class encapsulates the specific implementation details of the
* NodeVoxelization that are shared across configuration,
* monitoring, and Node Voxelization.
*
* It serves as a central reference for nodes that need to interact with
* the underlying Voxelization implementation.
*/
class VoxelizationImpl;
/**
* @brief Interface for Node Voxelization Configuration.
*
* This class provides an interface for configuring Voxelization nodes. It extends the NodeConfigIfs
* class and includes additional functionality specific to Voxelization configuration.
*/
class VoxelizationConfig : public NodeConfigIfs
{
public:
/**
* @brief Constructor for VoxelizationConfig.
* Initializes the VoxelizationConfig with a logger and a VoxelizationImpl object.
* @param[in] logger A reference to the logger to be shared and used by VoxelizationConfig.
* @param[in] pVoxelImpl A reference to the VoxelizationImpl object to be used by
* VoxelizationConfig.
*/
VoxelizationConfig( Logger &logger, VoxelizationImpl *pVoxelImpl )
: NodeConfigIfs( logger ),
m_pVoxelImpl( pVoxelImpl )
{}
/**
* @brief Destructor for VoxelizationConfig.
*/
~VoxelizationConfig() {}
/**
* @brief Verify the configuration string and set the configuration structure.
* This method verifies the provided configuration string and sets the configuration structure.
* The configuration string is expected to be in JSON format.
* @param[in] config The configuration string in JSON format.
* @param[out] errors The error string returned if there is an error.
* @return QC_STATUS_OK on success, other values on failure.
* @note The config is a JSON string according to the templates below.
* Example of static configuration used for initialization:
* @code
* {
* "static": {
* "name": "The Node unique name, type: string",
* "id": "The Node unique ID, type: uint32_t",
* "processorType": "The processor type, type: string, options: [htp0, htp1, cpu, gpu],
* default: htp0",
* "Xsize": "Pillar size in X direction in meters, type: float",
* "Ysize": "Pillar size in Y direction in meters, type: float",
* "Zsize": "Pillar size in Z direction in meters, type: float",
* "Xmin": "Minimum range value in X direction, type: float",
* "Ymin": "Minimum range value in Y direction, type: float",
* "Zmin": "Minimum range value in Z direction, type: float",
* "Xmax": "Maximum range value in X direction, type: float",
* "Ymax": "Maximum range value in Y direction, type: float",
* "Zmax": "Maximum range value in Z direction, type: float",
* "maxPointNum": "Maximum number of points in input point cloud, type: uint32_t",
* "maxPlrNum": "Maximum number of point pillars that can be created, type: uint32_t",
* "maxPointNumPerPlr": "Maximum number of points to map to each pillar,
* type: uint32_t",
* "inputMode": "Voxelization input pointclouds type, type: string,
* options: [xyzr, xyzrt], default: xyzr",
* "outputFeatureDimNum": "Number of features for each point in output point pillars,
* type: uint32_t",
* "inputPcdBufferIds": "[ A list of uint32_t values representing the indices of input
* pointcloud buffers in QCNodeInit::buffers ]",
* "outputPlrBufferIds": "[ A list of uint32_t values representing the indices of output
* pillar buffers in QCNodeInit::buffers ]",
* "outputFeatureBufferIds": "[ A list of uint32_t values representing the indices of
* output feature buffers in QCNodeInit::buffers ]",
* "plrPointsBufferId": "The index of buffer for maximal pliiar point number in
* QCNodeInit::buffers, type: uint32_t",
* "coordToPlrIdxBufferId": "The index of buffer to store coordinate to pillar point
* transform indices in QCNodeInit::buffers, type: uint32_t",
* "globalBufferIdMap": [
* {
* "name": "The buffer name, type: string",
* "id": "The index to a buffer in QCFrameDescriptorNodeIfs, type: uint32_t"
* }
* ],
* "deRegisterAllBuffersWhenStop": "Flag to deregister all buffers when stopped,
* type: bool, default: false"
* }
* }
* @endcode
*
* @note:
* plrPointsBufferId and coordToPlrIdxBufferId is only needed while the processorType is gpu.
* globalBufferIdMap is optional. If not set, this config will be set to default.
*/
virtual QCStatus_e VerifyAndSet( const std::string config, std::string &errors );
/**
* @brief Get the configuration options as a string.
* @return A reference to the configuration options string.
*/
virtual const std::string &GetOptions();
/**
* @brief Get the base configuration structure.
* @return A reference to the base configuration structure
*/
virtual const QCNodeConfigBase_t &Get();
private:
QCStatus_e VerifyStaticConfig( DataTree &dt, std::string &errors );
QCStatus_e ParseStaticConfig( DataTree &dt, std::string &errors );
QCStatus_e GetInputMode( std::string &mode );
private:
VoxelizationImpl *m_pVoxelImpl;
std::string m_options;
};
/**
* @brief Interface for Node Voxelization Monitor.
* This class provides an interface for monitoring Voxelization nodes. It extends the
* QCNodeMonitoringIfs class and includes additional functionality specific to VoxelizationMonitor.
*/
class VoxelizationMonitor : public QCNodeMonitoringIfs
{
public:
/**
* @brief Constructor for VoxelizationMonitor.
* Initializes the VoxelizationMonitor with a logger and a VoxelizationImpl object.
* @param[in] logger A reference to the logger to be shared and used by
* VoxelizationMonitor.
* @param[in] cam A reference to the VoxelizationImpl object to be
* used by VoxelizationMonitor.
*/
VoxelizationMonitor( Logger &logger, VoxelizationImpl *pVoxelImpl )
: m_pVoxelImpl( pVoxelImpl ),
m_logger( logger )
{}
/**
* @brief Destructor for VoxelizationMonitor.
*/
~VoxelizationMonitor() {}
/**
* @brief Verify the configuration string and set the configuration structure.
* This method verifies the provided configuration string and sets the configuration structure.
* Currently, this functionality is unsupported.
* @param[in] config The configuration string in JSON format.
* @param[out] errors The error string returned if there is an error.
* @return QC_STATUS_UNSUPPORTED as this functionality is not supported.
*/
virtual QCStatus_e VerifyAndSet( const std::string config, std::string &errors );
/**
* @brief Get the QCNode monitoring options as a string.
* @return A reference to the QCNode monitoring options string.
*/
virtual const std::string &GetOptions();
/**
* @brief Get the base QCNode monitoring structure.
* @return A reference to the base QCNode monitoring structure
*/
virtual const QCNodeMonitoringBase_t &Get();
/**
* @brief Get the maximal size of the monitoring data in bytes.
* @return The maximal size of the monitoring data in bytes.
*/
virtual inline uint32_t GetMaximalSize() { return 0; }
/**
* @brief Get the current size of the monitoring data in bytes.
* @return The current size of the monitoring data in bytes.
*/
virtual inline uint32_t GetCurrentSize() { return 0; }
/**
* @brief Place monitoring data.
* This method places the monitoring data. Currently, this functionality is unsupported.
* @param[in] pData Pointer to the data to be placed.
* @param[in, out] size The size of the data to be placed.
* @return QC_STATUS_UNSUPPORTED as this functionality is not supported.
*/
virtual QCStatus_e Place( void *pData, uint32_t &size ) { return QC_STATUS_UNSUPPORTED; }
private:
VoxelizationImpl *m_pVoxelImpl;
Logger &m_logger;
std::string m_options;
};
/**
* @brief Node Voxelization Interface.
* This class provides an interface for Voxelization nodes. It extends the NodeBase class and
* includes functionality for initializing, starting, processing frames, and stopping the
* Voxelization node.
*/
class Voxelization : public NodeBase
{
public:
/**
* @brief Constructor for Voxelization.
* Initializes the Voxelization object.
*/
Voxelization();
/**
* @brief Destructor for Voxelization.
*/
~Voxelization();
/**
* @brief Initialize the voxelization node.
* This method initializes the Voxelization node with the provided configuration.
* @param[in] config The configuration structure for node initialization.
* @return QC_STATUS_OK on success, other values on failure.
*/
virtual QCStatus_e Initialize( QCNodeInit_t &config );
/**
* @brief Get the configuration interface.
* @return A reference to the configuration interface.
*/
virtual QCNodeConfigIfs &GetConfigurationIfs() { return m_configIfs; }
/**
* @brief Get the monitoring interface.
* @return A reference to the monitoring interface.
*/
virtual QCNodeMonitoringIfs &GetMonitoringIfs() { return m_monitor; }
/**
* @brief Start the voxelization node.
* @return QC_STATUS_OK on success, other values on failure.
*/
virtual QCStatus_e Start();
/**
* @brief Process the provided frame descriptor.
* @param[in] frameDesc The frame descriptor containing a vector of input/output buffers.
* @note The voxelization pipeline has 1 input and 2 outputs.
* The input is point cloud with size of maxPointNum x inputFeatureDimNum x sizeof(float).
* The 1st output is pillar index tensor with size of 4 x maxPlrNum x sizeof(float).
* The 2nd output is stacked pillar tensor with size of maxPlrNum * maxPointNumPerPlr *
* outputFeatureDimNum * sizeof(float).
* @return QC_STATUS_OK on success, other values on failure.
*/
virtual QCStatus_e ProcessFrameDescriptor( QCFrameDescriptorNodeIfs &frameDesc );
/**
* @brief Stop the voxelization node.
* @return QC_STATUS_OK on success, other values on failure.
*/
virtual QCStatus_e Stop();
/**
* @brief Deinitialize the voxelization node.
* @return QC_STATUS_OK on success, other values on failure.
*/
virtual QCStatus_e DeInitialize();
/**
* @brief Get the current state of the voxelization node.
* @return The current state of the voxelization node.
*/
virtual QCObjectState_e GetState();
private:
VoxelizationImpl *m_pVoxelImpl;
VoxelizationConfig m_configIfs;
VoxelizationMonitor m_monitor;
};
} // namespace Node
} // namespace QC
#endif // QC_NODE_VOXELIZATION_HPP