summaryrefslogtreecommitdiffstats
path: root/tests/manual/kinectsurface/QtKinectWrapper/OpenNI/Include/XnUtils.h
blob: 00b1222b78483c538c40d46632d878a2f6ab749f (plain)
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/****************************************************************************
*                                                                           *
*  OpenNI 1.x Alpha                                                         *
*  Copyright (C) 2011 PrimeSense Ltd.                                       *
*                                                                           *
*  This file is part of OpenNI.                                             *
*                                                                           *
*  OpenNI is free software: you can redistribute it and/or modify           *
*  it under the terms of the GNU Lesser General Public License as published *
*  by the Free Software Foundation, either version 3 of the License, or     *
*  (at your option) any later version.                                      *
*                                                                           *
*  OpenNI is distributed in the hope that it will be useful,                *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
*  GNU Lesser General Public License for more details.                      *
*                                                                           *
*  You should have received a copy of the GNU Lesser General Public License *
*  along with OpenNI. If not, see <http://www.gnu.org/licenses/>.           *
*                                                                           *
****************************************************************************/
#ifndef __XN_UTILS_H__
#define __XN_UTILS_H__

/**
 * @ingroup cref
 * @defgroup utils Utilities
 * This page details some utility functions.
 * @{
 */

//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnTypes.h>
#include <XnModuleInterface.h>

//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------

/** 
 * @name General
 * @{
 */

/**
 * Gets current OpenNI version
 *
 * @param	pVersion	[out]	Current DLL version
 */
XN_C_API XnStatus XN_C_DECL xnGetVersion(XnVersion* pVersion);

/// @}

/**
 * @name ProductionNodeType Utils
 * @{
 */

/**
 * Gets a string representation of the production node type.
 *
 * @param	Type	[in]	The type of the production node.
 */
XN_C_API const XnChar* XN_C_DECL xnProductionNodeTypeToString(XnProductionNodeType Type);

/**
 * Gets a type from its string representation.
 *
 * @param	strType	[in]	The string representation of the type.
 * @param	pType	[out]	The type of the production node.
 */
XN_C_API XnStatus XN_C_DECL xnProductionNodeTypeFromString(const XnChar* strType, XnProductionNodeType* pType);

/**
 * @brief Checks if a certain production node type is a generator or not
 *
 * @param	type	[in]	The type to check
 */
XN_C_API XnBool XN_C_DECL xnIsTypeGenerator(XnProductionNodeType type);

/**
 * @brief Checks if a certain production node type is a derived of another type
 *
 * @param	type	[in]	The type to check
 * @param	base	[in]	The base type to check against
 */
XN_C_API XnBool XN_C_DECL xnIsTypeDerivedFrom(XnProductionNodeType type, XnProductionNodeType base);

/// @}

/**
 * @name PixelFormat Utils
 * @{
 */

/**
 * Get the name of the pixel format.
 *
 * @param	format [in]	Pixel Format
 */
XN_C_API const XnChar* XN_C_DECL xnPixelFormatToString(XnPixelFormat format);

/**
 * Gets pixel format by its name.
 *
 * @param	strName	[in]	Name of the pixel format.
 * @param	pFormat	[out]	Pixel format.
 */
XN_C_API XnStatus XN_C_DECL xnPixelFormatFromString(const XnChar* strName, XnPixelFormat* pFormat);

/**
 * Gets the bytes per pixel of a pixel format.
 *
 * @param	format	[in]	The pixel format.
 */
XN_C_API XnUInt32 XN_C_DECL xnGetBytesPerPixelForPixelFormat(XnPixelFormat format);

/// @}

/**
 * @name Resolution Utilities
 * @{
 */

/**
 * Gets the number of pixels in a row for given resolution.
 *
 * @param	resolution	[in]	The resolution to translate.
 */
XN_C_API XnUInt32 XN_C_DECL xnResolutionGetXRes(XnResolution resolution);

/**
 * Gets the number of pixels in a column for given resolution.
 *
 * @param	resolution	[in]	The resolution to translate.
 */
XN_C_API XnUInt32 XN_C_DECL xnResolutionGetYRes(XnResolution resolution);

/**
 * Gets the resolution from the number of pixels in every row and column.
 *
 * @param	xRes	[in]	Number of pixels in a row.
 * @param	yRes	[in]	Number of pixels in a column.
 */
XN_C_API XnResolution XN_C_DECL xnResolutionGetFromXYRes(XnUInt32 xRes, XnUInt32 yRes);

/**
 * Gets resolution by its name. If resolution is unknown, XN_RESOLUTION_CUSTOM is returned.
 *
 * @param	strName	[in]	Name of the resolution.
 */
XN_C_API XnResolution XN_C_DECL xnResolutionGetFromName(const XnChar* strName);

/**
 * Get the name of the resolution.
 *
 * @param	resolution [in]	Resolution.
 */
XN_C_API const XnChar* XN_C_DECL xnResolutionGetName(XnResolution resolution);

/// @}

/**
 * @name XnVersion Utilities
 * @{
 */

/**
 * Compares two versions.
 *
 * @param	pVersion1	[in]	First version.
 * @param	pVersion2	[in]	Second version.
 *
 * @returns <0 if first is smaller than second, 0 if same, >0 if first is greater than second.
 */
XN_C_API XnInt32 XN_C_DECL xnVersionCompare(const XnVersion* pVersion1, const XnVersion* pVersion2);

XN_C_API XnStatus XN_C_DECL xnVersionToString(const XnVersion* pVersion, XnChar* csResult, XnUInt32 nSize);

/// @}

/**
 * @name XnProductionNodeDescription Utilities
 * @{
 */

XN_C_API XnStatus XN_C_DECL xnProductionNodeDescriptionToString(const XnProductionNodeDescription* pDescription, XnChar* csResult, XnUInt32 nSize);

/// @}

/**
 * @name C Style Constructors
 * @{
 */

XN_C_API XnPoint3D XN_C_DECL xnCreatePoint3D(XnFloat x, XnFloat y, XnFloat z);
XN_C_API XnPlane3D XN_C_DECL xnCreatePlane3D(XnPoint3D ptPoint, XnVector3D vNormal);

/// @}

/**
 * @name Modules Registry Management
 * @{
 */

XN_C_API XnStatus XN_C_DECL xnRegisterModule(const XnChar* strModule, const XnChar* strConfigDir);
XN_C_API XnStatus XN_C_DECL xnUnregisterModule(const XnChar* strModule);
XN_C_API XnStatus XN_C_DECL xnPrintRegisteredModules();

/// @}

/**
 * @name Global Licenses Registry Management
 * @{
 */

XN_C_API XnStatus XN_C_DECL xnRegisterGlobalLicense(XnLicense* pLicense);
XN_C_API XnStatus XN_C_DECL xnUnregisterGlobalLicense(XnLicense* pLicense);
XN_C_API XnStatus XN_C_DECL xnPrintRegisteredLicenses();

/// @}

/**
 * @name MetaData Objects Management
 * @{
 */

/**
 * Allocates and returns an @ref XnOutputMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeOutputMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnOutputMetaData* XN_C_DECL xnAllocateOutputMetaData();
/**
 * Frees a previously allocated @ref XnOutputMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeOutputMetaData(const XnOutputMetaData* pMetaData);
/**
 * @brief Shallow-Copies an Output Meta Data object.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyOutputMetaData(XnOutputMetaData* pDestination, const XnOutputMetaData* pSource);

/**
 * Allocates and returns an @ref XnMapMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeMapMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnMapMetaData* XN_C_DECL xnAllocateMapMetaData();
/**
 * Frees a previously allocated @ref XnMapMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeMapMetaData(const XnMapMetaData* pMetaData);
/**
 * @brief Shallow-Copies a Map Meta Data object.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyMapMetaData(XnMapMetaData* pDestination, const XnMapMetaData* pSource);

/**
 * Allocates and returns an @ref XnDepthMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeDepthMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnDepthMetaData* XN_C_DECL xnAllocateDepthMetaData();
/**
 * Frees a previously allocated @ref XnDepthMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeDepthMetaData(const XnDepthMetaData* pMetaData);
/**
 * @brief Shallow-Copies a Depth Meta Data object. Note that the data buffer is not copied, and that both
 * object will point to the same buffer.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyDepthMetaData(XnDepthMetaData* pDestination, const XnDepthMetaData* pSource);

/**
 * Allocates and returns an @ref XnImageMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeImageMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnImageMetaData* XN_C_DECL xnAllocateImageMetaData();
/**
 * Frees a previously allocated @ref XnImageMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeImageMetaData(const XnImageMetaData* pMetaData);
/**
 * @brief Shallow-Copies an Image Meta Data object. Note that the data buffer is not copied, and that both
 * object will point to the same buffer.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyImageMetaData(XnImageMetaData* pDestination, const XnImageMetaData* pSource);

/**
 * Allocates and returns an @ref XnIRMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeIRMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnIRMetaData* XN_C_DECL xnAllocateIRMetaData();
/**
 * Frees a previously allocated @ref XnIRMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeIRMetaData(const XnIRMetaData* pMetaData);
/**
 * @brief Shallow-Copies an IR Meta Data object. Note that the data buffer is not copied, and that both
 * object will point to the same buffer.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyIRMetaData(XnIRMetaData* pDestination, const XnIRMetaData* pSource);

/**
 * Allocates and returns an @ref XnAudioMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeAudioMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnAudioMetaData* XN_C_DECL xnAllocateAudioMetaData();
/**
 * Frees a previously allocated @ref XnAudioMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeAudioMetaData(const XnAudioMetaData* pMetaData);
/**
 * @brief Shallow-Copies an Audio Meta Data object. Note that the data buffer is not copied, and that both
 * object will point to the same buffer.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopyAudioMetaData(XnAudioMetaData* pDestination, const XnAudioMetaData* pSource);

/**
 * Allocates and returns an @ref XnSceneMetaData object. When no longer needed, this object should be freed
 * by calling @ref xnFreeSceneMetaData().
 * @returns NULL if allocation failed.
 */
XN_C_API XnSceneMetaData* XN_C_DECL xnAllocateSceneMetaData();
/**
 * Frees a previously allocated @ref XnSceneMetaData object.
 *
 * @param	pMetaData		[in]	object to be freed.
 */
XN_C_API void XN_C_DECL xnFreeSceneMetaData(const XnSceneMetaData* pMetaData);
/**
 * @brief Shallow-Copies a Scene Meta Data object. Note that the data buffer is not copied, and that both
 * object will point to the same buffer.
 *
 * @param	pDestination	[in]	Destination object.
 * @param	pSource			[in]	Source object.
 */
XN_C_API XnStatus XN_C_DECL xnCopySceneMetaData(XnSceneMetaData* pDestination, const XnSceneMetaData* pSource);

/// @}

/**
 * @name Functions for Modules Implementors
 * @{
 */

/**
 * A helper function for production nodes implementers. Enumerates needed child nodes (assuming there
 * is only one needed input), and populates a list with production trees over that input.
 *
 * @param	pContext		[in]	OpenNI Context.
 * @param	pList			[in]	The list to be populated.
 * @param	pDescription	[in]	The description of the enumerated node.
 * @param	strCreationInfo	[in]	[Optional] Additional creation info.
 * @param	InputType		[in]	The type of the input required by this production node.
 * @param	pErrors			[in]	The errors object passed to Enumerate method.
 * @param	pQuery			[in]	[Optional] A filter to be used for finding the appropriate input.
 */
XN_C_API XnStatus XN_C_DECL xnAutoEnumerateOverSingleInput(XnContext* pContext, XnNodeInfoList* pList, XnProductionNodeDescription* pDescription, const XnChar* strCreationInfo, XnProductionNodeType InputType, XnEnumerationErrors* pErrors, XnNodeQuery* pQuery);

/**
 * Registers an extension node with OpenNI. An extension node is a node of type not defined by OpenNI.
 *
 * @param	strTypeName		[in]	Name of this new node type.
 * @param	baseType		[in]	Type of the direct base for this extension.
 * @param	pTypeID			[out]	The new ID registered with OpenNI.
 */
XN_C_API XnStatus XN_C_DECL xnRegisterExtensionNode(const XnChar* strTypeName, XnProductionNodeType baseType, XnProductionNodeType* pTypeID);

/**
 * Gets the module node handle of a node. This is useful for extension implementors.
 *
 * @param	hNode			[in]	The node to get its module node handle.
 */
XN_C_API XnModuleNodeHandle XN_C_DECL xnGetModuleNodeHandle(XnNodeHandle hNode);

#if !XN_PLATFORM_SUPPORTS_DYNAMIC_LIBS
/**
 * Registers a module to OpenNI in environments where dynamic library loading is not supported.
 *
 * @param	pInterface		[in]	The module interface.
 * @param	strConfigDir	[in]	The module configuration directory.
 * @param	strName			[in]	Name of this module.
 */
XN_C_API XnStatus XN_C_DECL xnRegisterModuleWithOpenNI(XnOpenNIModuleInterface* pInterface, const XnChar* strConfigDir, const XnChar* strName);
#endif

/// @}

/** @} */

#endif // __XN_UTILS_H__