00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __XN_CPP_WRAPPER_H__
00027 #define __XN_CPP_WRAPPER_H__
00028
00029
00030
00031
00032 #include <XnOpenNI.h>
00033 #include <XnCodecIDs.h>
00034
00035
00036
00037
00038 namespace xn
00039 {
00040
00041
00042
00043 class ProductionNode;
00044 class EnumerationErrors;
00045 class NodeInfo;
00046 class NodeInfoList;
00047 class Context;
00048 class Query;
00049 class Generator;
00050
00056
00057
00058
00059
00066 typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
00067
00068
00069
00070
00071 typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
00072 typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
00073
00074 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
00075 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
00076
00077
00078
00079
00080
00085 class OutputMetaData
00086 {
00087 public:
00093 inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
00094 {
00095 xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
00096 }
00097
00101 virtual ~OutputMetaData() { Free(); }
00102
00104 inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
00106 inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
00107
00109 inline XnUInt32 FrameID() const { return m_output.nFrameID; }
00111 inline XnUInt32& FrameID() { return m_output.nFrameID; }
00112
00114 inline XnUInt32 DataSize() const { return m_output.nDataSize; }
00116 inline XnUInt32& DataSize() { return m_output.nDataSize; }
00117
00119 inline XnBool IsDataNew() const { return m_output.bIsNew; }
00121 inline XnBool& IsDataNew() { return m_output.bIsNew; }
00122
00124 inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
00126 inline XnOutputMetaData* GetUnderlying() { return &m_output; }
00127
00129 inline const XnUInt8* Data() const { return *m_ppData; }
00131 inline const XnUInt8*& Data() { return *m_ppData; }
00133 inline XnUInt8* WritableData()
00134 {
00135 MakeDataWritable();
00136 return m_pAllocatedData;
00137 }
00138
00145 XnStatus AllocateData(XnUInt32 nBytes)
00146 {
00147 if (nBytes > m_nAllocatedSize)
00148 {
00149
00150 XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
00151 XN_VALIDATE_ALLOC_PTR(pData);
00152
00153
00154 Free();
00155 m_pAllocatedData = pData;
00156 m_nAllocatedSize = nBytes;
00157 }
00158
00159 DataSize() = nBytes;
00160 *m_ppData = m_pAllocatedData;
00161
00162 return XN_STATUS_OK;
00163 }
00164
00168 void Free()
00169 {
00170 if (m_nAllocatedSize != 0)
00171 {
00172 xnOSFreeAligned(m_pAllocatedData);
00173 m_pAllocatedData = NULL;
00174 m_nAllocatedSize = 0;
00175 }
00176 }
00177
00182 XnStatus MakeDataWritable()
00183 {
00184 XnStatus nRetVal = XN_STATUS_OK;
00185
00186
00187 if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
00188 {
00189 const XnUInt8* pOrigData = *m_ppData;
00190
00191 nRetVal = AllocateData(DataSize());
00192 XN_IS_STATUS_OK(nRetVal);
00193
00194 if (pOrigData != NULL)
00195 {
00196 xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
00197 }
00198 else
00199 {
00200 xnOSMemSet(m_pAllocatedData, 0, DataSize());
00201 }
00202 }
00203
00204 return (XN_STATUS_OK);
00205 }
00206
00207 protected:
00208 XnUInt8* m_pAllocatedData;
00209
00210 private:
00211 XnOutputMetaData m_output;
00212
00213 const XnUInt8** m_ppData;
00214 XnUInt32 m_nAllocatedSize;
00215 };
00216
00221 class MapMetaData : public OutputMetaData
00222 {
00223 public:
00230 inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
00231 {
00232 xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
00233 m_map.pOutput = OutputMetaData::GetUnderlying();
00234 m_map.PixelFormat = format;
00235 }
00236
00238 inline XnUInt32 XRes() const { return m_map.Res.X; }
00240 inline XnUInt32& XRes() { return m_map.Res.X; }
00241
00243 inline XnUInt32 YRes() const { return m_map.Res.Y; }
00245 inline XnUInt32& YRes() { return m_map.Res.Y; }
00246
00248 inline XnUInt32 XOffset() const { return m_map.Offset.X; }
00250 inline XnUInt32& XOffset() { return m_map.Offset.X; }
00251
00253 inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
00255 inline XnUInt32& YOffset() { return m_map.Offset.Y; }
00256
00258 inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
00260 inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
00261
00263 inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
00265 inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
00266
00268 inline XnUInt32 FPS() const { return m_map.nFPS; }
00270 inline XnUInt32& FPS() { return m_map.nFPS; }
00271
00273 inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
00274
00276 inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
00278 inline XnMapMetaData* GetUnderlying() { return &m_map; }
00279
00281 inline XnUInt32 BytesPerPixel() const
00282 {
00283 switch (PixelFormat())
00284 {
00285 case XN_PIXEL_FORMAT_RGB24:
00286 return sizeof(XnRGB24Pixel);
00287 case XN_PIXEL_FORMAT_YUV422:
00288 return sizeof(XnYUV422DoublePixel)/2;
00289 case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT:
00290 return sizeof(XnGrayscale8Pixel);
00291 case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT:
00292 return sizeof(XnGrayscale16Pixel);
00293 default:
00294 XN_ASSERT(FALSE);
00295 return 0;
00296 }
00297 }
00298
00305 XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
00306 {
00307 XnStatus nRetVal = XN_STATUS_OK;
00308
00309 XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
00310 nRetVal = OutputMetaData::AllocateData(nSize);
00311 XN_IS_STATUS_OK(nRetVal);
00312
00313 FullXRes() = XRes() = nXRes;
00314 FullYRes() = YRes() = nYRes;
00315 XOffset() = YOffset() = 0;
00316
00317 return (XN_STATUS_OK);
00318 }
00319
00328 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
00329 {
00330 XnStatus nRetVal = XN_STATUS_OK;
00331
00332 if (pExternalBuffer == NULL)
00333 {
00334 nRetVal = AllocateData(nXRes, nYRes);
00335 XN_IS_STATUS_OK(nRetVal);
00336 }
00337 else
00338 {
00339 FullXRes() = XRes() = nXRes;
00340 FullYRes() = YRes() = nYRes;
00341 XOffset() = YOffset() = 0;
00342 Data() = pExternalBuffer;
00343 DataSize() = nXRes * nYRes * BytesPerPixel();
00344 }
00345
00346 return (XN_STATUS_OK);
00347 }
00348
00349 protected:
00350 XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; }
00351
00352 private:
00353
00354 MapMetaData& operator=(const MapMetaData&);
00355 inline MapMetaData(const MapMetaData& other);
00356
00357
00358 XnMapMetaData m_map;
00359 };
00360
00361
00362 #define _XN_DECLARE_MAP_DATA_CLASS(_name, _pixelType) \
00363 class _name \
00364 { \
00365 public: \
00366 inline _name(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) : \
00367 m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes) {} \
00368 \
00369 inline XnUInt32 XRes() const { return m_nXRes; } \
00370 inline XnUInt32 YRes() const { return m_nYRes; } \
00371 \
00372 inline const _pixelType& operator[](XnUInt32 nIndex) const \
00373 { \
00374 XN_ASSERT(nIndex < (m_nXRes * m_nYRes)); \
00375 return m_pData[nIndex]; \
00376 } \
00377 inline _pixelType& operator[](XnUInt32 nIndex) \
00378 { \
00379 XN_ASSERT(nIndex < (m_nXRes *m_nYRes)); \
00380 return m_pData[nIndex]; \
00381 } \
00382 \
00383 inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const \
00384 { \
00385 XN_ASSERT(x < m_nXRes && y < m_nYRes); \
00386 return m_pData[y*m_nXRes + x]; \
00387 } \
00388 inline _pixelType& operator()(XnUInt32 x, XnUInt32 y) \
00389 { \
00390 XN_ASSERT(x < m_nXRes && y < m_nYRes); \
00391 return m_pData[y*m_nXRes + x]; \
00392 } \
00393 \
00394 private: \
00395 \
00396 _name(const _name& other); \
00397 _name& operator=(const _name&); \
00398 \
00399 _pixelType*& m_pData; \
00400 XnUInt32& m_nXRes; \
00401 XnUInt32& m_nYRes; \
00402 };
00403
00404 _XN_DECLARE_MAP_DATA_CLASS(DepthMap, XnDepthPixel);
00405 _XN_DECLARE_MAP_DATA_CLASS(ImageMap, XnUInt8);
00406 _XN_DECLARE_MAP_DATA_CLASS(RGB24Map, XnRGB24Pixel);
00407 _XN_DECLARE_MAP_DATA_CLASS(Grayscale16Map, XnGrayscale16Pixel);
00408 _XN_DECLARE_MAP_DATA_CLASS(Grayscale8Map, XnGrayscale8Pixel);
00409 _XN_DECLARE_MAP_DATA_CLASS(IRMap, XnIRPixel);
00410 _XN_DECLARE_MAP_DATA_CLASS(LabelMap, XnLabel);
00411
00416 class DepthMetaData : public MapMetaData
00417 {
00418 public:
00422 inline DepthMetaData() :
00423 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
00424 m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00425 m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00426 {
00427 xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
00428 m_depth.pMap = MapMetaData::GetUnderlying();
00429 }
00430
00436 inline void InitFrom(const DepthMetaData& other)
00437 {
00438 xnCopyDepthMetaData(&m_depth, &other.m_depth);
00439 }
00440
00450 inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
00451 {
00452 InitFrom(other);
00453 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00454 }
00455
00461 XnStatus CopyFrom(const DepthMetaData& other)
00462 {
00463
00464 InitFrom(other);
00465
00466 return MakeDataWritable();
00467 }
00468
00470 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
00471 {
00472 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00473 }
00474
00476 inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
00478 inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
00479
00481 inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
00483 inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
00485 inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); }
00486
00488 inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
00490 inline xn::DepthMap& WritableDepthMap()
00491 {
00492 MakeDataWritable();
00493 return m_writableDepthMap;
00494 }
00495
00501 inline const XnDepthPixel& operator[](XnUInt32 nIndex) const
00502 {
00503 XN_ASSERT(nIndex < (XRes()*YRes()));
00504 return Data()[nIndex];
00505 }
00506
00513 inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const
00514 {
00515 XN_ASSERT(x < XRes() && y < YRes());
00516 return Data()[y*XRes() + x];
00517 }
00518
00520 inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
00522 inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
00523
00524 private:
00525
00526 DepthMetaData(const DepthMetaData& other);
00527 DepthMetaData& operator=(const DepthMetaData&);
00528
00529 XnDepthMetaData m_depth;
00530 const xn::DepthMap m_depthMap;
00531 xn::DepthMap m_writableDepthMap;
00532 };
00533
00538 class ImageMetaData : public MapMetaData
00539 {
00540 public:
00542 inline ImageMetaData() :
00543 MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
00544 m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00545 m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00546 m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00547 m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00548 m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00549 m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00550 m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00551 m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00552 {
00553 xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
00554 m_image.pMap = MapMetaData::GetUnderlying();
00555 }
00556
00562 inline void InitFrom(const ImageMetaData& other)
00563 {
00564 xnCopyImageMetaData(&m_image, &other.m_image);
00565 }
00566
00577 inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
00578 {
00579 InitFrom(other);
00580 XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
00581 XN_IS_STATUS_OK(nRetVal);
00582 PixelFormat() = format;
00583 return XN_STATUS_OK;
00584 }
00585
00593 inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
00594 {
00595 XnPixelFormat origFormat = PixelFormat();
00596 PixelFormat() = format;
00597 XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
00598 if (nRetVal != XN_STATUS_OK)
00599 {
00600 PixelFormat() = origFormat;
00601 return (nRetVal);
00602 }
00603
00604 return XN_STATUS_OK;
00605 }
00606
00608 inline XnStatus CopyFrom(const ImageMetaData& other)
00609 {
00610
00611 xnCopyImageMetaData(&m_image, &other.m_image);
00612
00613 return MakeDataWritable();
00614 }
00615
00625 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
00626 {
00627 XnPixelFormat origFormat = PixelFormat();
00628 PixelFormat() = format;
00629 XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
00630 if (nRetVal != XN_STATUS_OK)
00631 {
00632 PixelFormat() = origFormat;
00633 return (nRetVal);
00634 }
00635
00636 return XN_STATUS_OK;
00637 }
00638
00640 inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); }
00642 inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); }
00643
00645 inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
00646
00648 inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
00650 inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
00652 inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); }
00653
00655 inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
00657 inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); }
00659 inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); }
00660
00662 inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
00664 inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); }
00666 inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); }
00667
00669 inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
00671 inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); }
00673 inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); }
00674
00676 inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
00678 inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
00679
00681 inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
00683 inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
00684
00686 inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
00688 inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
00689
00691 inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
00693 inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
00694
00696 inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
00698 inline XnImageMetaData* GetUnderlying() { return &m_image; }
00699
00700 private:
00701
00702 ImageMetaData(const ImageMetaData& other);
00703 ImageMetaData& operator=(const ImageMetaData&);
00704
00705 XnImageMetaData m_image;
00706 const xn::ImageMap m_imageMap;
00707 xn::ImageMap m_writableImageMap;
00708 const xn::RGB24Map m_rgb24Map;
00709 xn::RGB24Map m_writableRgb24Map;
00710 const xn::Grayscale16Map m_gray16Map;
00711 xn::Grayscale16Map m_writableGray16Map;
00712 const xn::Grayscale8Map m_gray8Map;
00713 xn::Grayscale8Map m_writableGray8Map;
00714 };
00715
00720 class IRMetaData : public MapMetaData
00721 {
00722 public:
00724 inline IRMetaData() :
00725 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
00726 m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00727 m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00728 {
00729 xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
00730 m_ir.pMap = MapMetaData::GetUnderlying();
00731 }
00732
00738 inline void InitFrom(const IRMetaData& other)
00739 {
00740 xnCopyIRMetaData(&m_ir, &other.m_ir);
00741 }
00742
00744 inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
00745 {
00746 InitFrom(other);
00747 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00748 }
00749
00751 XnStatus CopyFrom(const IRMetaData& other)
00752 {
00753
00754 xnCopyIRMetaData(&m_ir, &other.m_ir);
00755
00756 return MakeDataWritable();
00757 }
00758
00760 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
00761 {
00762 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00763 }
00764
00766 inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
00768 inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
00770 inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); }
00771
00773 inline const xn::IRMap& IRMap() const { return m_irMap; }
00775 inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
00776
00778 inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
00780 inline XnIRMetaData* GetUnderlying() { return &m_ir; }
00781
00782 private:
00783
00784 IRMetaData(const IRMetaData& other);
00785 IRMetaData& operator=(const IRMetaData&);
00786
00787 XnIRMetaData m_ir;
00788 const xn::IRMap m_irMap;
00789 xn::IRMap m_writableIRMap;
00790 };
00791
00796 class AudioMetaData : public OutputMetaData
00797 {
00798 public:
00800 inline AudioMetaData() : OutputMetaData(&m_audio.pData)
00801 {
00802 xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
00803 m_audio.pOutput = OutputMetaData::GetUnderlying();
00804 }
00805
00811 inline void InitFrom(const AudioMetaData& other)
00812 {
00813 xnCopyAudioMetaData(&m_audio, &other.m_audio);
00814 }
00815
00817 inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
00819 inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
00820
00822 inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
00824 inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
00825
00827 inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
00829 inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
00830
00832 inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
00834 inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
00835
00836 private:
00837
00838 AudioMetaData(const AudioMetaData& other);
00839 AudioMetaData& operator=(const AudioMetaData&);
00840
00841 XnAudioMetaData m_audio;
00842 XnBool m_bAllocated;
00843 };
00844
00849 class SceneMetaData : public MapMetaData
00850 {
00851 public:
00853 inline SceneMetaData() :
00854 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
00855 m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00856 m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00857 {
00858 xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
00859 m_scene.pMap = MapMetaData::GetUnderlying();
00860 }
00861
00867 inline void InitFrom(const SceneMetaData& other)
00868 {
00869 xnCopySceneMetaData(&m_scene, &other.m_scene);
00870 }
00871
00873 inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
00874 {
00875 InitFrom(other);
00876 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00877 }
00878
00880 XnStatus CopyFrom(const SceneMetaData& other)
00881 {
00882
00883 xnCopySceneMetaData(&m_scene, &other.m_scene);
00884
00885 return MakeDataWritable();
00886 }
00887
00889 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
00890 {
00891 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00892 }
00893
00895 inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
00897 inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
00899 inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); }
00900
00902 inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
00904 inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
00905
00911 inline const XnLabel& operator[](XnUInt32 nIndex) const
00912 {
00913 XN_ASSERT(nIndex < (XRes()*YRes()));
00914 return Data()[nIndex];
00915 }
00916
00923 inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
00924 {
00925 XN_ASSERT(x < XRes() && y < YRes());
00926 return (*this)[y*XRes() + x];
00927 }
00928
00930 inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
00932 inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
00933
00934 private:
00935
00936 SceneMetaData(const SceneMetaData& other);
00937 SceneMetaData& operator=(const SceneMetaData&);
00938
00939 XnSceneMetaData m_scene;
00940 const xn::LabelMap m_labelMap;
00941 xn::LabelMap m_writableLabelMap;
00942 };
00943
00944
00945
00946
00947
00952 class NodeWrapper
00953 {
00954 public:
00955 friend class Context;
00956
00962 inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL)
00963 {
00964 NodeWrapper::SetHandle(hNode);
00965 }
00966
00967 inline ~NodeWrapper()
00968 {
00969 }
00970
00972 inline operator XnNodeHandle() const { return m_hNode; }
00973
00979 inline XnBool operator==(const NodeWrapper& other)
00980 {
00981 return (m_hNode == other.m_hNode);
00982 }
00983
00989 inline XnBool operator!=(const NodeWrapper& other)
00990 {
00991 return (m_hNode != other.m_hNode);
00992 }
00993
00995 inline XnBool IsValid() const { return (m_hNode != NULL); }
00996
01000 const XnChar* GetName() const {return xnGetNodeName(m_hNode); }
01001
01005 inline XnStatus AddRef() { return xnProductionNodeAddRef(m_hNode); }
01006
01010 inline void Release()
01011 {
01012 xnProductionNodeRelease(m_hNode);
01013 m_hNode = NULL;
01014 }
01015
01016 inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
01017 inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
01018
01020 inline void SetHandle(XnNodeHandle hNode) { m_hNode = hNode; }
01021
01022 protected:
01023 XnNodeHandle m_hNode;
01024 };
01025
01026
01027
01028
01029
01034 class NodeInfo
01035 {
01036 public:
01042 NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL)
01043 {
01044 SetUnderlyingObject(pInfo);
01045 }
01046
01052 NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL)
01053 {
01054 SetUnderlyingObject(other.m_pInfo);
01055 }
01056
01058 ~NodeInfo()
01059 {
01060 SetUnderlyingObject(NULL);
01061 }
01062
01068 inline NodeInfo& operator=(const NodeInfo& other)
01069 {
01070 SetUnderlyingObject(other.m_pInfo);
01071 return *this;
01072 }
01073
01075 inline operator XnNodeInfo*()
01076 {
01077 return m_pInfo;
01078 }
01079
01083 inline XnStatus SetInstanceName(const XnChar* strName)
01084 {
01085 return xnNodeInfoSetInstanceName(m_pInfo, strName);
01086 }
01087
01091 inline const XnProductionNodeDescription& GetDescription() const
01092 {
01093 return *xnNodeInfoGetDescription(m_pInfo);
01094 }
01095
01099 inline const XnChar* GetInstanceName() const
01100 {
01101 return xnNodeInfoGetInstanceName(m_pInfo);
01102 }
01103 inline const XnChar* GetCreationInfo() const
01107 {
01108 return xnNodeInfoGetCreationInfo(m_pInfo);
01109 }
01110
01114 inline NodeInfoList& GetNeededNodes() const;
01115
01123 inline XnStatus GetInstance(ProductionNode& node) const;
01124
01125 private:
01126 inline void SetUnderlyingObject(XnNodeInfo* pInfo);
01127
01128 XnNodeInfo* m_pInfo;
01129 mutable NodeInfoList* m_pNeededNodes;
01130 };
01131
01132
01133
01134
01135
01141 class Query
01142 {
01143 public:
01145 inline Query()
01146 {
01147 xnNodeQueryAllocate(&m_pQuery);
01148 }
01149
01151 ~Query()
01152 {
01153 xnNodeQueryFree(m_pQuery);
01154 m_pQuery = NULL;
01155 }
01156
01158 inline XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
01159
01163 inline XnStatus SetVendor(const XnChar* strVendor)
01164 {
01165 return xnNodeQuerySetVendor(m_pQuery, strVendor);
01166 }
01167
01171 inline XnStatus SetName(const XnChar* strName)
01172 {
01173 return xnNodeQuerySetName(m_pQuery, strName);
01174 }
01175
01179 inline XnStatus SetMinVersion(const XnVersion& minVersion)
01180 {
01181 return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
01182 }
01183
01187 inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
01188 {
01189 return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
01190 }
01191
01195 inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
01196 {
01197 return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
01198 }
01199
01203 inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
01204 {
01205 return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
01206 }
01207
01211 inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
01212 {
01213 return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
01214 }
01215
01219 inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
01220 {
01221 return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
01222 }
01223
01227 inline XnStatus AddNeededNode(const XnChar* strInstanceName)
01228 {
01229 return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
01230 }
01231
01235 inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
01236 {
01237 return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
01238 }
01239
01240 private:
01241 XnNodeQuery* m_pQuery;
01242 };
01243
01244
01245
01246
01247
01252 class NodeInfoList
01253 {
01254 public:
01256 class Iterator
01257 {
01258 public:
01259 friend class NodeInfoList;
01260
01266 XnBool operator==(const Iterator& other) const
01267 {
01268 return m_it.pCurrent == other.m_it.pCurrent;
01269 }
01270
01276 XnBool operator!=(const Iterator& other) const
01277 {
01278 return m_it.pCurrent != other.m_it.pCurrent;
01279 }
01280
01285 inline Iterator& operator++()
01286 {
01287 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01288 return *this;
01289 }
01290
01295 inline Iterator operator++(int)
01296 {
01297 XnNodeInfoListIterator curr = m_it;
01298 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01299 return Iterator(curr);
01300 }
01301
01305 inline Iterator& operator--()
01306 {
01307 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01308 return *this;
01309 }
01310
01314 inline Iterator operator--(int)
01315 {
01316 XnNodeInfoListIterator curr = m_it;
01317 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01318 return Iterator(curr);
01319 }
01320
01322 inline NodeInfo operator*()
01323 {
01324 return m_Info;
01325 }
01326
01327 private:
01328 inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
01329 {
01330 UpdateInternalObject(it);
01331 }
01332
01333 inline void UpdateInternalObject(XnNodeInfoListIterator it)
01334 {
01335 m_it = it;
01336 if (xnNodeInfoListIteratorIsValid(it))
01337 {
01338 XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
01339 m_Info = NodeInfo(pInfo);
01340 }
01341 else
01342 {
01343 m_Info = NodeInfo(NULL);
01344 }
01345 }
01346
01347 NodeInfo m_Info;
01348 XnNodeInfoListIterator m_it;
01349 };
01350
01354 inline NodeInfoList()
01355 {
01356 xnNodeInfoListAllocate(&m_pList);
01357 m_bAllocated = TRUE;
01358 }
01359
01366 inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
01367
01369 inline ~NodeInfoList()
01370 {
01371 FreeImpl();
01372 }
01373
01375 inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
01376
01383 inline void ReplaceUnderlyingObject(XnNodeInfoList* pList)
01384 {
01385 FreeImpl();
01386 m_pList = pList;
01387 m_bAllocated = TRUE;
01388 }
01389
01394 inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
01395 {
01396 XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01397 return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
01398 }
01399
01403 inline XnStatus AddNode(NodeInfo& info)
01404 {
01405 return xnNodeInfoListAddNode(m_pList, info);
01406 }
01407
01411 inline XnStatus AddNodeFromAnotherList(Iterator& it)
01412 {
01413 return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
01414 }
01415
01417 inline Iterator Begin() const
01418 {
01419 return Iterator(xnNodeInfoListGetFirst(m_pList));
01420 }
01421
01423 inline Iterator End() const
01424 {
01425 XnNodeInfoListIterator it = { NULL };
01426 return Iterator(it);
01427 }
01428
01430 inline Iterator RBegin() const
01431 {
01432 return Iterator(xnNodeInfoListGetLast(m_pList));
01433 }
01434
01436 inline Iterator REnd() const
01437 {
01438 XnNodeInfoListIterator it = { NULL };
01439 return Iterator(it);
01440 }
01441
01445 inline XnStatus Remove(Iterator& it)
01446 {
01447 return xnNodeInfoListRemove(m_pList, it.m_it);
01448 }
01449
01453 inline XnStatus Clear()
01454 {
01455 return xnNodeInfoListClear(m_pList);
01456 }
01457
01461 inline XnStatus Append(NodeInfoList& other)
01462 {
01463 return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
01464 }
01465
01469 inline XnBool IsEmpty()
01470 {
01471 return xnNodeInfoListIsEmpty(m_pList);
01472 }
01473
01477 inline XnStatus FilterList(Context& context, Query& query);
01478
01479 private:
01480 inline void FreeImpl()
01481 {
01482 if (m_bAllocated)
01483 {
01484 xnNodeInfoListFree(m_pList);
01485 m_bAllocated = FALSE;
01486 m_pList = NULL;
01487 }
01488 }
01489
01490 XnNodeInfoList* m_pList;
01491 XnBool m_bAllocated;
01492 };
01493
01494
01495
01496
01497
01502 class Capability
01503 {
01504 public:
01510 Capability(XnNodeHandle hNode) : m_hNode(hNode) {}
01511
01517 inline void SetUnderlyingHandle(XnNodeHandle hNode)
01518 {
01519 m_hNode = hNode;
01520 }
01521
01522 protected:
01523 XnNodeHandle m_hNode;
01524 };
01525
01530 class ErrorStateCapability : public Capability
01531 {
01532 public:
01538 ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
01539
01543 inline XnStatus GetErrorState()
01544 {
01545 return xnGetNodeErrorState(m_hNode);
01546 }
01547
01551 inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01552 {
01553 return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, m_hNode, handler, pCookie, hCallback);
01554 }
01555
01559 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
01560 {
01561 _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, m_hNode, hCallback);
01562 }
01563 };
01564
01569 class ProductionNode : public NodeWrapper
01570 {
01571 public:
01577 inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
01578
01582 inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(m_hNode)); }
01583
01587 inline XnStatus AddNeededNode(ProductionNode& needed)
01588 {
01589 return xnAddNeededNode(m_hNode, needed.m_hNode);
01590 }
01591
01595 inline XnStatus RemoveNeededNode(ProductionNode& needed)
01596 {
01597 return xnRemoveNeededNode(m_hNode, needed.m_hNode);
01598 }
01599
01603 inline void GetContext(Context& context);
01604
01608 inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
01609 {
01610 return xnIsCapabilitySupported(m_hNode, strCapabilityName);
01611 }
01612
01616 inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
01617 {
01618 return xnSetIntProperty(m_hNode, strName, nValue);
01619 }
01620
01624 inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
01625 {
01626 return xnSetRealProperty(m_hNode, strName, dValue);
01627 }
01628
01632 inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
01633 {
01634 return xnSetStringProperty(m_hNode, strName, strValue);
01635 }
01636
01640 inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
01641 {
01642 return xnSetGeneralProperty(m_hNode, strName, nBufferSize, pBuffer);
01643 }
01644
01648 inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
01649 {
01650 return xnGetIntProperty(m_hNode, strName, &nValue);
01651 }
01652
01656 inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
01657 {
01658 return xnGetRealProperty(m_hNode, strName, &dValue);
01659 }
01660
01664 inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
01665 {
01666 return xnGetStringProperty(m_hNode, strName, csValue, nBufSize);
01667 }
01668
01672 inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
01673 {
01674 return xnGetGeneralProperty(m_hNode, strName, nBufferSize, pBuffer);
01675 }
01676
01680 inline XnStatus LockForChanges(XnLockHandle* phLock)
01681 {
01682 return xnLockNodeForChanges(m_hNode, phLock);
01683 }
01684
01688 inline void UnlockForChanges(XnLockHandle hLock)
01689 {
01690 xnUnlockNodeForChanges(m_hNode, hLock);
01691 }
01692
01696 inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
01697 {
01698 return xnLockedNodeStartChanges(m_hNode, hLock);
01699 }
01700
01704 inline void LockedNodeEndChanges(XnLockHandle hLock)
01705 {
01706 xnLockedNodeEndChanges(m_hNode, hLock);
01707 }
01708
01714 inline ErrorStateCapability GetErrorStateCap()
01715 {
01716 return ErrorStateCapability(m_hNode);
01717 }
01718 };
01719
01724 class Device : public ProductionNode
01725 {
01726 public:
01732 inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01733 };
01734
01739 class MirrorCapability : public Capability
01740 {
01741 public:
01747 inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
01748
01752 inline XnStatus SetMirror(XnBool bMirror)
01753 {
01754 return xnSetMirror(m_hNode, bMirror);
01755 }
01756
01760 inline XnBool IsMirrored() const
01761 {
01762 return xnIsMirrored(m_hNode);
01763 }
01764
01768 inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01769 {
01770 return _RegisterToStateChange(xnRegisterToMirrorChange, m_hNode, handler, pCookie, hCallback);
01771 }
01772
01776 inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
01777 {
01778 _UnregisterFromStateChange(xnUnregisterFromMirrorChange, m_hNode, hCallback);
01779 }
01780 };
01781
01786 class AlternativeViewPointCapability : public Capability
01787 {
01788 public:
01794 inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
01795
01799 inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
01800 {
01801 return xnIsViewPointSupported(m_hNode, otherNode);
01802 }
01803
01807 inline XnStatus SetViewPoint(ProductionNode& otherNode)
01808 {
01809 return xnSetViewPoint(m_hNode, otherNode);
01810 }
01811
01815 inline XnStatus ResetViewPoint()
01816 {
01817 return xnResetViewPoint(m_hNode);
01818 }
01819
01823 inline XnBool IsViewPointAs(ProductionNode& otherNode) const
01824 {
01825 return xnIsViewPointAs(m_hNode, otherNode);
01826 }
01827
01831 inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01832 {
01833 return _RegisterToStateChange(xnRegisterToViewPointChange, m_hNode, handler, pCookie, hCallback);
01834 }
01835
01839 inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
01840 {
01841 _UnregisterFromStateChange(xnUnregisterFromViewPointChange, m_hNode, hCallback);
01842 }
01843 };
01844
01849 class FrameSyncCapability : public Capability
01850 {
01851 public:
01857 inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
01858
01862 inline XnBool CanFrameSyncWith(Generator& other);
01863
01867 inline XnStatus FrameSyncWith(Generator& other);
01868
01872 inline XnStatus StopFrameSyncWith(Generator& other);
01873
01877 inline XnBool IsFrameSyncedWith(Generator& other);
01878
01882 inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01883 {
01884 return _RegisterToStateChange(xnRegisterToFrameSyncChange, m_hNode, handler, pCookie, hCallback);
01885 }
01886
01890 inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
01891 {
01892 _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, m_hNode, hCallback);
01893 }
01894 };
01895
01900 class Generator : public ProductionNode
01901 {
01902 public:
01908 inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
01909
01913 inline XnStatus StartGenerating()
01914 {
01915 return xnStartGenerating(m_hNode);
01916 }
01917
01921 inline XnBool IsGenerating() const
01922 {
01923 return xnIsGenerating(m_hNode);
01924 }
01925
01929 inline XnStatus StopGenerating()
01930 {
01931 return xnStopGenerating(m_hNode);
01932 }
01933
01937 inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
01938 {
01939 return _RegisterToStateChange(xnRegisterToGenerationRunningChange, m_hNode, handler, pCookie, hCallback);
01940 }
01941
01945 inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
01946 {
01947 _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, m_hNode, hCallback);
01948 }
01949
01953 inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
01954 {
01955 return _RegisterToStateChange(xnRegisterToNewDataAvailable, m_hNode, handler, pCookie, hCallback);
01956 }
01957
01961 inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
01962 {
01963 _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, m_hNode, hCallback);
01964 }
01965
01969 inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL)
01970 {
01971 return xnIsNewDataAvailable(m_hNode, pnTimestamp);
01972 }
01973
01977 inline XnStatus WaitAndUpdateData()
01978 {
01979 return xnWaitAndUpdateData(m_hNode);
01980 }
01981
01985 inline XnBool IsDataNew() const
01986 {
01987 return xnIsDataNew(m_hNode);
01988 }
01989
01993 inline XnUInt32 GetDataSize() const
01994 {
01995 return xnGetDataSize(m_hNode);
01996 }
01997
02001 inline XnUInt64 GetTimestamp() const
02002 {
02003 return xnGetTimestamp(m_hNode);
02004 }
02005
02009 inline XnUInt32 GetFrameID() const
02010 {
02011 return xnGetFrameID(m_hNode);
02012 }
02013
02019 inline MirrorCapability GetMirrorCap()
02020 {
02021 return MirrorCapability(m_hNode);
02022 }
02023
02029 inline AlternativeViewPointCapability GetAlternativeViewPointCap()
02030 {
02031 return AlternativeViewPointCapability(m_hNode);
02032 }
02033
02039 inline FrameSyncCapability GetFrameSyncCap()
02040 {
02041 return FrameSyncCapability(m_hNode);
02042 }
02043 };
02044
02049 class Recorder : public ProductionNode
02050 {
02051 public:
02057 inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02058
02062 inline XnStatus Create(Context& context, const XnChar* strFormatName);
02063
02067 inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
02068 {
02069 return xnSetRecorderDestination(m_hNode, destType, strDest);
02070 }
02071
02075 inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
02076 {
02077 return xnAddNodeToRecording(m_hNode, Node, compression);
02078 }
02079
02083 inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
02084 {
02085 return xnRemoveNodeFromRecording(m_hNode, Node);
02086 }
02087
02091 inline XnStatus Record()
02092 {
02093 return xnRecord(m_hNode);
02094 }
02095 };
02096
02101 class Player : public ProductionNode
02102 {
02103 public:
02109 inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02110
02114 inline XnStatus Create(Context& context, const XnChar* strFormatName);
02115
02119 inline XnStatus SetRepeat(XnBool bRepeat)
02120 {
02121 return xnSetPlayerRepeat(m_hNode, bRepeat);
02122 }
02123
02127 inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
02128 {
02129 return xnSetPlayerSource(m_hNode, sourceType, strSource);
02130 }
02131
02135 inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize)
02136 {
02137 return xnGetPlayerSource(m_hNode, &sourceType, strSource, nBufSize);
02138 }
02139
02143 inline XnStatus ReadNext()
02144 {
02145 return xnPlayerReadNext(m_hNode);
02146 }
02147
02151 inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
02152 {
02153 return xnSeekPlayerToTimeStamp(m_hNode, nTimeOffset, origin);
02154 }
02155
02159 inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
02160 {
02161 return xnSeekPlayerToFrame(m_hNode, strNodeName, nFrameOffset, origin);
02162 }
02163
02167 inline XnStatus TellTimestamp(XnUInt64& nTimestamp)
02168 {
02169 return xnTellPlayerTimestamp(m_hNode, &nTimestamp);
02170 }
02171
02175 inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame)
02176 {
02177 return xnTellPlayerFrame(m_hNode, strNodeName, &nFrame);
02178 }
02179
02183 inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames)
02184 {
02185 return xnGetPlayerNumFrames(m_hNode, strNodeName, &nFrames);
02186 }
02187
02191 inline const XnChar* GetSupportedFormat()
02192 {
02193 return xnGetPlayerSupportedFormat(m_hNode);
02194 }
02195
02199 inline XnStatus EnumerateNodes(NodeInfoList& list)
02200 {
02201 XnNodeInfoList* pList;
02202 XnStatus nRetVal = xnEnumeratePlayerNodes(m_hNode, &pList);
02203 XN_IS_STATUS_OK(nRetVal);
02204
02205 list.ReplaceUnderlyingObject(pList);
02206
02207 return (XN_STATUS_OK);
02208 }
02209
02213 inline XnBool IsEOF()
02214 {
02215 return xnIsPlayerAtEOF(m_hNode);
02216 }
02217
02221 inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02222 {
02223 return _RegisterToStateChange(xnRegisterToEndOfFileReached, m_hNode, handler, pCookie, hCallback);
02224 }
02225
02229 inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
02230 {
02231 _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, m_hNode, hCallback);
02232 }
02233
02237 inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
02238 {
02239 return xnSetPlaybackSpeed(m_hNode, dSpeed);
02240 }
02241
02245 inline XnDouble GetPlaybackSpeed()
02246 {
02247 return xnGetPlaybackSpeed(m_hNode);
02248 }
02249 };
02250
02255 class CroppingCapability : public Capability
02256 {
02257 public:
02263 inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
02264
02268 inline XnStatus SetCropping(const XnCropping& Cropping)
02269 {
02270 return xnSetCropping(m_hNode, &Cropping);
02271 }
02272
02276 inline XnStatus GetCropping(XnCropping& Cropping) const
02277 {
02278 return xnGetCropping(m_hNode, &Cropping);
02279 }
02280
02284 inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02285 {
02286 return _RegisterToStateChange(xnRegisterToCroppingChange, m_hNode, handler, pCookie, hCallback);
02287 }
02288
02292 inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
02293 {
02294 _UnregisterFromStateChange(xnUnregisterFromCroppingChange, m_hNode, hCallback);
02295 }
02296 };
02297
02302 class MapGenerator : public Generator
02303 {
02304 public:
02310 inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02311
02315 inline XnUInt32 GetSupportedMapOutputModesCount() const
02316 {
02317 return xnGetSupportedMapOutputModesCount(m_hNode);
02318 }
02319
02323 inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
02324 {
02325 return xnGetSupportedMapOutputModes(m_hNode, aModes, &nCount);
02326 }
02327
02331 inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
02332 {
02333 return xnSetMapOutputMode(m_hNode, &OutputMode);
02334 }
02335
02339 inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
02340 {
02341 return xnGetMapOutputMode(m_hNode, &OutputMode);
02342 }
02343
02347 inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02348 {
02349 return _RegisterToStateChange(xnRegisterToMapOutputModeChange, m_hNode, handler, pCookie, hCallback);
02350 }
02351
02355 inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
02356 {
02357 _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, m_hNode, hCallback);
02358 }
02359
02365 inline CroppingCapability GetCroppingCap()
02366 {
02367 return CroppingCapability(m_hNode);
02368 }
02369 };
02370
02375 class UserPositionCapability : public Capability
02376 {
02377 public:
02383 inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
02384
02388 inline XnUInt32 GetSupportedUserPositionsCount() const
02389 {
02390 return xnGetSupportedUserPositionsCount(m_hNode);
02391 }
02392
02396 inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
02397 {
02398 return xnSetUserPosition(m_hNode, nIndex, &Position);
02399 }
02400
02404 inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
02405 {
02406 return xnGetUserPosition(m_hNode, nIndex, &Position);
02407 }
02408
02412 inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02413 {
02414 return _RegisterToStateChange(xnRegisterToUserPositionChange, m_hNode, handler, pCookie, hCallback);
02415 }
02416
02420 inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
02421 {
02422 _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, m_hNode, hCallback);
02423 }
02424 };
02425
02430 class DepthGenerator : public MapGenerator
02431 {
02432 public:
02438 inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02439
02443 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02444
02448 inline void GetMetaData(DepthMetaData& metaData) const
02449 {
02450 return xnGetDepthMetaData(m_hNode, metaData.GetUnderlying());
02451 }
02452
02456 inline const XnDepthPixel* GetDepthMap() const
02457 {
02458 return xnGetDepthMap(m_hNode);
02459 }
02460
02464 inline XnDepthPixel GetDeviceMaxDepth() const
02465 {
02466 return xnGetDeviceMaxDepth(m_hNode);
02467 }
02468
02472 inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
02473 {
02474 return xnGetDepthFieldOfView(m_hNode, &FOV);
02475 }
02476
02480 inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02481 {
02482 return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, m_hNode, handler, pCookie, hCallback);
02483 }
02484
02488 inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
02489 {
02490 _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, m_hNode, hCallback);
02491 }
02492
02496 inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
02497 {
02498 return xnConvertProjectiveToRealWorld(m_hNode, nCount, aProjective, aRealWorld);
02499 }
02500
02504 inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
02505 {
02506 return xnConvertRealWorldToProjective(m_hNode, nCount, aRealWorld, aProjective);
02507 }
02508
02514 inline UserPositionCapability GetUserPositionCap()
02515 {
02516 return UserPositionCapability(m_hNode);
02517 }
02518 };
02519
02524 class MockDepthGenerator : public DepthGenerator
02525 {
02526 public:
02532 inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
02533
02540 XnStatus Create(Context& context, const XnChar* strName = NULL);
02541
02548 XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
02549
02553 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
02554 {
02555 return xnMockDepthSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pDepthMap);
02556 }
02557
02565 inline XnStatus SetData(DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02566 {
02567 return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
02568 }
02569
02575 inline XnStatus SetData(DepthMetaData& depthMD)
02576 {
02577 return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
02578 }
02579 };
02580
02585 class ImageGenerator : public MapGenerator
02586 {
02587 public:
02593 inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02594
02598 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02599
02603 inline void GetMetaData(ImageMetaData& metaData) const
02604 {
02605 return xnGetImageMetaData(m_hNode, metaData.GetUnderlying());
02606 }
02607
02611 inline const XnRGB24Pixel* GetRGB24ImageMap() const
02612 {
02613 return xnGetRGB24ImageMap(m_hNode);
02614 }
02615
02619 inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
02620 {
02621 return xnGetYUV422ImageMap(m_hNode);
02622 }
02623
02627 inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
02628 {
02629 return xnGetGrayscale8ImageMap(m_hNode);
02630 }
02631
02635 inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
02636 {
02637 return xnGetGrayscale16ImageMap(m_hNode);
02638 }
02639
02643 inline const XnUInt8* GetImageMap() const
02644 {
02645 return xnGetImageMap(m_hNode);
02646 }
02647
02651 inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
02652 {
02653 return xnIsPixelFormatSupported(m_hNode, Format);
02654 }
02655
02659 inline XnStatus SetPixelFormat(XnPixelFormat Format)
02660 {
02661 return xnSetPixelFormat(m_hNode, Format);
02662 }
02663
02667 inline XnPixelFormat GetPixelFormat() const
02668 {
02669 return xnGetPixelFormat(m_hNode);
02670 }
02671
02675 inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02676 {
02677 return _RegisterToStateChange(xnRegisterToPixelFormatChange, m_hNode, handler, pCookie, hCallback);
02678 }
02679
02683 inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
02684 {
02685 _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, m_hNode, hCallback);
02686 }
02687 };
02688
02693 class MockImageGenerator : public ImageGenerator
02694 {
02695 public:
02701 inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
02702
02709 XnStatus Create(Context& context, const XnChar* strName = NULL);
02710
02717 XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
02718
02722 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
02723 {
02724 return xnMockImageSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pImageMap);
02725 }
02726
02734 inline XnStatus SetData(ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02735 {
02736 return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
02737 }
02738
02744 inline XnStatus SetData(ImageMetaData& imageMD)
02745 {
02746 return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
02747 }
02748 };
02749
02754 class IRGenerator : public MapGenerator
02755 {
02756 public:
02762 inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
02763
02767 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02768
02772 inline void GetMetaData(IRMetaData& metaData) const
02773 {
02774 xnGetIRMetaData(m_hNode, metaData.GetUnderlying());
02775 }
02776
02780 inline const XnIRPixel* GetIRMap() const
02781 {
02782 return xnGetIRMap(m_hNode);
02783 }
02784 };
02785
02790 class MockIRGenerator : public IRGenerator
02791 {
02792 public:
02798 inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
02799
02806 XnStatus Create(Context& context, const XnChar* strName = NULL);
02813 XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
02814
02818 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
02819 {
02820 return xnMockIRSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pIRMap);
02821 }
02822
02830 inline XnStatus SetData(IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
02831 {
02832 return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
02833 }
02834
02840 inline XnStatus SetData(IRMetaData& irMD)
02841 {
02842 return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
02843 }
02844 };
02845
02850 class GestureGenerator : public Generator
02851 {
02852 public:
02858 inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02859
02863 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02864
02868 inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
02869 {
02870 return xnAddGesture(m_hNode, strGesture, pArea);
02871 }
02872
02876 inline XnStatus RemoveGesture(const XnChar* strGesture)
02877 {
02878 return xnRemoveGesture(m_hNode, strGesture);
02879 }
02880
02884 inline XnStatus GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
02885 {
02886 return xnGetActiveGestures(m_hNode, &astrGestures, &nGestures);
02887 }
02888
02892 inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
02893 {
02894 return xnGetAllActiveGestures(m_hNode, astrGestures, nNameLength, &nGestures);
02895 }
02896
02900 inline XnStatus EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures)
02901 {
02902 return xnEnumerateGestures(m_hNode, &astrGestures, &nGestures);
02903 }
02907 inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures)
02908 {
02909 return xnEnumerateAllGestures(m_hNode, astrGestures, nNameLength, &nGestures);
02910 }
02911
02915 inline XnBool IsGestureAvailable(const XnChar* strGesture)
02916 {
02917 return xnIsGestureAvailable(m_hNode, strGesture);
02918 }
02919
02923 inline XnBool IsGestureProgressSupported(const XnChar* strGesture)
02924 {
02925 return xnIsGestureProgressSupported(m_hNode, strGesture);
02926 }
02927
02937 typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
02947 typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
02948
02952 XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
02953 {
02954 XnStatus nRetVal = XN_STATUS_OK;
02955
02956 GestureCookie* pGestureCookie;
02957 XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
02958 pGestureCookie->recognizedHandler = RecognizedCB;
02959 pGestureCookie->progressHandler = ProgressCB;
02960 pGestureCookie->pUserCookie = pCookie;
02961
02962 nRetVal = xnRegisterGestureCallbacks(m_hNode, GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
02963 if (nRetVal != XN_STATUS_OK)
02964 {
02965 xnOSFree(pGestureCookie);
02966 return (nRetVal);
02967 }
02968
02969 hCallback = pGestureCookie;
02970
02971 return (XN_STATUS_OK);
02972 }
02973
02977 inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
02978 {
02979 GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
02980 xnUnregisterGestureCallbacks(m_hNode, pGestureCookie->hCallback);
02981 xnOSFree(pGestureCookie);
02982 }
02983
02987 inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02988 {
02989 return _RegisterToStateChange(xnRegisterToGestureChange, m_hNode, handler, pCookie, hCallback);
02990 }
02991
02995 inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
02996 {
02997 _UnregisterFromStateChange(xnUnregisterFromGestureChange, m_hNode, hCallback);
02998 }
02999
03000 private:
03001 typedef struct GestureCookie
03002 {
03003 GestureRecognized recognizedHandler;
03004 GestureProgress progressHandler;
03005 void* pUserCookie;
03006 XnCallbackHandle hCallback;
03007 } GestureCookie;
03008
03009 static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
03010 {
03011 GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03012 GestureGenerator gen(hNode);
03013 if (pGestureCookie->recognizedHandler != NULL)
03014 {
03015 pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
03016 }
03017 }
03018
03019 static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
03020 {
03021 GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03022 GestureGenerator gen(hNode);
03023 if (pGestureCookie->progressHandler != NULL)
03024 {
03025 pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
03026 }
03027 }
03028 };
03029
03034 class SceneAnalyzer : public MapGenerator
03035 {
03036 public:
03042 inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03043
03047 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03048
03052 inline void GetMetaData(SceneMetaData& metaData) const
03053 {
03054 xnGetSceneMetaData(m_hNode, metaData.GetUnderlying());
03055 }
03056
03060 inline const XnLabel* GetLabelMap() const
03061 {
03062 return xnGetLabelMap(m_hNode);
03063 }
03064
03068 inline XnStatus GetFloor(XnPlane3D& Plane) const
03069 {
03070 return xnGetFloor(m_hNode, &Plane);
03071 }
03072 };
03073
03078 class HandsGenerator : public Generator
03079 {
03080 public:
03086 inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03087
03091 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03092
03102 typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03112 typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03121 typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
03122
03126 inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
03127 {
03128 XnStatus nRetVal = XN_STATUS_OK;
03129
03130 HandCookie* pHandCookie;
03131 XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
03132 pHandCookie->createHandler = CreateCB;
03133 pHandCookie->updateHandler = UpdateCB;
03134 pHandCookie->destroyHandler = DestroyCB;
03135 pHandCookie->pUserCookie = pCookie;
03136
03137 nRetVal = xnRegisterHandCallbacks(m_hNode, HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
03138 if (nRetVal != XN_STATUS_OK)
03139 {
03140 xnOSFree(pHandCookie);
03141 return (nRetVal);
03142 }
03143
03144 hCallback = pHandCookie;
03145
03146 return (XN_STATUS_OK);
03147 }
03148
03152 inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
03153 {
03154 HandCookie* pHandCookie = (HandCookie*)hCallback;
03155 xnUnregisterHandCallbacks(m_hNode, pHandCookie->hCallback);
03156 xnOSFree(pHandCookie);
03157 }
03158
03162 inline XnStatus StopTracking(XnUserID user)
03163 {
03164 return xnStopTracking(m_hNode, user);
03165 }
03166
03170 inline XnStatus StopTrackingAll()
03171 {
03172 return xnStopTrackingAll(m_hNode);
03173 }
03174
03178 inline XnStatus StartTracking(const XnPoint3D& ptPosition)
03179 {
03180 return xnStartTracking(m_hNode, &ptPosition);
03181 }
03182
03186 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03187 {
03188 return xnSetTrackingSmoothing(m_hNode, fSmoothingFactor);
03189 }
03190
03191 private:
03192 typedef struct HandCookie
03193 {
03194 HandCreate createHandler;
03195 HandUpdate updateHandler;
03196 HandDestroy destroyHandler;
03197 void* pUserCookie;
03198 XnCallbackHandle hCallback;
03199 } HandCookie;
03200
03201 static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03202 {
03203 HandCookie* pHandCookie = (HandCookie*)pCookie;
03204 HandsGenerator gen(hNode);
03205 if (pHandCookie->createHandler != NULL)
03206 {
03207 pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03208 }
03209 }
03210 static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
03211 {
03212 HandCookie* pHandCookie = (HandCookie*)pCookie;
03213 HandsGenerator gen(hNode);
03214 if (pHandCookie->updateHandler != NULL)
03215 {
03216 pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
03217 }
03218 }
03219 static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
03220 {
03221 HandCookie* pHandCookie = (HandCookie*)pCookie;
03222 HandsGenerator gen(hNode);
03223 if (pHandCookie->destroyHandler != NULL)
03224 {
03225 pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
03226 }
03227 }
03228 };
03229
03234 class SkeletonCapability : public Capability
03235 {
03236 public:
03242 inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
03243
03247 inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
03248 {
03249 return xnIsJointAvailable(m_hNode, eJoint);
03250 }
03251
03255 inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
03256 {
03257 return xnIsProfileAvailable(m_hNode, eProfile);
03258 }
03259
03263 inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
03264 {
03265 return xnSetSkeletonProfile(m_hNode, eProfile);
03266 }
03267
03271 inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
03272 {
03273 return xnSetJointActive(m_hNode, eJoint, bState);
03274 }
03275
03279 inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool bState)
03280 {
03281 return xnIsJointActive(m_hNode, eJoint);
03282 }
03283
03287 inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03288 {
03289 return _RegisterToStateChange(xnRegisterToJointConfigurationChange, m_hNode, handler, pCookie, hCallback);
03290 }
03291
03295 inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
03296 {
03297 _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, m_hNode, hCallback);
03298 }
03299
03303 inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints)
03304 {
03305 return xnEnumerateActiveJoints(m_hNode, pJoints, &nJoints);
03306 }
03307
03311 inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
03312 {
03313 return xnGetSkeletonJoint(m_hNode, user, eJoint, &Joint);
03314 }
03315
03319 inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
03320 {
03321 return xnGetSkeletonJointPosition(m_hNode, user, eJoint, &Joint);
03322 }
03323
03327 inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
03328 {
03329 return xnGetSkeletonJointOrientation(m_hNode, user, eJoint, &Joint);
03330 }
03331
03335 inline XnBool IsTracking(XnUserID user)
03336 {
03337 return xnIsSkeletonTracking(m_hNode, user);
03338 }
03339
03343 inline XnBool IsCalibrated(XnUserID user)
03344 {
03345 return xnIsSkeletonCalibrated(m_hNode, user);
03346 }
03347
03351 inline XnBool IsCalibrating(XnUserID user)
03352 {
03353 return xnIsSkeletonCalibrating(m_hNode, user);
03354 }
03355
03359 inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
03360 {
03361 return xnRequestSkeletonCalibration(m_hNode, user, bForce);
03362 }
03363
03367 inline XnStatus AbortCalibration(XnUserID user)
03368 {
03369 return xnAbortSkeletonCalibration(m_hNode, user);
03370 }
03371
03375 inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
03376 {
03377 return xnSaveSkeletonCalibrationData(m_hNode, user, nSlot);
03378 }
03379
03383 inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
03384 {
03385 return xnLoadSkeletonCalibrationData(m_hNode, user, nSlot);
03386 }
03387
03391 inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
03392 {
03393 return xnClearSkeletonCalibrationData(m_hNode, nSlot);
03394 }
03395
03399 inline XnBool IsCalibrationData(XnUInt32 nSlot)
03400 {
03401 return xnIsSkeletonCalibrationData(m_hNode, nSlot);
03402 }
03403
03407 inline XnStatus StartTracking(XnUserID user)
03408 {
03409 return xnStartSkeletonTracking(m_hNode, user);
03410 }
03411
03415 inline XnStatus StopTracking(XnUserID user)
03416 {
03417 return xnStopSkeletonTracking(m_hNode, user);
03418 }
03419
03423 inline XnStatus Reset(XnUserID user)
03424 {
03425 return xnResetSkeleton(m_hNode, user);
03426 }
03427
03431 inline XnBool NeedPoseForCalibration()
03432 {
03433 return xnNeedPoseForSkeletonCalibration(m_hNode);
03434 }
03435
03439 inline XnStatus GetCalibrationPose(XnChar* strPose)
03440 {
03441 return xnGetSkeletonCalibrationPose(m_hNode, strPose);
03442 }
03443
03447 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03448 {
03449 return xnSetSkeletonSmoothing(m_hNode, fSmoothingFactor);
03450 }
03451
03459 typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
03468 typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
03469
03473 inline XnStatus RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
03474 {
03475 XnStatus nRetVal = XN_STATUS_OK;
03476
03477 SkeletonCookie* pSkeletonCookie;
03478 XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
03479 pSkeletonCookie->startHandler = CalibrationStartCB;
03480 pSkeletonCookie->endHandler = CalibrationEndCB;
03481 pSkeletonCookie->pUserCookie = pCookie;
03482
03483 nRetVal = xnRegisterCalibrationCallbacks(m_hNode, CalibrationStartCallback, CalibrationEndCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
03484 if (nRetVal != XN_STATUS_OK)
03485 {
03486 xnOSFree(pSkeletonCookie);
03487 return (nRetVal);
03488 }
03489
03490 hCallback = pSkeletonCookie;
03491
03492 return (XN_STATUS_OK);
03493 }
03494
03498 inline void UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
03499 {
03500 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
03501 xnUnregisterCalibrationCallbacks(m_hNode, pSkeletonCookie->hCallback);
03502 xnOSFree(pSkeletonCookie);
03503 }
03504
03505 private:
03506 typedef struct SkeletonCookie
03507 {
03508 CalibrationStart startHandler;
03509 CalibrationEnd endHandler;
03510 void* pUserCookie;
03511 XnCallbackHandle hCallback;
03512 } SkeletonCookie;
03513
03514 static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03515 {
03516 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
03517 SkeletonCapability cap(hNode);
03518 if (pSkeletonCookie->startHandler != NULL)
03519 {
03520 pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
03521 }
03522 }
03523
03524 static void XN_CALLBACK_TYPE CalibrationEndCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
03525 {
03526 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
03527 SkeletonCapability cap(hNode);
03528 if (pSkeletonCookie->endHandler != NULL)
03529 {
03530 pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
03531 }
03532 }
03533 };
03534
03539 class PoseDetectionCapability : public Capability
03540 {
03541 public:
03547 inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
03548
03557 typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
03558
03562 inline XnUInt32 GetNumberOfPoses()
03563 {
03564 return xnGetNumberOfPoses(m_hNode);
03565 }
03566
03570 inline XnStatus GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses)
03571 {
03572 return xnGetAvailablePoses(m_hNode, pstrPoses, &nPoses);
03573 }
03577 inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses)
03578 {
03579 return xnGetAllAvailablePoses(m_hNode, pstrPoses, nNameLength, &nPoses);
03580 }
03581
03585 inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
03586 {
03587 return xnStartPoseDetection(m_hNode, strPose, user);
03588 }
03589
03593 inline XnStatus StopPoseDetection(XnUserID user)
03594 {
03595 return xnStopPoseDetection(m_hNode, user);
03596 }
03597
03601 inline XnStatus RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
03602 {
03603 XnStatus nRetVal = XN_STATUS_OK;
03604
03605 PoseCookie* pPoseCookie;
03606 XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
03607 pPoseCookie->startHandler = PoseStartCB;
03608 pPoseCookie->endHandler = PoseEndCB;
03609 pPoseCookie->pPoseCookie = pCookie;
03610
03611 nRetVal = xnRegisterToPoseCallbacks(m_hNode, PoseDetectionStartCallback, PoseDetectionStartEndCallback, pPoseCookie, &pPoseCookie->hCallback);
03612 if (nRetVal != XN_STATUS_OK)
03613 {
03614 xnOSFree(pPoseCookie);
03615 return (nRetVal);
03616 }
03617
03618 hCallback = pPoseCookie;
03619
03620 return (XN_STATUS_OK);
03621 }
03622
03626 inline void UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
03627 {
03628 PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
03629 xnUnregisterCalibrationCallbacks(m_hNode, pPoseCookie->hCallback);
03630 xnOSFree(pPoseCookie);
03631 }
03632 private:
03633 typedef struct PoseCookie
03634 {
03635 PoseDetection startHandler;
03636 PoseDetection endHandler;
03637 void* pPoseCookie;
03638 XnCallbackHandle hCallback;
03639 } PoseCookie;
03640
03641 static void XN_CALLBACK_TYPE PoseDetectionStartCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
03642 {
03643 PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
03644 PoseDetectionCapability cap(hNode);
03645 if (pPoseCookie->startHandler != NULL)
03646 {
03647 pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
03648 }
03649 }
03650
03651 static void XN_CALLBACK_TYPE PoseDetectionStartEndCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
03652 {
03653 PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
03654 PoseDetectionCapability cap(hNode);
03655 if (pPoseCookie->endHandler != NULL)
03656 {
03657 pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
03658 }
03659 }
03660 };
03661
03666 class UserGenerator : public Generator
03667 {
03668 public:
03674 inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03675
03679 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03680
03681 typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
03682
03686 inline XnUInt16 GetNumberOfUsers() const
03687 {
03688 return xnGetNumberOfUsers(m_hNode);
03689 }
03690
03694 inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
03695 {
03696 return xnGetUsers(m_hNode, aUsers, &nUsers);
03697 }
03698
03702 inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
03703 {
03704 return xnGetUserCoM(m_hNode, user, &com);
03705 }
03706
03710 inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd)
03711 {
03712 return xnGetUserPixels(m_hNode, user, smd.GetUnderlying());
03713 }
03714
03718 inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
03719 {
03720 XnStatus nRetVal = XN_STATUS_OK;
03721
03722 UserCookie* pUserCookie;
03723 XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
03724 pUserCookie->newHandler = NewUserCB;
03725 pUserCookie->lostHandler = LostUserCB;
03726 pUserCookie->pUserCookie = pCookie;
03727
03728 nRetVal = xnRegisterUserCallbacks(m_hNode, NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
03729 if (nRetVal != XN_STATUS_OK)
03730 {
03731 xnOSFree(pUserCookie);
03732 return (nRetVal);
03733 }
03734
03735 hCallback = pUserCookie;
03736
03737 return (XN_STATUS_OK);
03738 }
03739
03743 inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
03744 {
03745 UserCookie* pUserCookie = (UserCookie*)hCallback;
03746 xnUnregisterUserCallbacks(m_hNode, pUserCookie->hCallback);
03747 xnOSFree(pUserCookie);
03748 }
03749
03755 inline SkeletonCapability GetSkeletonCap()
03756 {
03757 return SkeletonCapability(m_hNode);
03758 }
03759
03765 inline PoseDetectionCapability GetPoseDetectionCap()
03766 {
03767 return PoseDetectionCapability(m_hNode);
03768 }
03769
03770 private:
03771 typedef struct UserCookie
03772 {
03773 UserHandler newHandler;
03774 UserHandler lostHandler;
03775 void* pUserCookie;
03776 XnCallbackHandle hCallback;
03777 } UserCookie;
03778
03779 static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03780 {
03781 UserCookie* pUserCookie = (UserCookie*)pCookie;
03782 UserGenerator gen(hNode);
03783 if (pUserCookie->newHandler != NULL)
03784 {
03785 pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
03786 }
03787 }
03788
03789 static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
03790 {
03791 UserCookie* pUserCookie = (UserCookie*)pCookie;
03792 UserGenerator gen(hNode);
03793 if (pUserCookie->lostHandler != NULL)
03794 {
03795 pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
03796 }
03797 }
03798 };
03799
03804 class AudioGenerator : public Generator
03805 {
03806 public:
03812 inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03813
03817 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03818
03822 inline void GetMetaData(AudioMetaData& metaData) const
03823 {
03824 xnGetAudioMetaData(m_hNode, metaData.GetUnderlying());
03825 }
03826
03830 inline const XnUChar* GetAudioBuffer() const
03831 {
03832 return xnGetAudioBuffer(m_hNode);
03833 }
03834
03838 inline XnUInt32 GetSupportedWaveOutputModesCount() const
03839 {
03840 return xnGetSupportedWaveOutputModesCount(m_hNode);
03841 }
03842
03846 inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
03847 {
03848 return xnGetSupportedWaveOutputModes(m_hNode, aSupportedModes, &nCount);
03849 }
03850
03854 inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
03855 {
03856 return xnSetWaveOutputMode(m_hNode, &OutputMode);
03857 }
03858
03862 inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
03863 {
03864 return xnGetWaveOutputMode(m_hNode, &OutputMode);
03865 }
03866
03870 inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03871 {
03872 return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, m_hNode, handler, pCookie, hCallback);
03873 }
03874
03878 inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
03879 {
03880 _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, m_hNode, hCallback);
03881 }
03882 };
03883
03888 class MockAudioGenerator : public AudioGenerator
03889 {
03890 public:
03896 inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
03897
03904 XnStatus Create(Context& context, const XnChar* strName = NULL);
03905
03912 XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
03913
03917 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
03918 {
03919 return xnMockAudioSetData(m_hNode, nFrameID, nTimestamp, nDataSize, pAudioBuffer);
03920 }
03921
03929 inline XnStatus SetData(AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03930 {
03931 return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
03932 }
03933
03939 inline XnStatus SetData(AudioMetaData& audioMD)
03940 {
03941 return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
03942 }
03943 };
03944
03945
03946
03947
03952 class Codec : public ProductionNode
03953 {
03954 public:
03960 inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
03961
03965 inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
03966
03970 inline XnCodecID GetCodecID() const
03971 {
03972 return xnGetCodecID(m_hNode);
03973 }
03974
03978 inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
03979 {
03980 return xnEncodeData(m_hNode, pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
03981 }
03982
03986 inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
03987 {
03988 return xnDecodeData(m_hNode, pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
03989 }
03990 };
03991
03992
03993
03994
03999 class EnumerationErrors
04000 {
04001 public:
04003 inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
04004
04011 inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
04012
04014 ~EnumerationErrors() { Free(); }
04015
04017 class Iterator
04018 {
04019 public:
04020 friend class EnumerationErrors;
04021
04027 XnBool operator==(const Iterator& other) const
04028 {
04029 return m_it == other.m_it;
04030 }
04031
04037 XnBool operator!=(const Iterator& other) const
04038 {
04039 return m_it != other.m_it;
04040 }
04041
04046 inline Iterator& operator++()
04047 {
04048 m_it = xnEnumerationErrorsGetNext(m_it);
04049 return *this;
04050 }
04051
04056 inline Iterator operator++(int)
04057 {
04058 return Iterator(xnEnumerationErrorsGetNext(m_it));
04059 }
04060
04062 inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
04064 inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
04065
04066 private:
04067 inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
04068
04069 XnEnumerationErrorsIterator m_it;
04070 };
04071
04073 inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); }
04075 inline Iterator End() const { return Iterator(NULL); }
04076
04080 inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
04081 {
04082 return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
04083 }
04084
04088 inline void Free()
04089 {
04090 if (m_bAllocated)
04091 {
04092 xnEnumerationErrorsFree(m_pErrors);
04093 m_pErrors = NULL;
04094 m_bAllocated = FALSE;
04095 }
04096 }
04097
04099 inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
04100
04101 private:
04102 XnEnumerationErrors* m_pErrors;
04103 XnBool m_bAllocated;
04104 };
04105
04106
04107
04108
04109
04114 class Context
04115 {
04116 public:
04118 inline Context() : m_pContext(NULL), m_bAllocated(FALSE) {}
04124 inline Context(XnContext* pContext) : m_pContext(pContext), m_bAllocated(FALSE) {}
04131 inline Context(const Context& other) : m_pContext(other.m_pContext), m_bAllocated(FALSE) {}
04132
04134 ~Context()
04135 {
04136 FreeImpl();
04137 }
04138
04140 inline XnContext* GetUnderlyingObject() const { return m_pContext; }
04141
04145 inline XnStatus Init()
04146 {
04147 XnStatus nRetVal = xnInit(&m_pContext);
04148 XN_IS_STATUS_OK(nRetVal);
04149 m_bAllocated = TRUE;
04150 return (XN_STATUS_OK);
04151 }
04152
04156 inline XnStatus RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
04157 {
04158 return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04159 }
04160
04164 inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
04165 {
04166 return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04167 }
04168
04172 inline XnStatus InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
04173 {
04174 XnStatus nRetVal = xnInitFromXmlFile(strFileName, &m_pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04175 XN_IS_STATUS_OK(nRetVal);
04176 m_bAllocated = TRUE;
04177 return (XN_STATUS_OK);
04178 }
04179
04183 inline XnStatus OpenFileRecording(const XnChar* strFileName)
04184 {
04185 return xnContextOpenFileRecording(m_pContext, strFileName);
04186 }
04187
04191 inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& node)
04192 {
04193 return xnCreateMockNode(m_pContext, type, strName, &node.m_hNode);
04194 }
04195
04199 inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
04200 {
04201 return xnCreateMockNodeBasedOn(m_pContext, originalNode.m_hNode, strName, &mockNode.m_hNode);
04202 }
04203
04207 inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
04208 {
04209 return xnCreateCodec(m_pContext, codecID, initializerNode, &codec.m_hNode);
04210 }
04211
04215 inline void Shutdown()
04216 {
04217 if (m_pContext != NULL)
04218 {
04219 xnShutdown(m_pContext);
04220 m_pContext = NULL;
04221 }
04222 }
04223
04227 inline XnStatus AddLicense(const XnLicense& License)
04228 {
04229 return xnAddLicense(m_pContext, &License);
04230 }
04231
04235 inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
04236 {
04237 return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
04238 }
04239
04243 inline static void FreeLicensesList(XnLicense aLicenses[])
04244 {
04245 return xnFreeLicensesList(aLicenses);
04246 }
04247
04251 XnStatus EnumerateProductionTrees(XnProductionNodeType Type, Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
04252 {
04253 XnStatus nRetVal = XN_STATUS_OK;
04254
04255 XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
04256
04257 XnNodeInfoList* pList = NULL;
04258 nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04259 XN_IS_STATUS_OK(nRetVal);
04260
04261 TreesList.ReplaceUnderlyingObject(pList);
04262
04263 return (XN_STATUS_OK);
04264 }
04265
04269 XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
04270 {
04271 XnStatus nRetVal = XN_STATUS_OK;
04272
04273 XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
04274
04275 XnNodeHandle hNode;
04276 nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
04277 XN_IS_STATUS_OK(nRetVal);
04278
04279 node.SetHandle(hNode);
04280
04281 return (XN_STATUS_OK);
04282 }
04283
04287 XnStatus CreateProductionTree(NodeInfo& Tree)
04288 {
04289 XnStatus nRetVal = XN_STATUS_OK;
04290
04291 XnNodeHandle hNode;
04292 nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
04293 XN_IS_STATUS_OK(nRetVal);
04294
04295 return (XN_STATUS_OK);
04296 }
04297
04301 XnStatus EnumerateExistingNodes(NodeInfoList& list) const
04302 {
04303 XnNodeInfoList* pList;
04304 XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
04305 XN_IS_STATUS_OK(nRetVal);
04306
04307 list.ReplaceUnderlyingObject(pList);
04308
04309 return (XN_STATUS_OK);
04310 }
04311
04315 XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
04316 {
04317 XnNodeInfoList* pList;
04318 XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
04319 XN_IS_STATUS_OK(nRetVal);
04320
04321 list.ReplaceUnderlyingObject(pList);
04322
04323 return (XN_STATUS_OK);
04324 }
04325
04329 XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
04330 {
04331 XnStatus nRetVal = XN_STATUS_OK;
04332
04333 XnNodeHandle hNode;
04334 nRetVal = xnFindExistingNodeByType(m_pContext, type, &hNode);
04335 XN_IS_STATUS_OK(nRetVal);
04336
04337 node.SetHandle(hNode);
04338
04339 return (XN_STATUS_OK);
04340 }
04341
04345 XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
04346 {
04347 XnStatus nRetVal = XN_STATUS_OK;
04348
04349 XnNodeHandle hNode;
04350 nRetVal = xnGetNodeHandleByName(m_pContext, strInstanceName, &hNode);
04351 XN_IS_STATUS_OK(nRetVal);
04352
04353 node.SetHandle(hNode);
04354
04355 return (XN_STATUS_OK);
04356 }
04357
04361 XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
04362 {
04363 XnStatus nRetVal = XN_STATUS_OK;
04364
04365 XnNodeHandle hNode;
04366 nRetVal = xnGetNodeHandleByName(m_pContext, strInstanceName, &hNode);
04367 XN_IS_STATUS_OK(nRetVal);
04368
04369 nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
04370
04371 return (XN_STATUS_OK);
04372 }
04373
04377 inline XnStatus StartGeneratingAll()
04378 {
04379 return xnStartGeneratingAll(m_pContext);
04380 }
04381
04385 inline XnStatus StopGeneratingAll()
04386 {
04387 return xnStopGeneratingAll(m_pContext);
04388 }
04389
04393 inline XnStatus SetGlobalMirror(XnBool bMirror)
04394 {
04395 return xnSetGlobalMirror(m_pContext, bMirror);
04396 }
04397
04401 inline XnBool GetGlobalMirror()
04402 {
04403 return xnGetGlobalMirror(m_pContext);
04404 }
04405
04409 inline XnStatus GetGlobalErrorState()
04410 {
04411 return xnGetGlobalErrorState(m_pContext);
04412 }
04413
04417 inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04418 {
04419 return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
04420 }
04421
04425 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
04426 {
04427 return xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
04428 }
04429
04433 inline XnStatus WaitAndUpdateAll()
04434 {
04435 return xnWaitAndUpdateAll(m_pContext);
04436 }
04437
04441 inline XnStatus WaitAnyUpdateAll()
04442 {
04443 return xnWaitAnyUpdateAll(m_pContext);
04444 }
04445
04449 inline XnStatus WaitOneUpdateAll(ProductionNode& node)
04450 {
04451 return xnWaitOneUpdateAll(m_pContext, node);
04452 }
04453
04457 inline XnStatus WaitNoneUpdateAll()
04458 {
04459 return xnWaitNoneUpdateAll(m_pContext);
04460 }
04461
04465 inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
04466 {
04467 return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
04468 }
04469
04471 inline void SetHandle(XnContext* pContext)
04472 {
04473 if (m_pContext != pContext)
04474 {
04475 FreeImpl();
04476 m_pContext = pContext;
04477 }
04478 }
04479
04480 private:
04481 void FreeImpl()
04482 {
04483 if (m_bAllocated)
04484 {
04485 Shutdown();
04486 m_pContext = NULL;
04487 m_bAllocated = FALSE;
04488 }
04489 }
04490
04491 XnContext* m_pContext;
04492 XnBool m_bAllocated;
04493 };
04494
04499 class Resolution
04500 {
04501 public:
04507 inline Resolution(XnResolution res) : m_Res(res)
04508 {
04509 m_nXRes = xnResolutionGetXRes(res);
04510 m_nYRes = xnResolutionGetYRes(res);
04511 m_strName = xnResolutionGetName(res);
04512 }
04513
04520 inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
04521 {
04522 m_Res = xnResolutionGetFromXYRes(xRes, yRes);
04523 m_strName = xnResolutionGetName(m_Res);
04524 }
04525
04531 inline Resolution(const XnChar* strName)
04532 {
04533 m_Res = xnResolutionGetFromName(strName);
04534 m_nXRes = xnResolutionGetXRes(m_Res);
04535 m_nYRes = xnResolutionGetYRes(m_Res);
04536 m_strName = xnResolutionGetName(m_Res);
04537 }
04538
04540 inline XnResolution GetResolution() const { return m_Res; }
04542 inline XnUInt32 GetXResolution() const { return m_nXRes; }
04544 inline XnUInt32 GetYResolution() const { return m_nYRes; }
04546 inline const XnChar* GetName() const { return m_strName; }
04547
04548 private:
04549 XnResolution m_Res;
04550 XnUInt32 m_nXRes;
04551 XnUInt32 m_nYRes;
04552 const XnChar* m_strName;
04553 };
04554
04555
04556
04557
04558 inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
04559 {
04560 return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
04561 }
04562
04563 inline void ProductionNode::GetContext(Context& context)
04564 {
04565 context.SetHandle(xnGetContextFromNodeHandle(m_hNode));
04566 }
04567
04568 inline NodeInfoList& NodeInfo::GetNeededNodes() const
04569 {
04570 if (m_pNeededNodes == NULL)
04571 {
04572 XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
04573 m_pNeededNodes = XN_NEW(NodeInfoList, pList);
04574 }
04575
04576 return *m_pNeededNodes;
04577 }
04578
04579 inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
04580 {
04581 if (m_pNeededNodes != NULL)
04582 {
04583 XN_DELETE(m_pNeededNodes);
04584 }
04585
04586 m_pInfo = pInfo;
04587 m_pNeededNodes = NULL;
04588 }
04589
04590 inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other)
04591 {
04592 return xnCanFrameSyncWith(m_hNode, other);
04593 }
04594
04595 inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
04596 {
04597 return xnFrameSyncWith(m_hNode, other);
04598 }
04599
04600 inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
04601 {
04602 return xnStopFrameSyncWith(m_hNode, other);
04603 }
04604
04605 inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other)
04606 {
04607 return xnIsFrameSyncedWith(m_hNode, other);
04608 }
04609
04610 inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
04611 {
04612 XnStatus nRetVal = XN_STATUS_OK;
04613
04614 if (m_pInfo == NULL)
04615 {
04616 return XN_STATUS_INVALID_OPERATION;
04617 }
04618
04619 node.SetHandle(xnNodeInfoGetHandle(m_pInfo));
04620
04621 return (XN_STATUS_OK);
04622 }
04623
04624
04625
04626
04627
04628
04629
04630 inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName = NULL)
04631 {
04632 return xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &m_hNode);
04633 }
04634
04635 inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
04636 {
04637 return xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &m_hNode);
04638 }
04639
04640 inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04641 {
04642 return xnCreateDepthGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04643 }
04644
04645 inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName )
04646 {
04647 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &m_hNode);
04648 }
04649
04650 inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName )
04651 {
04652 Context context;
04653 other.GetContext(context);
04654 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04655 }
04656
04657 inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04658 {
04659 return xnCreateImageGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04660 }
04661
04662 inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName )
04663 {
04664 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &m_hNode);
04665 }
04666
04667 inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName )
04668 {
04669 Context context;
04670 other.GetContext(context);
04671 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04672 }
04673
04674 inline XnStatus IRGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04675 {
04676 return xnCreateIRGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04677 }
04678
04679 inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName )
04680 {
04681 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &m_hNode);
04682 }
04683
04684 inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName )
04685 {
04686 Context context;
04687 other.GetContext(context);
04688 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04689 }
04690
04691 inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04692 {
04693 return xnCreateGestureGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04694 }
04695
04696 inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04697 {
04698
04699 return xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04700 }
04701
04702 inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04703 {
04704 return xnCreateHandsGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04705 }
04706
04707 inline XnStatus UserGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04708 {
04709 return xnCreateUserGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04710 }
04711
04712 inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
04713 {
04714 return xnCreateAudioGenerator(context.GetUnderlyingObject(), &m_hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
04715 }
04716
04717 inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName )
04718 {
04719 return xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &m_hNode);
04720 }
04721
04722 inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName )
04723 {
04724 Context context;
04725 other.GetContext(context);
04726 return xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other, strName, &m_hNode);
04727 }
04728
04729 inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
04730 {
04731 return xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode, &m_hNode);
04732 }
04733
04734
04735
04736
04737
04741 inline void GetVersion(XnVersion& Version)
04742 {
04743 xnGetVersion(&Version);
04744 }
04745
04746
04747
04748
04749
04750 class StateChangedCallbackTranslator
04751 {
04752 public:
04753 StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
04754
04755 XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
04756 {
04757 return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
04758 }
04759
04760 void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
04761 {
04762 xnFunc(hNode, m_hCallback);
04763 }
04764
04765 static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04766 {
04767 XnStatus nRetVal = XN_STATUS_OK;
04768
04769 StateChangedCallbackTranslator* pTrans;
04770 XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
04771
04772 nRetVal = pTrans->Register(xnFunc, hNode);
04773 if (nRetVal != XN_STATUS_OK)
04774 {
04775 XN_DELETE(pTrans);
04776 return (nRetVal);
04777 }
04778
04779 hCallback = pTrans;
04780
04781 return (XN_STATUS_OK);
04782 }
04783
04784 static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
04785 {
04786 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
04787 pTrans->Unregister(xnFunc, hNode);
04788 XN_DELETE(pTrans);
04789 return XN_STATUS_OK;
04790 }
04791
04792 private:
04793 typedef struct StateChangeCookie
04794 {
04795 StateChangedHandler userHandler;
04796 void* pUserCookie;
04797 XnCallbackHandle hCallback;
04798 } StateChangeCookie;
04799
04800 static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
04801 {
04802 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
04803 ProductionNode node(hNode);
04804 pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
04805 }
04806
04807 StateChangedHandler m_UserHandler;
04808 void* m_pUserCookie;
04809 XnCallbackHandle m_hCallback;
04810 };
04811
04812 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04813 {
04814 return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
04815 }
04816
04817 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
04818 {
04819 StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
04820 }
04821
04823 };
04824
04825 #endif // __XN_CPP_WRAPPER_H__