00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __XN_CPP_WRAPPER_H__
00023 #define __XN_CPP_WRAPPER_H__
00024
00025
00026
00027
00028 #include <XnOpenNI.h>
00029 #include <XnCodecIDs.h>
00030
00031
00032
00033
00034 namespace xn
00035 {
00036
00037
00038
00039 class ProductionNode;
00040 class EnumerationErrors;
00041 class NodeInfo;
00042 class NodeInfoList;
00043 class Context;
00044 class Query;
00045 class Generator;
00046
00052
00053
00054
00055
00062 typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie);
00063
00064
00065
00066
00067 typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback);
00068 typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback);
00069
00070 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
00071 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback);
00072
00073
00074
00075
00076 class Version
00077 {
00078 public:
00079 Version(const XnVersion& version) : m_version(version) {}
00080 Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild)
00081 {
00082 m_version.nMajor = nMajor;
00083 m_version.nMinor = nMinor;
00084 m_version.nMaintenance = nMaintenance;
00085 m_version.nBuild = nBuild;
00086 }
00087
00088 bool operator==(const Version& other) const
00089 {
00090 return (xnVersionCompare(&m_version, &other.m_version) == 0);
00091 }
00092 bool operator!=(const Version& other) const
00093 {
00094 return (xnVersionCompare(&m_version, &other.m_version) != 0);
00095 }
00096 bool operator<(const Version& other) const
00097 {
00098 return (xnVersionCompare(&m_version, &other.m_version) < 0);
00099 }
00100 bool operator<=(const Version& other) const
00101 {
00102 return (xnVersionCompare(&m_version, &other.m_version) <= 0);
00103 }
00104 bool operator>(const Version& other) const
00105 {
00106 return (xnVersionCompare(&m_version, &other.m_version) > 0);
00107 }
00108 bool operator>=(const Version& other) const
00109 {
00110 return (xnVersionCompare(&m_version, &other.m_version) >= 0);
00111 }
00112 private:
00113 XnVersion m_version;
00114 };
00115
00116
00117
00118
00119
00124 class OutputMetaData
00125 {
00126 public:
00132 inline OutputMetaData(const XnUInt8** ppData) : m_ppData(ppData), m_nAllocatedSize(0), m_pAllocatedData(NULL)
00133 {
00134 xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData));
00135 }
00136
00140 virtual ~OutputMetaData() { Free(); }
00141
00143 inline XnUInt64 Timestamp() const { return m_output.nTimestamp; }
00145 inline XnUInt64& Timestamp() { return m_output.nTimestamp; }
00146
00148 inline XnUInt32 FrameID() const { return m_output.nFrameID; }
00150 inline XnUInt32& FrameID() { return m_output.nFrameID; }
00151
00153 inline XnUInt32 DataSize() const { return m_output.nDataSize; }
00155 inline XnUInt32& DataSize() { return m_output.nDataSize; }
00156
00158 inline XnBool IsDataNew() const { return m_output.bIsNew; }
00160 inline XnBool& IsDataNew() { return m_output.bIsNew; }
00161
00163 inline const XnOutputMetaData* GetUnderlying() const { return &m_output; }
00165 inline XnOutputMetaData* GetUnderlying() { return &m_output; }
00166
00168 inline const XnUInt8* Data() const { return *m_ppData; }
00170 inline const XnUInt8*& Data() { return *m_ppData; }
00172 inline XnUInt8* WritableData()
00173 {
00174 MakeDataWritable();
00175 return m_pAllocatedData;
00176 }
00177
00184 XnStatus AllocateData(XnUInt32 nBytes)
00185 {
00186 if (nBytes > m_nAllocatedSize)
00187 {
00188
00189 XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN);
00190 XN_VALIDATE_ALLOC_PTR(pData);
00191
00192
00193 Free();
00194 m_pAllocatedData = pData;
00195 m_nAllocatedSize = nBytes;
00196 }
00197
00198 DataSize() = nBytes;
00199 *m_ppData = m_pAllocatedData;
00200
00201 return XN_STATUS_OK;
00202 }
00203
00207 void Free()
00208 {
00209 if (m_nAllocatedSize != 0)
00210 {
00211 xnOSFreeAligned(m_pAllocatedData);
00212 m_pAllocatedData = NULL;
00213 m_nAllocatedSize = 0;
00214 }
00215 }
00216
00221 XnStatus MakeDataWritable()
00222 {
00223 XnStatus nRetVal = XN_STATUS_OK;
00224
00225
00226 if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize)
00227 {
00228 const XnUInt8* pOrigData = *m_ppData;
00229
00230 nRetVal = AllocateData(DataSize());
00231 XN_IS_STATUS_OK(nRetVal);
00232
00233 if (pOrigData != NULL)
00234 {
00235 xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize());
00236 }
00237 else
00238 {
00239 xnOSMemSet(m_pAllocatedData, 0, DataSize());
00240 }
00241 }
00242
00243 return (XN_STATUS_OK);
00244 }
00245
00246 protected:
00247 XnUInt8* m_pAllocatedData;
00248
00249 private:
00250 XnOutputMetaData m_output;
00251
00252 const XnUInt8** m_ppData;
00253 XnUInt32 m_nAllocatedSize;
00254 };
00255
00260 class MapMetaData : public OutputMetaData
00261 {
00262 public:
00269 inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData)
00270 {
00271 xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData));
00272 m_map.pOutput = OutputMetaData::GetUnderlying();
00273 m_map.PixelFormat = format;
00274 }
00275
00277 inline XnUInt32 XRes() const { return m_map.Res.X; }
00279 inline XnUInt32& XRes() { return m_map.Res.X; }
00280
00282 inline XnUInt32 YRes() const { return m_map.Res.Y; }
00284 inline XnUInt32& YRes() { return m_map.Res.Y; }
00285
00287 inline XnUInt32 XOffset() const { return m_map.Offset.X; }
00289 inline XnUInt32& XOffset() { return m_map.Offset.X; }
00290
00292 inline XnUInt32 YOffset() const { return m_map.Offset.Y; }
00294 inline XnUInt32& YOffset() { return m_map.Offset.Y; }
00295
00297 inline XnUInt32 FullXRes() const { return m_map.FullRes.X; }
00299 inline XnUInt32& FullXRes() { return m_map.FullRes.X; }
00300
00302 inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; }
00304 inline XnUInt32& FullYRes() { return m_map.FullRes.Y; }
00305
00307 inline XnUInt32 FPS() const { return m_map.nFPS; }
00309 inline XnUInt32& FPS() { return m_map.nFPS; }
00310
00312 inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; }
00313
00315 inline const XnMapMetaData* GetUnderlying() const { return &m_map; }
00317 inline XnMapMetaData* GetUnderlying() { return &m_map; }
00318
00320 inline XnUInt32 BytesPerPixel() const
00321 {
00322 switch (PixelFormat())
00323 {
00324 case XN_PIXEL_FORMAT_RGB24:
00325 return sizeof(XnRGB24Pixel);
00326 case XN_PIXEL_FORMAT_YUV422:
00327 return sizeof(XnYUV422DoublePixel)/2;
00328 case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT:
00329 return sizeof(XnGrayscale8Pixel);
00330 case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT:
00331 return sizeof(XnGrayscale16Pixel);
00332 case XN_PIXEL_FORMAT_MJPEG:
00333 return 2;
00334 default:
00335 XN_ASSERT(FALSE);
00336 return 0;
00337 }
00338 }
00339
00346 XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes)
00347 {
00348 XnStatus nRetVal = XN_STATUS_OK;
00349
00350 XnUInt32 nSize = nXRes * nYRes * BytesPerPixel();
00351 nRetVal = OutputMetaData::AllocateData(nSize);
00352 XN_IS_STATUS_OK(nRetVal);
00353
00354 FullXRes() = XRes() = nXRes;
00355 FullYRes() = YRes() = nYRes;
00356 XOffset() = YOffset() = 0;
00357
00358 return (XN_STATUS_OK);
00359 }
00360
00369 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer)
00370 {
00371 XnStatus nRetVal = XN_STATUS_OK;
00372
00373 if (pExternalBuffer == NULL)
00374 {
00375 nRetVal = AllocateData(nXRes, nYRes);
00376 XN_IS_STATUS_OK(nRetVal);
00377 }
00378 else
00379 {
00380 FullXRes() = XRes() = nXRes;
00381 FullYRes() = YRes() = nYRes;
00382 XOffset() = YOffset() = 0;
00383 Data() = pExternalBuffer;
00384 DataSize() = nXRes * nYRes * BytesPerPixel();
00385 }
00386
00387 return (XN_STATUS_OK);
00388 }
00389
00390 protected:
00391 XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; }
00392
00393 private:
00394
00395 MapMetaData& operator=(const MapMetaData&);
00396 inline MapMetaData(const MapMetaData& other);
00397
00398
00399 XnMapMetaData m_map;
00400 };
00401
00402
00403 #define _XN_DECLARE_MAP_DATA_CLASS(_name, _pixelType) \
00404 class _name \
00405 { \
00406 public: \
00407 inline _name(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) : \
00408 m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes) {} \
00409 \
00410 inline XnUInt32 XRes() const { return m_nXRes; } \
00411 inline XnUInt32 YRes() const { return m_nYRes; } \
00412 \
00413 inline const _pixelType& operator[](XnUInt32 nIndex) const \
00414 { \
00415 XN_ASSERT(nIndex < (m_nXRes * m_nYRes)); \
00416 return m_pData[nIndex]; \
00417 } \
00418 inline _pixelType& operator[](XnUInt32 nIndex) \
00419 { \
00420 XN_ASSERT(nIndex < (m_nXRes *m_nYRes)); \
00421 return m_pData[nIndex]; \
00422 } \
00423 \
00424 inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const \
00425 { \
00426 XN_ASSERT(x < m_nXRes && y < m_nYRes); \
00427 return m_pData[y*m_nXRes + x]; \
00428 } \
00429 inline _pixelType& operator()(XnUInt32 x, XnUInt32 y) \
00430 { \
00431 XN_ASSERT(x < m_nXRes && y < m_nYRes); \
00432 return m_pData[y*m_nXRes + x]; \
00433 } \
00434 \
00435 private: \
00436 \
00437 _name(const _name& other); \
00438 _name& operator=(const _name&); \
00439 \
00440 _pixelType*& m_pData; \
00441 XnUInt32& m_nXRes; \
00442 XnUInt32& m_nYRes; \
00443 };
00444
00445 _XN_DECLARE_MAP_DATA_CLASS(DepthMap, XnDepthPixel);
00446 _XN_DECLARE_MAP_DATA_CLASS(ImageMap, XnUInt8);
00447 _XN_DECLARE_MAP_DATA_CLASS(RGB24Map, XnRGB24Pixel);
00448 _XN_DECLARE_MAP_DATA_CLASS(Grayscale16Map, XnGrayscale16Pixel);
00449 _XN_DECLARE_MAP_DATA_CLASS(Grayscale8Map, XnGrayscale8Pixel);
00450 _XN_DECLARE_MAP_DATA_CLASS(IRMap, XnIRPixel);
00451 _XN_DECLARE_MAP_DATA_CLASS(LabelMap, XnLabel);
00452
00457 class DepthMetaData : public MapMetaData
00458 {
00459 public:
00463 inline DepthMetaData() :
00464 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData),
00465 m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00466 m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00467 {
00468 xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData));
00469 m_depth.pMap = MapMetaData::GetUnderlying();
00470 }
00471
00477 inline void InitFrom(const DepthMetaData& other)
00478 {
00479 xnCopyDepthMetaData(&m_depth, &other.m_depth);
00480 }
00481
00491 inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer)
00492 {
00493 InitFrom(other);
00494 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00495 }
00496
00502 XnStatus CopyFrom(const DepthMetaData& other)
00503 {
00504
00505 InitFrom(other);
00506
00507 return MakeDataWritable();
00508 }
00509
00511 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL)
00512 {
00513 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00514 }
00515
00517 inline XnDepthPixel ZRes() const { return m_depth.nZRes; }
00519 inline XnDepthPixel& ZRes() { return m_depth.nZRes; }
00520
00522 inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); }
00524 inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); }
00526 inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); }
00527
00529 inline const xn::DepthMap& DepthMap() const { return m_depthMap; }
00531 inline xn::DepthMap& WritableDepthMap()
00532 {
00533 MakeDataWritable();
00534 return m_writableDepthMap;
00535 }
00536
00542 inline const XnDepthPixel& operator[](XnUInt32 nIndex) const
00543 {
00544 XN_ASSERT(nIndex < (XRes()*YRes()));
00545 return Data()[nIndex];
00546 }
00547
00554 inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const
00555 {
00556 XN_ASSERT(x < XRes() && y < YRes());
00557 return Data()[y*XRes() + x];
00558 }
00559
00561 inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; }
00563 inline XnDepthMetaData* GetUnderlying() { return &m_depth; }
00564
00565 private:
00566
00567 DepthMetaData(const DepthMetaData& other);
00568 DepthMetaData& operator=(const DepthMetaData&);
00569
00570 XnDepthMetaData m_depth;
00571 const xn::DepthMap m_depthMap;
00572 xn::DepthMap m_writableDepthMap;
00573 };
00574
00579 class ImageMetaData : public MapMetaData
00580 {
00581 public:
00583 inline ImageMetaData() :
00584 MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData),
00585 m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00586 m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00587 m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00588 m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00589 m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00590 m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00591 m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00592 m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00593 {
00594 xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData));
00595 m_image.pMap = MapMetaData::GetUnderlying();
00596 }
00597
00603 inline void InitFrom(const ImageMetaData& other)
00604 {
00605 xnCopyImageMetaData(&m_image, &other.m_image);
00606 }
00607
00618 inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer)
00619 {
00620 InitFrom(other);
00621 XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer);
00622 XN_IS_STATUS_OK(nRetVal);
00623 PixelFormat() = format;
00624 return XN_STATUS_OK;
00625 }
00626
00634 inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format)
00635 {
00636 XnPixelFormat origFormat = PixelFormat();
00637 PixelFormat() = format;
00638 XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes);
00639 if (nRetVal != XN_STATUS_OK)
00640 {
00641 PixelFormat() = origFormat;
00642 return (nRetVal);
00643 }
00644
00645 return XN_STATUS_OK;
00646 }
00647
00649 inline XnStatus CopyFrom(const ImageMetaData& other)
00650 {
00651
00652 xnCopyImageMetaData(&m_image, &other.m_image);
00653
00654 return MakeDataWritable();
00655 }
00656
00666 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL)
00667 {
00668 XnPixelFormat origFormat = PixelFormat();
00669 PixelFormat() = format;
00670 XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer);
00671 if (nRetVal != XN_STATUS_OK)
00672 {
00673 PixelFormat() = origFormat;
00674 return (nRetVal);
00675 }
00676
00677 return XN_STATUS_OK;
00678 }
00679
00681 inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); }
00683 inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); }
00684
00686 inline XnUInt8* WritableData() { return MapMetaData::WritableData(); }
00687
00689 inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); }
00691 inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); }
00693 inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); }
00694
00696 inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); }
00698 inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); }
00700 inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); }
00701
00703 inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); }
00705 inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); }
00707 inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); }
00708
00710 inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); }
00712 inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); }
00714 inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); }
00715
00717 inline const xn::ImageMap& ImageMap() const { return m_imageMap; }
00719 inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; }
00720
00722 inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; }
00724 inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; }
00725
00727 inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; }
00729 inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; }
00730
00732 inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; }
00734 inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; }
00735
00737 inline const XnImageMetaData* GetUnderlying() const { return &m_image; }
00739 inline XnImageMetaData* GetUnderlying() { return &m_image; }
00740
00741 private:
00742
00743 ImageMetaData(const ImageMetaData& other);
00744 ImageMetaData& operator=(const ImageMetaData&);
00745
00746 XnImageMetaData m_image;
00747 const xn::ImageMap m_imageMap;
00748 xn::ImageMap m_writableImageMap;
00749 const xn::RGB24Map m_rgb24Map;
00750 xn::RGB24Map m_writableRgb24Map;
00751 const xn::Grayscale16Map m_gray16Map;
00752 xn::Grayscale16Map m_writableGray16Map;
00753 const xn::Grayscale8Map m_gray8Map;
00754 xn::Grayscale8Map m_writableGray8Map;
00755 };
00756
00761 class IRMetaData : public MapMetaData
00762 {
00763 public:
00765 inline IRMetaData() :
00766 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData),
00767 m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00768 m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00769 {
00770 xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData));
00771 m_ir.pMap = MapMetaData::GetUnderlying();
00772 }
00773
00779 inline void InitFrom(const IRMetaData& other)
00780 {
00781 xnCopyIRMetaData(&m_ir, &other.m_ir);
00782 }
00783
00785 inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer)
00786 {
00787 InitFrom(other);
00788 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00789 }
00790
00792 XnStatus CopyFrom(const IRMetaData& other)
00793 {
00794
00795 xnCopyIRMetaData(&m_ir, &other.m_ir);
00796
00797 return MakeDataWritable();
00798 }
00799
00801 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL)
00802 {
00803 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00804 }
00805
00807 inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); }
00809 inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); }
00811 inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); }
00812
00818 inline const XnIRPixel& operator[](XnUInt32 nIndex) const
00819 {
00820 XN_ASSERT(nIndex < (XRes()*YRes()));
00821 return Data()[nIndex];
00822 }
00823
00830 inline const XnIRPixel& operator()(XnUInt32 x, XnUInt32 y) const
00831 {
00832 XN_ASSERT(x < XRes() && y < YRes());
00833 return Data()[y*XRes() + x];
00834 }
00835
00837 inline const xn::IRMap& IRMap() const { return m_irMap; }
00839 inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; }
00840
00842 inline const XnIRMetaData* GetUnderlying() const { return &m_ir; }
00844 inline XnIRMetaData* GetUnderlying() { return &m_ir; }
00845
00846 private:
00847
00848 IRMetaData(const IRMetaData& other);
00849 IRMetaData& operator=(const IRMetaData&);
00850
00851 XnIRMetaData m_ir;
00852 const xn::IRMap m_irMap;
00853 xn::IRMap m_writableIRMap;
00854 };
00855
00860 class AudioMetaData : public OutputMetaData
00861 {
00862 public:
00864 inline AudioMetaData() : OutputMetaData(&m_audio.pData)
00865 {
00866 xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData));
00867 m_audio.pOutput = OutputMetaData::GetUnderlying();
00868 }
00869
00875 inline void InitFrom(const AudioMetaData& other)
00876 {
00877 xnCopyAudioMetaData(&m_audio, &other.m_audio);
00878 }
00879
00881 inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; }
00883 inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; }
00884
00886 inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; }
00888 inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; }
00889
00891 inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; }
00893 inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; }
00894
00896 inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; }
00898 inline XnAudioMetaData* GetUnderlying() { return &m_audio; }
00899
00900 private:
00901
00902 AudioMetaData(const AudioMetaData& other);
00903 AudioMetaData& operator=(const AudioMetaData&);
00904
00905 XnAudioMetaData m_audio;
00906 XnBool m_bAllocated;
00907 };
00908
00913 class SceneMetaData : public MapMetaData
00914 {
00915 public:
00917 inline SceneMetaData() :
00918 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData),
00919 m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y),
00920 m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y)
00921 {
00922 xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData));
00923 m_scene.pMap = MapMetaData::GetUnderlying();
00924 }
00925
00931 inline void InitFrom(const SceneMetaData& other)
00932 {
00933 xnCopySceneMetaData(&m_scene, &other.m_scene);
00934 }
00935
00937 inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer)
00938 {
00939 InitFrom(other);
00940 return ReAdjust(nXRes, nYRes, pExternalBuffer);
00941 }
00942
00944 XnStatus CopyFrom(const SceneMetaData& other)
00945 {
00946
00947 xnCopySceneMetaData(&m_scene, &other.m_scene);
00948
00949 return MakeDataWritable();
00950 }
00951
00953 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL)
00954 {
00955 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer);
00956 }
00957
00959 inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); }
00961 inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); }
00963 inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); }
00964
00966 inline const xn::LabelMap& LabelMap() const { return m_labelMap; }
00968 inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; }
00969
00975 inline const XnLabel& operator[](XnUInt32 nIndex) const
00976 {
00977 XN_ASSERT(nIndex < (XRes()*YRes()));
00978 return Data()[nIndex];
00979 }
00980
00987 inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const
00988 {
00989 XN_ASSERT(x < XRes() && y < YRes());
00990 return (*this)[y*XRes() + x];
00991 }
00992
00994 inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; }
00996 inline XnSceneMetaData* GetUnderlying() { return &m_scene; }
00997
00998 private:
00999
01000 SceneMetaData(const SceneMetaData& other);
01001 SceneMetaData& operator=(const SceneMetaData&);
01002
01003 XnSceneMetaData m_scene;
01004 const xn::LabelMap m_labelMap;
01005 xn::LabelMap m_writableLabelMap;
01006 };
01007
01008
01009
01010
01011
01016 class NodeWrapper
01017 {
01018 public:
01019 friend class Context;
01020
01026 inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
01027 {
01028 NodeWrapper::SetHandle(hNode);
01029 }
01030
01031 inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL)
01032 {
01033 NodeWrapper::SetHandle(other.GetHandle());
01034 }
01035
01036 inline NodeWrapper& operator=(const NodeWrapper& other)
01037 {
01038 NodeWrapper::SetHandle(other.GetHandle());
01039 return *this;
01040 }
01041
01042 inline ~NodeWrapper()
01043 {
01044 NodeWrapper::SetHandle(NULL);
01045 }
01046
01047 inline operator XnNodeHandle() const { return GetHandle(); }
01048
01050 inline XnNodeHandle GetHandle() const { return m_hNode; }
01051
01057 inline XnBool operator==(const NodeWrapper& other)
01058 {
01059 return (GetHandle() == other.GetHandle());
01060 }
01061
01067 inline XnBool operator!=(const NodeWrapper& other)
01068 {
01069 return (GetHandle() != other.GetHandle());
01070 }
01071
01073 inline XnBool IsValid() const { return (GetHandle() != NULL); }
01074
01078 const XnChar* GetName() const {return xnGetNodeName(GetHandle()); }
01079
01083 inline XnStatus AddRef() { return xnProductionNodeAddRef(GetHandle()); }
01084
01088 inline void Release()
01089 {
01090 NodeWrapper::SetHandle(NULL);
01091 }
01092
01093 inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); }
01094 inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); }
01095
01097 inline void SetHandle(XnNodeHandle hNode)
01098 {
01099 if (m_hNode == hNode)
01100 {
01101
01102 return;
01103 }
01104
01105
01106 if (m_hNode != NULL)
01107 {
01108 XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode);
01109 xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback);
01110 xnContextRelease(pContext);
01111 xnProductionNodeRelease(m_hNode);
01112 }
01113
01114
01115 if (hNode != NULL)
01116 {
01117 XnStatus nRetVal = xnProductionNodeAddRef(hNode);
01118 XN_ASSERT(nRetVal == XN_STATUS_OK);
01119
01120 XnContext* pContext = xnGetRefContextFromNodeHandle(hNode);
01121
01122 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
01123 XN_ASSERT(nRetVal == XN_STATUS_OK);
01124
01125 xnContextRelease(pContext);
01126 }
01127
01128 m_hNode = hNode;
01129 }
01130
01131 inline void TakeOwnership(XnNodeHandle hNode)
01132 {
01133 SetHandle(hNode);
01134
01135 if (hNode != NULL)
01136 {
01137 xnProductionNodeRelease(hNode);
01138 }
01139 }
01140
01141 private:
01142 XnNodeHandle m_hNode;
01143 XnCallbackHandle m_hShuttingDownCallback;
01144
01145 static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* , void* pCookie)
01146 {
01147 NodeWrapper* pThis = (NodeWrapper*)pCookie;
01148 pThis->m_hNode = NULL;
01149 }
01150 };
01151
01152
01153
01154
01155
01160 class NodeInfo
01161 {
01162 public:
01168 NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
01169 {
01170 SetUnderlyingObject(pInfo);
01171 }
01172
01178 NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE)
01179 {
01180 SetUnderlyingObject(other.m_pInfo);
01181 }
01182
01184 ~NodeInfo()
01185 {
01186 SetUnderlyingObject(NULL);
01187 }
01188
01194 inline NodeInfo& operator=(const NodeInfo& other)
01195 {
01196 SetUnderlyingObject(other.m_pInfo);
01197 return *this;
01198 }
01199
01201 inline operator XnNodeInfo*()
01202 {
01203 return m_pInfo;
01204 }
01205
01209 inline XnStatus SetInstanceName(const XnChar* strName)
01210 {
01211 return xnNodeInfoSetInstanceName(m_pInfo, strName);
01212 }
01213
01217 inline const XnProductionNodeDescription& GetDescription() const
01218 {
01219 return *xnNodeInfoGetDescription(m_pInfo);
01220 }
01221
01225 inline const XnChar* GetInstanceName() const
01226 {
01227 return xnNodeInfoGetInstanceName(m_pInfo);
01228 }
01229
01233 inline const XnChar* GetCreationInfo() const
01234 {
01235 return xnNodeInfoGetCreationInfo(m_pInfo);
01236 }
01237
01241 inline NodeInfoList& GetNeededNodes() const;
01242
01250 inline XnStatus GetInstance(ProductionNode& node) const;
01251
01255 inline const void* GetAdditionalData() const
01256 {
01257 return xnNodeInfoGetAdditionalData(m_pInfo);
01258 }
01259
01263 inline XnStatus GetTreeStringRepresentation(XnChar* csResultBuffer, XnUInt32 nBufferSize) const
01264 {
01265 return xnNodeInfoGetTreeStringRepresentation(m_pInfo, csResultBuffer, nBufferSize);
01266 }
01267
01268 private:
01269 inline void SetUnderlyingObject(XnNodeInfo* pInfo);
01270
01271 XnNodeInfo* m_pInfo;
01272 mutable NodeInfoList* m_pNeededNodes;
01273 XnBool m_bOwnerOfNode;
01274 friend class Context;
01275 };
01276
01277
01278
01279
01280
01286 class Query
01287 {
01288 public:
01290 inline Query() : m_bAllocated(TRUE)
01291 {
01292 xnNodeQueryAllocate(&m_pQuery);
01293 }
01294
01295 inline Query(XnNodeQuery* pNodeQuery) : m_bAllocated(FALSE), m_pQuery(pNodeQuery)
01296 {
01297 }
01298
01300 ~Query()
01301 {
01302 if (m_bAllocated)
01303 {
01304 xnNodeQueryFree(m_pQuery);
01305 }
01306 }
01307
01309 inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; }
01310 inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; }
01311
01315 inline XnStatus SetVendor(const XnChar* strVendor)
01316 {
01317 return xnNodeQuerySetVendor(m_pQuery, strVendor);
01318 }
01319
01323 inline XnStatus SetName(const XnChar* strName)
01324 {
01325 return xnNodeQuerySetName(m_pQuery, strName);
01326 }
01327
01331 inline XnStatus SetMinVersion(const XnVersion& minVersion)
01332 {
01333 return xnNodeQuerySetMinVersion(m_pQuery, &minVersion);
01334 }
01335
01339 inline XnStatus SetMaxVersion(const XnVersion& maxVersion)
01340 {
01341 return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion);
01342 }
01343
01347 inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability)
01348 {
01349 return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability);
01350 }
01351
01355 inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode)
01356 {
01357 return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode);
01358 }
01359
01363 inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount)
01364 {
01365 return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount);
01366 }
01367
01371 inline XnStatus SetExistingNodeOnly(XnBool bExistingNode)
01372 {
01373 return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode);
01374 }
01375
01379 inline XnStatus AddNeededNode(const XnChar* strInstanceName)
01380 {
01381 return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName);
01382 }
01383
01387 inline XnStatus SetCreationInfo(const XnChar* strCreationInfo)
01388 {
01389 return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo);
01390 }
01391
01392 private:
01393 XnNodeQuery* m_pQuery;
01394 XnBool m_bAllocated;
01395 };
01396
01397
01398
01399
01400
01405 class NodeInfoList
01406 {
01407 public:
01409 class Iterator
01410 {
01411 public:
01412 friend class NodeInfoList;
01413
01419 XnBool operator==(const Iterator& other) const
01420 {
01421 return m_it.pCurrent == other.m_it.pCurrent;
01422 }
01423
01429 XnBool operator!=(const Iterator& other) const
01430 {
01431 return m_it.pCurrent != other.m_it.pCurrent;
01432 }
01433
01438 inline Iterator& operator++()
01439 {
01440 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01441 return *this;
01442 }
01443
01448 inline Iterator operator++(int)
01449 {
01450 XnNodeInfoListIterator curr = m_it;
01451 UpdateInternalObject(xnNodeInfoListGetNext(m_it));
01452 return Iterator(curr);
01453 }
01454
01458 inline Iterator& operator--()
01459 {
01460 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01461 return *this;
01462 }
01463
01467 inline Iterator operator--(int)
01468 {
01469 XnNodeInfoListIterator curr = m_it;
01470 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it));
01471 return Iterator(curr);
01472 }
01473
01475 inline NodeInfo operator*()
01476 {
01477 return m_Info;
01478 }
01479
01480 private:
01481 inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL)
01482 {
01483 UpdateInternalObject(it);
01484 }
01485
01486 inline void UpdateInternalObject(XnNodeInfoListIterator it)
01487 {
01488 m_it = it;
01489 if (xnNodeInfoListIteratorIsValid(it))
01490 {
01491 XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it);
01492 m_Info = NodeInfo(pInfo);
01493 }
01494 else
01495 {
01496 m_Info = NodeInfo(NULL);
01497 }
01498 }
01499
01500 NodeInfo m_Info;
01501 XnNodeInfoListIterator m_it;
01502 };
01503
01507 inline NodeInfoList()
01508 {
01509 xnNodeInfoListAllocate(&m_pList);
01510 m_bAllocated = TRUE;
01511 }
01512
01519 inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {}
01520
01522 inline ~NodeInfoList()
01523 {
01524 FreeImpl();
01525 }
01526
01528 inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; }
01529
01536 inline void ReplaceUnderlyingObject(XnNodeInfoList* pList)
01537 {
01538 FreeImpl();
01539 m_pList = pList;
01540 m_bAllocated = TRUE;
01541 }
01542
01546 inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes)
01547 {
01548 XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01549 return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList);
01550 }
01551
01555 inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler)
01556 {
01557 XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject();
01558 return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler);
01559 }
01560
01564 inline XnStatus AddNode(NodeInfo& info)
01565 {
01566 return xnNodeInfoListAddNode(m_pList, info);
01567 }
01568
01572 inline XnStatus AddNodeFromAnotherList(Iterator& it)
01573 {
01574 return xnNodeInfoListAddNodeFromList(m_pList, it.m_it);
01575 }
01576
01578 inline Iterator Begin() const
01579 {
01580 return Iterator(xnNodeInfoListGetFirst(m_pList));
01581 }
01582
01584 inline Iterator End() const
01585 {
01586 XnNodeInfoListIterator it = { NULL };
01587 return Iterator(it);
01588 }
01589
01591 inline Iterator RBegin() const
01592 {
01593 return Iterator(xnNodeInfoListGetLast(m_pList));
01594 }
01595
01597 inline Iterator REnd() const
01598 {
01599 XnNodeInfoListIterator it = { NULL };
01600 return Iterator(it);
01601 }
01602
01606 inline XnStatus Remove(Iterator& it)
01607 {
01608 return xnNodeInfoListRemove(m_pList, it.m_it);
01609 }
01610
01614 inline XnStatus Clear()
01615 {
01616 return xnNodeInfoListClear(m_pList);
01617 }
01618
01622 inline XnStatus Append(NodeInfoList& other)
01623 {
01624 return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject());
01625 }
01626
01630 inline XnBool IsEmpty()
01631 {
01632 return xnNodeInfoListIsEmpty(m_pList);
01633 }
01634
01638 inline XnStatus FilterList(Context& context, Query& query);
01639
01640 private:
01641 inline void FreeImpl()
01642 {
01643 if (m_bAllocated)
01644 {
01645 xnNodeInfoListFree(m_pList);
01646 m_bAllocated = FALSE;
01647 m_pList = NULL;
01648 }
01649 }
01650
01651 XnNodeInfoList* m_pList;
01652 XnBool m_bAllocated;
01653 };
01654
01655
01656
01657
01658
01663 class Capability : public NodeWrapper
01664 {
01665 public:
01671 Capability(XnNodeHandle hNode) : NodeWrapper(hNode) {}
01672 Capability(const NodeWrapper& node) : NodeWrapper(node) {}
01673 };
01674
01679 class ErrorStateCapability : public Capability
01680 {
01681 public:
01687 ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {}
01688 ErrorStateCapability(const NodeWrapper& node) : Capability(node) {}
01689
01693 inline XnStatus GetErrorState() const
01694 {
01695 return xnGetNodeErrorState(GetHandle());
01696 }
01697
01701 inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
01702 {
01703 return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback);
01704 }
01705
01709 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
01710 {
01711 _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback);
01712 }
01713 };
01714
01719 class GeneralIntCapability : public Capability
01720 {
01721 public:
01728 GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {}
01729 GeneralIntCapability(const NodeWrapper& node) : Capability(node) {}
01730
01734 inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const
01735 {
01736 xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported);
01737 }
01738
01742 inline XnInt32 Get()
01743 {
01744 XnInt32 nValue;
01745 xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue);
01746 return nValue;
01747 }
01748
01752 inline XnStatus Set(XnInt32 nValue)
01753 {
01754 return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue);
01755 }
01756
01760 XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback);
01761
01765 void UnregisterFromValueChange(XnCallbackHandle hCallback);
01766
01767 private:
01768 const XnChar* m_strCap;
01769 };
01770
01775 class ProductionNode : public NodeWrapper
01776 {
01777 public:
01783 inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {}
01784 inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {}
01785
01789 inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); }
01790
01794 inline XnStatus AddNeededNode(ProductionNode& needed)
01795 {
01796 return xnAddNeededNode(GetHandle(), needed.GetHandle());
01797 }
01798
01802 inline XnStatus RemoveNeededNode(ProductionNode& needed)
01803 {
01804 return xnRemoveNeededNode(GetHandle(), needed.GetHandle());
01805 }
01806
01810 inline void GetContext(Context& context) const;
01811
01815 inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const
01816 {
01817 return xnIsCapabilitySupported(GetHandle(), strCapabilityName);
01818 }
01819
01823 inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue)
01824 {
01825 return xnSetIntProperty(GetHandle(), strName, nValue);
01826 }
01827
01831 inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue)
01832 {
01833 return xnSetRealProperty(GetHandle(), strName, dValue);
01834 }
01835
01839 inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue)
01840 {
01841 return xnSetStringProperty(GetHandle(), strName, strValue);
01842 }
01843
01847 inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer)
01848 {
01849 return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01850 }
01851
01855 inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const
01856 {
01857 return xnGetIntProperty(GetHandle(), strName, &nValue);
01858 }
01859
01863 inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const
01864 {
01865 return xnGetRealProperty(GetHandle(), strName, &dValue);
01866 }
01867
01871 inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const
01872 {
01873 return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize);
01874 }
01875
01879 inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const
01880 {
01881 return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer);
01882 }
01883
01887 inline XnStatus LockForChanges(XnLockHandle* phLock)
01888 {
01889 return xnLockNodeForChanges(GetHandle(), phLock);
01890 }
01891
01895 inline void UnlockForChanges(XnLockHandle hLock)
01896 {
01897 xnUnlockNodeForChanges(GetHandle(), hLock);
01898 }
01899
01903 inline XnStatus LockedNodeStartChanges(XnLockHandle hLock)
01904 {
01905 return xnLockedNodeStartChanges(GetHandle(), hLock);
01906 }
01907
01911 inline void LockedNodeEndChanges(XnLockHandle hLock)
01912 {
01913 xnLockedNodeEndChanges(GetHandle(), hLock);
01914 }
01915
01921 inline const ErrorStateCapability GetErrorStateCap() const
01922 {
01923 return ErrorStateCapability(GetHandle());
01924 }
01925
01931 inline ErrorStateCapability GetErrorStateCap()
01932 {
01933 return ErrorStateCapability(GetHandle());
01934 }
01935
01943 inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability)
01944 {
01945 return GeneralIntCapability(GetHandle(), strCapability);
01946 }
01947 };
01948
01953 class DeviceIdentificationCapability : public Capability
01954 {
01955 public:
01961 DeviceIdentificationCapability(XnNodeHandle hNode) : Capability(hNode) {}
01962 DeviceIdentificationCapability(const NodeWrapper& node) : Capability(node) {}
01963
01967 inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize)
01968 {
01969 return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize);
01970 }
01971
01975 inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize)
01976 {
01977 return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize);
01978 }
01979
01983 inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize)
01984 {
01985 return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize);
01986 }
01987 };
01988
01993 class Device : public ProductionNode
01994 {
01995 public:
02001 inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02002 inline Device(const NodeWrapper& other) : ProductionNode(other) {}
02003
02007 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
02008
02014 inline DeviceIdentificationCapability GetIdentificationCap()
02015 {
02016 return DeviceIdentificationCapability(GetHandle());
02017 }
02018 };
02019
02024 class MirrorCapability : public Capability
02025 {
02026 public:
02032 inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {}
02033 MirrorCapability(const NodeWrapper& node) : Capability(node) {}
02034
02038 inline XnStatus SetMirror(XnBool bMirror)
02039 {
02040 return xnSetMirror(GetHandle(), bMirror);
02041 }
02042
02046 inline XnBool IsMirrored() const
02047 {
02048 return xnIsMirrored(GetHandle());
02049 }
02050
02054 inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02055 {
02056 return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback);
02057 }
02058
02062 inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback)
02063 {
02064 _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback);
02065 }
02066 };
02067
02072 class AlternativeViewPointCapability : public Capability
02073 {
02074 public:
02080 inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {}
02081 AlternativeViewPointCapability(const NodeWrapper& node) : Capability(node) {}
02082
02086 inline XnBool IsViewPointSupported(ProductionNode& otherNode) const
02087 {
02088 return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle());
02089 }
02090
02094 inline XnStatus SetViewPoint(ProductionNode& otherNode)
02095 {
02096 return xnSetViewPoint(GetHandle(), otherNode.GetHandle());
02097 }
02098
02102 inline XnStatus ResetViewPoint()
02103 {
02104 return xnResetViewPoint(GetHandle());
02105 }
02106
02110 inline XnBool IsViewPointAs(ProductionNode& otherNode) const
02111 {
02112 return xnIsViewPointAs(GetHandle(), otherNode.GetHandle());
02113 }
02114
02118 inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02119 {
02120 return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback);
02121 }
02122
02126 inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback)
02127 {
02128 _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback);
02129 }
02130 };
02131
02136 class FrameSyncCapability : public Capability
02137 {
02138 public:
02144 inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {}
02145 FrameSyncCapability(const NodeWrapper& node) : Capability(node) {}
02146
02150 inline XnBool CanFrameSyncWith(Generator& other) const;
02151
02155 inline XnStatus FrameSyncWith(Generator& other);
02156
02160 inline XnStatus StopFrameSyncWith(Generator& other);
02161
02165 inline XnBool IsFrameSyncedWith(Generator& other) const;
02166
02170 inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02171 {
02172 return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback);
02173 }
02174
02178 inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback)
02179 {
02180 _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback);
02181 }
02182 };
02183
02188 class Generator : public ProductionNode
02189 {
02190 public:
02196 inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02197 inline Generator(const NodeWrapper& other) : ProductionNode(other) {}
02198
02202 inline XnStatus StartGenerating()
02203 {
02204 return xnStartGenerating(GetHandle());
02205 }
02206
02210 inline XnBool IsGenerating() const
02211 {
02212 return xnIsGenerating(GetHandle());
02213 }
02214
02218 inline XnStatus StopGenerating()
02219 {
02220 return xnStopGenerating(GetHandle());
02221 }
02222
02226 inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02227 {
02228 return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback);
02229 }
02230
02234 inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback)
02235 {
02236 _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback);
02237 }
02238
02242 inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback)
02243 {
02244 return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback);
02245 }
02246
02250 inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback)
02251 {
02252 _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback);
02253 }
02254
02258 inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const
02259 {
02260 return xnIsNewDataAvailable(GetHandle(), pnTimestamp);
02261 }
02262
02266 inline XnStatus WaitAndUpdateData()
02267 {
02268 return xnWaitAndUpdateData(GetHandle());
02269 }
02270
02274 inline XnBool IsDataNew() const
02275 {
02276 return xnIsDataNew(GetHandle());
02277 }
02278
02282 inline const void* GetData()
02283 {
02284 return xnGetData(GetHandle());
02285 }
02286
02290 inline XnUInt32 GetDataSize() const
02291 {
02292 return xnGetDataSize(GetHandle());
02293 }
02294
02298 inline XnUInt64 GetTimestamp() const
02299 {
02300 return xnGetTimestamp(GetHandle());
02301 }
02302
02306 inline XnUInt32 GetFrameID() const
02307 {
02308 return xnGetFrameID(GetHandle());
02309 }
02310
02316 inline const MirrorCapability GetMirrorCap() const
02317 {
02318 return MirrorCapability(GetHandle());
02319 }
02320
02326 inline MirrorCapability GetMirrorCap()
02327 {
02328 return MirrorCapability(GetHandle());
02329 }
02330
02336 inline const AlternativeViewPointCapability GetAlternativeViewPointCap() const
02337 {
02338 return AlternativeViewPointCapability(GetHandle());
02339 }
02340
02346 inline AlternativeViewPointCapability GetAlternativeViewPointCap()
02347 {
02348 return AlternativeViewPointCapability(GetHandle());
02349 }
02350
02356 inline const FrameSyncCapability GetFrameSyncCap() const
02357 {
02358 return FrameSyncCapability(GetHandle());
02359 }
02360
02366 inline FrameSyncCapability GetFrameSyncCap()
02367 {
02368 return FrameSyncCapability(GetHandle());
02369 }
02370 };
02371
02376 class Recorder : public ProductionNode
02377 {
02378 public:
02384 inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02385 inline Recorder(const NodeWrapper& other) : ProductionNode(other) {}
02386
02390 inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL);
02391
02395 inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest)
02396 {
02397 return xnSetRecorderDestination(GetHandle(), destType, strDest);
02398 }
02399
02400 inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize)
02401 {
02402 return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize);
02403 }
02404
02408 inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL)
02409 {
02410 return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression);
02411 }
02412
02416 inline XnStatus RemoveNodeFromRecording(ProductionNode& Node)
02417 {
02418 return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle());
02419 }
02420
02424 inline XnStatus Record()
02425 {
02426 return xnRecord(GetHandle());
02427 }
02428 };
02429
02434 class Player : public ProductionNode
02435 {
02436 public:
02442 inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
02443 inline Player(const NodeWrapper& other) : ProductionNode(other) {}
02444
02448 inline XnStatus Create(Context& context, const XnChar* strFormatName);
02449
02453 inline XnStatus SetRepeat(XnBool bRepeat)
02454 {
02455 return xnSetPlayerRepeat(GetHandle(), bRepeat);
02456 }
02457
02461 inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource)
02462 {
02463 return xnSetPlayerSource(GetHandle(), sourceType, strSource);
02464 }
02465
02469 inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const
02470 {
02471 return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize);
02472 }
02473
02477 inline XnStatus ReadNext()
02478 {
02479 return xnPlayerReadNext(GetHandle());
02480 }
02481
02485 inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin)
02486 {
02487 return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin);
02488 }
02489
02493 inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin)
02494 {
02495 return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin);
02496 }
02497
02501 inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const
02502 {
02503 return xnTellPlayerTimestamp(GetHandle(), &nTimestamp);
02504 }
02505
02509 inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const
02510 {
02511 return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame);
02512 }
02513
02517 inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const
02518 {
02519 return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames);
02520 }
02521
02525 inline const XnChar* GetSupportedFormat() const
02526 {
02527 return xnGetPlayerSupportedFormat(GetHandle());
02528 }
02529
02533 inline XnStatus EnumerateNodes(NodeInfoList& list) const
02534 {
02535 XnNodeInfoList* pList;
02536 XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList);
02537 XN_IS_STATUS_OK(nRetVal);
02538
02539 list.ReplaceUnderlyingObject(pList);
02540
02541 return (XN_STATUS_OK);
02542 }
02543
02547 inline XnBool IsEOF() const
02548 {
02549 return xnIsPlayerAtEOF(GetHandle());
02550 }
02551
02555 inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02556 {
02557 return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback);
02558 }
02559
02563 inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback)
02564 {
02565 _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback);
02566 }
02567
02571 inline XnStatus SetPlaybackSpeed(XnDouble dSpeed)
02572 {
02573 return xnSetPlaybackSpeed(GetHandle(), dSpeed);
02574 }
02575
02579 inline XnDouble GetPlaybackSpeed() const
02580 {
02581 return xnGetPlaybackSpeed(GetHandle());
02582 }
02583 };
02584
02589 class CroppingCapability : public Capability
02590 {
02591 public:
02597 inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {}
02598 CroppingCapability(const NodeWrapper& node) : Capability(node) {}
02599
02603 inline XnStatus SetCropping(const XnCropping& Cropping)
02604 {
02605 return xnSetCropping(GetHandle(), &Cropping);
02606 }
02607
02611 inline XnStatus GetCropping(XnCropping& Cropping) const
02612 {
02613 return xnGetCropping(GetHandle(), &Cropping);
02614 }
02615
02619 inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02620 {
02621 return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback);
02622 }
02623
02627 inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback)
02628 {
02629 _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback);
02630 }
02631 };
02632
02637 class AntiFlickerCapability : public Capability
02638 {
02639 public:
02645 inline AntiFlickerCapability(XnNodeHandle hNode) : Capability(hNode) {}
02646 AntiFlickerCapability(const NodeWrapper& node) : Capability(node) {}
02647
02651 inline XnStatus SetPowerLineFrequency(XnPowerLineFrequency nFrequency)
02652 {
02653 return xnSetPowerLineFrequency(GetHandle(), nFrequency);
02654 }
02655
02659 inline XnPowerLineFrequency GetPowerLineFrequency()
02660 {
02661 return xnGetPowerLineFrequency(GetHandle());
02662 }
02663
02667 inline XnStatus RegisterToPowerLineFrequencyChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02668 {
02669 return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback);
02670 }
02671
02675 inline void UnregisterFromPowerLineFrequencyChange(XnCallbackHandle hCallback)
02676 {
02677 _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback);
02678 }
02679 };
02680
02685 class MapGenerator : public Generator
02686 {
02687 public:
02693 inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
02694 inline MapGenerator(const NodeWrapper& other) : Generator(other) {}
02695
02699 inline XnUInt32 GetSupportedMapOutputModesCount() const
02700 {
02701 return xnGetSupportedMapOutputModesCount(GetHandle());
02702 }
02703
02707 inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const
02708 {
02709 return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount);
02710 }
02711
02715 inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode)
02716 {
02717 return xnSetMapOutputMode(GetHandle(), &OutputMode);
02718 }
02719
02723 inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const
02724 {
02725 return xnGetMapOutputMode(GetHandle(), &OutputMode);
02726 }
02727
02731 inline XnUInt32 GetBytesPerPixel() const
02732 {
02733 return xnGetBytesPerPixel(GetHandle());
02734 }
02735
02739 inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02740 {
02741 return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback);
02742 }
02743
02747 inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback)
02748 {
02749 _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback);
02750 }
02751
02757 inline const CroppingCapability GetCroppingCap() const
02758 {
02759 return CroppingCapability(GetHandle());
02760 }
02761
02767 inline CroppingCapability GetCroppingCap()
02768 {
02769 return CroppingCapability(GetHandle());
02770 }
02771
02777 inline GeneralIntCapability GetBrightnessCap()
02778 {
02779 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BRIGHTNESS);
02780 }
02781
02787 inline GeneralIntCapability GetContrastCap()
02788 {
02789 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_CONTRAST);
02790 }
02791
02797 inline GeneralIntCapability GetHueCap()
02798 {
02799 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_HUE);
02800 }
02801
02807 inline GeneralIntCapability GetSaturationCap()
02808 {
02809 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SATURATION);
02810 }
02811
02817 inline GeneralIntCapability GetSharpnessCap()
02818 {
02819 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SHARPNESS);
02820 }
02821
02827 inline GeneralIntCapability GetGammaCap()
02828 {
02829 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAMMA);
02830 }
02831
02837 inline GeneralIntCapability GetWhiteBalanceCap()
02838 {
02839 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_COLOR_TEMPERATURE);
02840 }
02841
02847 inline GeneralIntCapability GetBacklightCompensationCap()
02848 {
02849 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BACKLIGHT_COMPENSATION);
02850 }
02851
02857 inline GeneralIntCapability GetGainCap()
02858 {
02859 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAIN);
02860 }
02861
02867 inline GeneralIntCapability GetPanCap()
02868 {
02869 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_PAN);
02870 }
02871
02877 inline GeneralIntCapability GetTiltCap()
02878 {
02879 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_TILT);
02880 }
02881
02887 inline GeneralIntCapability GetRollCap()
02888 {
02889 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ROLL);
02890 }
02891
02897 inline GeneralIntCapability GetZoomCap()
02898 {
02899 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ZOOM);
02900 }
02901
02907 inline GeneralIntCapability GetExposureCap()
02908 {
02909 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_EXPOSURE);
02910 }
02911
02917 inline GeneralIntCapability GetIrisCap()
02918 {
02919 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_IRIS);
02920 }
02921
02927 inline GeneralIntCapability GetFocusCap()
02928 {
02929 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_FOCUS);
02930 }
02931
02937 inline GeneralIntCapability GetLowLightCompensationCap()
02938 {
02939 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_LOW_LIGHT_COMPENSATION);
02940 }
02941
02947 inline AntiFlickerCapability GetAntiFlickerCap()
02948 {
02949 return AntiFlickerCapability(GetHandle());
02950 }
02951 };
02952
02957 class UserPositionCapability : public Capability
02958 {
02959 public:
02965 inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {}
02966 UserPositionCapability(const NodeWrapper& node) : Capability(node) {}
02967
02971 inline XnUInt32 GetSupportedUserPositionsCount() const
02972 {
02973 return xnGetSupportedUserPositionsCount(GetHandle());
02974 }
02975
02979 inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position)
02980 {
02981 return xnSetUserPosition(GetHandle(), nIndex, &Position);
02982 }
02983
02987 inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const
02988 {
02989 return xnGetUserPosition(GetHandle(), nIndex, &Position);
02990 }
02991
02995 inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
02996 {
02997 return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback);
02998 }
02999
03003 inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback)
03004 {
03005 _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback);
03006 }
03007 };
03008
03013 class DepthGenerator : public MapGenerator
03014 {
03015 public:
03021 inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03022 inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03023
03027 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03028
03032 inline void GetMetaData(DepthMetaData& metaData) const
03033 {
03034 xnGetDepthMetaData(GetHandle(), metaData.GetUnderlying());
03035 }
03036
03040 inline const XnDepthPixel* GetDepthMap() const
03041 {
03042 return xnGetDepthMap(GetHandle());
03043 }
03044
03048 inline XnDepthPixel GetDeviceMaxDepth() const
03049 {
03050 return xnGetDeviceMaxDepth(GetHandle());
03051 }
03052
03056 inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const
03057 {
03058 return xnGetDepthFieldOfView(GetHandle(), &FOV);
03059 }
03060
03064 inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03065 {
03066 return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback);
03067 }
03068
03072 inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback)
03073 {
03074 _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback);
03075 }
03076
03080 inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const
03081 {
03082 return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld);
03083 }
03084
03088 inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const
03089 {
03090 return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective);
03091 }
03092
03098 inline const UserPositionCapability GetUserPositionCap() const
03099 {
03100 return UserPositionCapability(GetHandle());
03101 }
03102
03108 inline UserPositionCapability GetUserPositionCap()
03109 {
03110 return UserPositionCapability(GetHandle());
03111 }
03112 };
03113
03118 class MockDepthGenerator : public DepthGenerator
03119 {
03120 public:
03126 inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {}
03127 inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {}
03128
03135 XnStatus Create(Context& context, const XnChar* strName = NULL);
03136
03143 XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL);
03144
03148 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap)
03149 {
03150 return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap);
03151 }
03152
03160 inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03161 {
03162 return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data());
03163 }
03164
03170 inline XnStatus SetData(const DepthMetaData& depthMD)
03171 {
03172 return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp());
03173 }
03174 };
03175
03180 class ImageGenerator : public MapGenerator
03181 {
03182 public:
03188 inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03189 inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03190
03194 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03195
03199 inline void GetMetaData(ImageMetaData& metaData) const
03200 {
03201 xnGetImageMetaData(GetHandle(), metaData.GetUnderlying());
03202 }
03203
03207 inline const XnRGB24Pixel* GetRGB24ImageMap() const
03208 {
03209 return xnGetRGB24ImageMap(GetHandle());
03210 }
03211
03215 inline const XnYUV422DoublePixel* GetYUV422ImageMap() const
03216 {
03217 return xnGetYUV422ImageMap(GetHandle());
03218 }
03219
03223 inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const
03224 {
03225 return xnGetGrayscale8ImageMap(GetHandle());
03226 }
03227
03231 inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const
03232 {
03233 return xnGetGrayscale16ImageMap(GetHandle());
03234 }
03235
03239 inline const XnUInt8* GetImageMap() const
03240 {
03241 return xnGetImageMap(GetHandle());
03242 }
03243
03247 inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const
03248 {
03249 return xnIsPixelFormatSupported(GetHandle(), Format);
03250 }
03251
03255 inline XnStatus SetPixelFormat(XnPixelFormat Format)
03256 {
03257 return xnSetPixelFormat(GetHandle(), Format);
03258 }
03259
03263 inline XnPixelFormat GetPixelFormat() const
03264 {
03265 return xnGetPixelFormat(GetHandle());
03266 }
03267
03271 inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03272 {
03273 return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback);
03274 }
03275
03279 inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback)
03280 {
03281 _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback);
03282 }
03283 };
03284
03289 class MockImageGenerator : public ImageGenerator
03290 {
03291 public:
03297 inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {}
03298 inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {}
03299
03306 XnStatus Create(Context& context, const XnChar* strName = NULL);
03307
03314 XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL);
03315
03319 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap)
03320 {
03321 return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap);
03322 }
03323
03331 inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03332 {
03333 return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data());
03334 }
03335
03341 inline XnStatus SetData(const ImageMetaData& imageMD)
03342 {
03343 return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp());
03344 }
03345 };
03346
03351 class IRGenerator : public MapGenerator
03352 {
03353 public:
03359 inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03360 inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {}
03361
03365 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03366
03370 inline void GetMetaData(IRMetaData& metaData) const
03371 {
03372 xnGetIRMetaData(GetHandle(), metaData.GetUnderlying());
03373 }
03374
03378 inline const XnIRPixel* GetIRMap() const
03379 {
03380 return xnGetIRMap(GetHandle());
03381 }
03382 };
03383
03388 class MockIRGenerator : public IRGenerator
03389 {
03390 public:
03396 inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {}
03397 inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {}
03398
03405 XnStatus Create(Context& context, const XnChar* strName = NULL);
03412 XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL);
03413
03417 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap)
03418 {
03419 return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap);
03420 }
03421
03429 inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
03430 {
03431 return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data());
03432 }
03433
03439 inline XnStatus SetData(const IRMetaData& irMD)
03440 {
03441 return SetData(irMD, irMD.FrameID(), irMD.Timestamp());
03442 }
03443 };
03444
03449 class GestureGenerator : public Generator
03450 {
03451 public:
03457 inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03458 inline GestureGenerator(const NodeWrapper& other) : Generator(other) {}
03459
03463 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03464
03468 inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea)
03469 {
03470 return xnAddGesture(GetHandle(), strGesture, pArea);
03471 }
03472
03476 inline XnStatus RemoveGesture(const XnChar* strGesture)
03477 {
03478 return xnRemoveGesture(GetHandle(), strGesture);
03479 }
03480
03484 inline XnStatus GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03485 {
03486 return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures);
03487 }
03488
03492 inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03493 {
03494 return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03495 }
03496
03500 inline XnStatus EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const
03501 {
03502 return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures);
03503 }
03504
03508 inline XnUInt16 GetNumberOfAvailableGestures() const
03509 {
03510 return xnGetNumberOfAvailableGestures(GetHandle());
03511 }
03512
03516 inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const
03517 {
03518 return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures);
03519 }
03520
03524 inline XnBool IsGestureAvailable(const XnChar* strGesture) const
03525 {
03526 return xnIsGestureAvailable(GetHandle(), strGesture);
03527 }
03528
03532 inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const
03533 {
03534 return xnIsGestureProgressSupported(GetHandle(), strGesture);
03535 }
03536
03546 typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie);
03556 typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie);
03557
03561 XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback)
03562 {
03563 XnStatus nRetVal = XN_STATUS_OK;
03564
03565 GestureCookie* pGestureCookie;
03566 XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie);
03567 pGestureCookie->recognizedHandler = RecognizedCB;
03568 pGestureCookie->progressHandler = ProgressCB;
03569 pGestureCookie->pUserCookie = pCookie;
03570
03571 nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback);
03572 if (nRetVal != XN_STATUS_OK)
03573 {
03574 xnOSFree(pGestureCookie);
03575 return (nRetVal);
03576 }
03577
03578 hCallback = pGestureCookie;
03579
03580 return (XN_STATUS_OK);
03581 }
03582
03586 inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback)
03587 {
03588 GestureCookie* pGestureCookie = (GestureCookie*)hCallback;
03589 xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback);
03590 xnOSFree(pGestureCookie);
03591 }
03592
03596 inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
03597 {
03598 return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback);
03599 }
03600
03604 inline void UnregisterFromGestureChange(XnCallbackHandle hCallback)
03605 {
03606 _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback);
03607 }
03608
03617 typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03621 XnStatus RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompleted handler, void* pCookie, XnCallbackHandle& hCallback)
03622 {
03623 XnStatus nRetVal = XN_STATUS_OK;
03624
03625 GestureIntermediateStageCompletedCookie* pGestureCookie;
03626 XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie);
03627 pGestureCookie->handler = handler;
03628 pGestureCookie->pUserCookie = pCookie;
03629
03630 nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback);
03631 if (nRetVal != XN_STATUS_OK)
03632 {
03633 xnOSFree(pGestureCookie);
03634 return (nRetVal);
03635 }
03636
03637 hCallback = pGestureCookie;
03638
03639 return (XN_STATUS_OK);
03640 }
03644 inline void UnregisterFromGestureIntermediateStageCompleted(XnCallbackHandle hCallback)
03645 {
03646 GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback;
03647 xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback);
03648 xnOSFree(pGestureCookie);
03649 }
03650
03659 typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie);
03663 XnStatus RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStage handler, void* pCookie, XnCallbackHandle& hCallback)
03664 {
03665 XnStatus nRetVal = XN_STATUS_OK;
03666
03667 GestureReadyForNextIntermediateStageCookie* pGestureCookie;
03668 XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie);
03669 pGestureCookie->handler = handler;
03670 pGestureCookie->pUserCookie = pCookie;
03671
03672 nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback);
03673 if (nRetVal != XN_STATUS_OK)
03674 {
03675 xnOSFree(pGestureCookie);
03676 return (nRetVal);
03677 }
03678
03679 hCallback = pGestureCookie;
03680
03681 return (XN_STATUS_OK);
03682 }
03683
03687 inline void UnregisterFromGestureReadyForNextIntermediateStageCallbacks(XnCallbackHandle hCallback)
03688 {
03689 GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback;
03690 xnUnregisterFromGestureReadyForNextIntermediateStage(GetHandle(), pGestureCookie->hCallback);
03691 xnOSFree(pGestureCookie);
03692 }
03693
03694 private:
03695 typedef struct GestureCookie
03696 {
03697 GestureRecognized recognizedHandler;
03698 GestureProgress progressHandler;
03699 void* pUserCookie;
03700 XnCallbackHandle hCallback;
03701 } GestureCookie;
03702
03703 static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie)
03704 {
03705 GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03706 GestureGenerator gen(hNode);
03707 if (pGestureCookie->recognizedHandler != NULL)
03708 {
03709 pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie);
03710 }
03711 }
03712
03713 static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie)
03714 {
03715 GestureCookie* pGestureCookie = (GestureCookie*)pCookie;
03716 GestureGenerator gen(hNode);
03717 if (pGestureCookie->progressHandler != NULL)
03718 {
03719 pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie);
03720 }
03721 }
03722
03723 typedef struct GestureIntermediateStageCompletedCookie
03724 {
03725 GestureIntermediateStageCompleted handler;
03726 void* pUserCookie;
03727 XnCallbackHandle hCallback;
03728 } GestureIntermediateStageCompletedCookie;
03729
03730 static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03731 {
03732 GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie;
03733 GestureGenerator gen(hNode);
03734 if (pGestureCookie->handler != NULL)
03735 {
03736 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03737 }
03738 }
03739
03740 typedef struct GestureReadyForNextIntermediateStageCookie
03741 {
03742 GestureReadyForNextIntermediateStage handler;
03743 void* pUserCookie;
03744 XnCallbackHandle hCallback;
03745 } GestureReadyForNextIntermediateStageCookie;
03746
03747 static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie)
03748 {
03749 GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie;
03750 GestureGenerator gen(hNode);
03751 if (pGestureCookie->handler != NULL)
03752 {
03753 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie);
03754 }
03755 }
03756 };
03757
03762 class SceneAnalyzer : public MapGenerator
03763 {
03764 public:
03770 inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {}
03771 inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {}
03772
03776 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03777
03781 inline void GetMetaData(SceneMetaData& metaData) const
03782 {
03783 xnGetSceneMetaData(GetHandle(), metaData.GetUnderlying());
03784 }
03785
03789 inline const XnLabel* GetLabelMap() const
03790 {
03791 return xnGetLabelMap(GetHandle());
03792 }
03793
03797 inline XnStatus GetFloor(XnPlane3D& Plane) const
03798 {
03799 return xnGetFloor(GetHandle(), &Plane);
03800 }
03801 };
03802
03807 class HandTouchingFOVEdgeCapability : public Capability
03808 {
03809 public:
03815 inline HandTouchingFOVEdgeCapability(XnNodeHandle hNode) : Capability(hNode) {}
03816 HandTouchingFOVEdgeCapability(const NodeWrapper& node) : Capability(node) {}
03817
03828 typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie);
03832 inline XnStatus RegisterToHandTouchingFOVEdge(HandTouchingFOVEdge handler, void* pCookie, XnCallbackHandle& hCallback)
03833 {
03834 XnStatus nRetVal = XN_STATUS_OK;
03835
03836 HandTouchingFOVEdgeCookie* pHandCookie;
03837 XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie);
03838 pHandCookie->handler = handler;
03839 pHandCookie->pUserCookie = pCookie;
03840
03841 nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback);
03842 if (nRetVal != XN_STATUS_OK)
03843 {
03844 xnOSFree(pHandCookie);
03845 return (nRetVal);
03846 }
03847
03848 hCallback = pHandCookie;
03849
03850 return (XN_STATUS_OK);
03851 }
03852
03856 inline void UnregisterFromHandTouchingFOVEdge(XnCallbackHandle hCallback)
03857 {
03858 HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback;
03859 xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback);
03860 xnOSFree(pHandCookie);
03861 }
03862 private:
03863 typedef struct HandTouchingFOVEdgeCookie
03864 {
03865 HandTouchingFOVEdge handler;
03866 void* pUserCookie;
03867 XnCallbackHandle hCallback;
03868 } HandTouchingFOVEdgeCookie;
03869
03870 static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie)
03871 {
03872 HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie;
03873 HandTouchingFOVEdgeCapability cap(hNode);
03874 if (pHandCookie->handler != NULL)
03875 {
03876 pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie);
03877 }
03878 }
03879
03880 };
03885 class HandsGenerator : public Generator
03886 {
03887 public:
03893 inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
03894 inline HandsGenerator(const NodeWrapper& other) : Generator(other) {}
03895
03899 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
03900
03910 typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03920 typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie);
03929 typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie);
03930
03934 inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback)
03935 {
03936 XnStatus nRetVal = XN_STATUS_OK;
03937
03938 HandCookie* pHandCookie;
03939 XN_VALIDATE_ALLOC(pHandCookie, HandCookie);
03940 pHandCookie->createHandler = CreateCB;
03941 pHandCookie->updateHandler = UpdateCB;
03942 pHandCookie->destroyHandler = DestroyCB;
03943 pHandCookie->pUserCookie = pCookie;
03944
03945 nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback);
03946 if (nRetVal != XN_STATUS_OK)
03947 {
03948 xnOSFree(pHandCookie);
03949 return (nRetVal);
03950 }
03951
03952 hCallback = pHandCookie;
03953
03954 return (XN_STATUS_OK);
03955 }
03956
03960 inline void UnregisterHandCallbacks(XnCallbackHandle hCallback)
03961 {
03962 HandCookie* pHandCookie = (HandCookie*)hCallback;
03963 xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback);
03964 xnOSFree(pHandCookie);
03965 }
03966
03970 inline XnStatus StopTracking(XnUserID user)
03971 {
03972 return xnStopTracking(GetHandle(), user);
03973 }
03974
03978 inline XnStatus StopTrackingAll()
03979 {
03980 return xnStopTrackingAll(GetHandle());
03981 }
03982
03986 inline XnStatus StartTracking(const XnPoint3D& ptPosition)
03987 {
03988 return xnStartTracking(GetHandle(), &ptPosition);
03989 }
03990
03994 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
03995 {
03996 return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor);
03997 }
03998
04004 inline const HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() const
04005 {
04006 return HandTouchingFOVEdgeCapability(GetHandle());
04007 }
04008
04014 inline HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap()
04015 {
04016 return HandTouchingFOVEdgeCapability(GetHandle());
04017 }
04018
04019 private:
04020 typedef struct HandCookie
04021 {
04022 HandCreate createHandler;
04023 HandUpdate updateHandler;
04024 HandDestroy destroyHandler;
04025 void* pUserCookie;
04026 XnCallbackHandle hCallback;
04027 } HandCookie;
04028
04029 static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
04030 {
04031 HandCookie* pHandCookie = (HandCookie*)pCookie;
04032 HandsGenerator gen(hNode);
04033 if (pHandCookie->createHandler != NULL)
04034 {
04035 pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
04036 }
04037 }
04038 static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie)
04039 {
04040 HandCookie* pHandCookie = (HandCookie*)pCookie;
04041 HandsGenerator gen(hNode);
04042 if (pHandCookie->updateHandler != NULL)
04043 {
04044 pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie);
04045 }
04046 }
04047 static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie)
04048 {
04049 HandCookie* pHandCookie = (HandCookie*)pCookie;
04050 HandsGenerator gen(hNode);
04051 if (pHandCookie->destroyHandler != NULL)
04052 {
04053 pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie);
04054 }
04055 }
04056 };
04057
04062 class SkeletonCapability : public Capability
04063 {
04064 public:
04070 inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {}
04071 SkeletonCapability(const NodeWrapper& node) : Capability(node) {}
04072
04076 inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const
04077 {
04078 return xnIsJointAvailable(GetHandle(), eJoint);
04079 }
04080
04084 inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const
04085 {
04086 return xnIsProfileAvailable(GetHandle(), eProfile);
04087 }
04088
04092 inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile)
04093 {
04094 return xnSetSkeletonProfile(GetHandle(), eProfile);
04095 }
04096
04100 inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState)
04101 {
04102 return xnSetJointActive(GetHandle(), eJoint, bState);
04103 }
04104
04108 XN_API_DEPRECATED("Use the version with one argument")
04109 inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool ) const
04110 {
04111 return xnIsJointActive(GetHandle(), eJoint);
04112 }
04113
04117 inline XnBool IsJointActive(XnSkeletonJoint eJoint) const
04118 {
04119 return xnIsJointActive(GetHandle(), eJoint);
04120 }
04121
04125 inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04126 {
04127 return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback);
04128 }
04129
04133 inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback)
04134 {
04135 _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback);
04136 }
04137
04141 inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const
04142 {
04143 return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints);
04144 }
04145
04149 inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const
04150 {
04151 return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint);
04152 }
04153
04157 inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const
04158 {
04159 return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint);
04160 }
04161
04165 inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const
04166 {
04167 return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint);
04168 }
04169
04173 inline XnBool IsTracking(XnUserID user) const
04174 {
04175 return xnIsSkeletonTracking(GetHandle(), user);
04176 }
04177
04181 inline XnBool IsCalibrated(XnUserID user) const
04182 {
04183 return xnIsSkeletonCalibrated(GetHandle(), user);
04184 }
04185
04189 inline XnBool IsCalibrating(XnUserID user) const
04190 {
04191 return xnIsSkeletonCalibrating(GetHandle(), user);
04192 }
04193
04197 inline XnStatus RequestCalibration(XnUserID user, XnBool bForce)
04198 {
04199 return xnRequestSkeletonCalibration(GetHandle(), user, bForce);
04200 }
04201
04205 inline XnStatus AbortCalibration(XnUserID user)
04206 {
04207 return xnAbortSkeletonCalibration(GetHandle(), user);
04208 }
04209
04213 inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName)
04214 {
04215 return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName);
04216 }
04217
04221 inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName)
04222 {
04223 return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName);
04224 }
04225
04229 inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot)
04230 {
04231 return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot);
04232 }
04233
04237 inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot)
04238 {
04239 return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot);
04240 }
04241
04245 inline XnStatus ClearCalibrationData(XnUInt32 nSlot)
04246 {
04247 return xnClearSkeletonCalibrationData(GetHandle(), nSlot);
04248 }
04249
04253 inline XnBool IsCalibrationData(XnUInt32 nSlot) const
04254 {
04255 return xnIsSkeletonCalibrationData(GetHandle(), nSlot);
04256 }
04257
04261 inline XnStatus StartTracking(XnUserID user)
04262 {
04263 return xnStartSkeletonTracking(GetHandle(), user);
04264 }
04265
04269 inline XnStatus StopTracking(XnUserID user)
04270 {
04271 return xnStopSkeletonTracking(GetHandle(), user);
04272 }
04273
04277 inline XnStatus Reset(XnUserID user)
04278 {
04279 return xnResetSkeleton(GetHandle(), user);
04280 }
04281
04285 inline XnBool NeedPoseForCalibration() const
04286 {
04287 return xnNeedPoseForSkeletonCalibration(GetHandle());
04288 }
04289
04293 inline XnStatus GetCalibrationPose(XnChar* strPose) const
04294 {
04295 return xnGetSkeletonCalibrationPose(GetHandle(), strPose);
04296 }
04297
04301 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor)
04302 {
04303 return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor);
04304 }
04305
04313 typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie);
04322 typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie);
04323
04327 inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback)
04328 {
04329 XnStatus nRetVal = XN_STATUS_OK;
04330
04331 SkeletonCookie* pSkeletonCookie;
04332 XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie);
04333 pSkeletonCookie->startHandler = CalibrationStartCB;
04334 pSkeletonCookie->endHandler = CalibrationEndCB;
04335 pSkeletonCookie->pUserCookie = pCookie;
04336
04337 #pragma warning (push)
04338 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04339 nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04340 #pragma warning (pop)
04341 if (nRetVal != XN_STATUS_OK)
04342 {
04343 xnOSFree(pSkeletonCookie);
04344 return (nRetVal);
04345 }
04346
04347 hCallback = pSkeletonCookie;
04348
04349 return (XN_STATUS_OK);
04350 }
04351
04355 inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback)
04356 {
04357 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback;
04358 #pragma warning (push)
04359 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04360 xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback);
04361 #pragma warning (pop)
04362 xnOSFree(pSkeletonCookie);
04363 }
04364
04368 inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback)
04369 {
04370 XnStatus nRetVal = XN_STATUS_OK;
04371 CalibrationStartCookie* pCalibrationCookie;
04372 XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie);
04373 pCalibrationCookie->handler = handler;
04374 pCalibrationCookie->pUserCookie = pCookie;
04375 nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback);
04376 if (nRetVal != XN_STATUS_OK)
04377 {
04378 xnOSFree(pCalibrationCookie);
04379 return nRetVal;
04380 }
04381 hCallback = pCalibrationCookie;
04382 return XN_STATUS_OK;
04383 }
04384
04391 inline XnStatus UnregisterFromCalibrationStart(XnCallbackHandle hCallback)
04392 {
04393 CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback;
04394 xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback);
04395 xnOSFree(pCalibrationCookie);
04396 return XN_STATUS_OK;
04397 }
04398
04407 typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04408
04412 inline XnStatus RegisterToCalibrationInProgress(CalibrationInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04413 {
04414 XnStatus nRetVal = XN_STATUS_OK;
04415
04416 CalibrationInProgressCookie* pSkeletonCookie;
04417 XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie);
04418 pSkeletonCookie->handler = handler;
04419 pSkeletonCookie->pUserCookie = pCookie;
04420
04421 nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04422 if (nRetVal != XN_STATUS_OK)
04423 {
04424 xnOSFree(pSkeletonCookie);
04425 return (nRetVal);
04426 }
04427
04428 hCallback = pSkeletonCookie;
04429
04430 return (XN_STATUS_OK);
04431 }
04432
04436 inline void UnregisterFromCalibrationInProgress(XnCallbackHandle hCallback)
04437 {
04438 CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback;
04439 xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback);
04440 xnOSFree(pSkeletonCookie);
04441 }
04442
04451 typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie);
04455 inline XnStatus RegisterToCalibrationComplete(CalibrationComplete handler, void* pCookie, XnCallbackHandle& hCallback)
04456 {
04457 XnStatus nRetVal = XN_STATUS_OK;
04458
04459 CalibrationCompleteCookie* pSkeletonCookie;
04460 XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie);
04461 pSkeletonCookie->handler = handler;
04462 pSkeletonCookie->pUserCookie = pCookie;
04463
04464 nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback);
04465 if (nRetVal != XN_STATUS_OK)
04466 {
04467 xnOSFree(pSkeletonCookie);
04468 return (nRetVal);
04469 }
04470
04471 hCallback = pSkeletonCookie;
04472
04473 return (XN_STATUS_OK);
04474 }
04475
04479 inline void UnregisterFromCalibrationComplete(XnCallbackHandle hCallback)
04480 {
04481 CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback;
04482 xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback);
04483 xnOSFree(pSkeletonCookie);
04484 }
04485 private:
04486 typedef struct SkeletonCookie
04487 {
04488 CalibrationStart startHandler;
04489 CalibrationEnd endHandler;
04490 void* pUserCookie;
04491 XnCallbackHandle hCallback;
04492 } SkeletonCookie;
04493
04494 static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04495 {
04496 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04497 SkeletonCapability cap(hNode);
04498 if (pSkeletonCookie->startHandler != NULL)
04499 {
04500 pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie);
04501 }
04502 }
04503
04504 static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie)
04505 {
04506 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie;
04507 SkeletonCapability cap(hNode);
04508 if (pSkeletonCookie->endHandler != NULL)
04509 {
04510 pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie);
04511 }
04512 }
04513 typedef struct CalibrationStartCookie
04514 {
04515 CalibrationStart handler;
04516 void* pUserCookie;
04517 XnCallbackHandle hCallback;
04518 } CalibrationStartCookie;
04519
04520 static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
04521 {
04522 CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie;
04523 SkeletonCapability cap(hNode);
04524 if (pCalibrationCookie->handler != NULL)
04525 {
04526 pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie);
04527 }
04528 }
04529 typedef struct CalibrationInProgressCookie
04530 {
04531 CalibrationInProgress handler;
04532 void* pUserCookie;
04533 XnCallbackHandle hCallback;
04534 } CalibrationInProgressCookie;
04535
04536 static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04537 {
04538 CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie;
04539 SkeletonCapability cap(hNode);
04540 if (pSkeletonCookie->handler != NULL)
04541 {
04542 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04543 }
04544 }
04545
04546 typedef struct CalibrationCompleteCookie
04547 {
04548 CalibrationComplete handler;
04549 void* pUserCookie;
04550 XnCallbackHandle hCallback;
04551 } CalibrationCompleteCookie;
04552
04553 static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie)
04554 {
04555 CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie;
04556 SkeletonCapability cap(hNode);
04557 if (pSkeletonCookie->handler != NULL)
04558 {
04559 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie);
04560 }
04561 }
04562 };
04563
04568 class PoseDetectionCapability : public Capability
04569 {
04570 public:
04576 inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {}
04577 PoseDetectionCapability(const NodeWrapper& node) : Capability(node) {}
04578
04587 typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie);
04588
04592 inline XnUInt32 GetNumberOfPoses() const
04593 {
04594 return xnGetNumberOfPoses(GetHandle());
04595 }
04596
04600 inline XnStatus GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const
04601 {
04602 return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses);
04603 }
04607 inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const
04608 {
04609 return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses);
04610 }
04611
04612 inline XnBool IsPoseSupported(const XnChar* strPose)
04613 {
04614 return xnIsPoseSupported(GetHandle(), strPose);
04615 }
04616
04617 inline XnStatus GetPoseStatus(XnUserID userID, const XnChar* poseName, XnUInt64& poseTime, XnPoseDetectionStatus& eStatus, XnPoseDetectionState& eState)
04618 {
04619 return xnGetPoseStatus(GetHandle(), userID, poseName, &poseTime, &eStatus, &eState);
04620 }
04621
04625 inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user)
04626 {
04627 return xnStartPoseDetection(GetHandle(), strPose, user);
04628 }
04629
04633 inline XnStatus StopPoseDetection(XnUserID user)
04634 {
04635 return xnStopPoseDetection(GetHandle(), user);
04636 }
04637
04641 inline XnStatus StopSinglePoseDetection(XnUserID user, const XnChar* strPose)
04642 {
04643 return xnStopSinglePoseDetection(GetHandle(), user, strPose);
04644 }
04645
04649 inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback)
04650 {
04651 XnStatus nRetVal = XN_STATUS_OK;
04652
04653 PoseCookie* pPoseCookie;
04654 XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie);
04655 pPoseCookie->startHandler = PoseStartCB;
04656 pPoseCookie->endHandler = PoseEndCB;
04657 pPoseCookie->pPoseCookie = pCookie;
04658
04659 #pragma warning (push)
04660 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04661 nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback);
04662 #pragma warning (pop)
04663 if (nRetVal != XN_STATUS_OK)
04664 {
04665 xnOSFree(pPoseCookie);
04666 return (nRetVal);
04667 }
04668
04669 hCallback = pPoseCookie;
04670
04671 return (XN_STATUS_OK);
04672 }
04673
04677 inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback)
04678 {
04679 PoseCookie* pPoseCookie = (PoseCookie*)hCallback;
04680 #pragma warning (push)
04681 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
04682 xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback);
04683 #pragma warning (pop)
04684 xnOSFree(pPoseCookie);
04685 }
04686
04690 inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04691 {
04692 XnStatus nRetVal = XN_STATUS_OK;
04693 PoseDetectionCookie* pPoseCookie;
04694 XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04695 pPoseCookie->handler = handler;
04696 pPoseCookie->pPoseCookie = pCookie;
04697
04698 nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04699 if (nRetVal != XN_STATUS_OK)
04700 {
04701 xnOSFree(pPoseCookie);
04702 return nRetVal;
04703 }
04704 hCallback = pPoseCookie;
04705 return XN_STATUS_OK;
04706 }
04710 inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback)
04711 {
04712 XnStatus nRetVal = XN_STATUS_OK;
04713 PoseDetectionCookie* pPoseCookie;
04714 XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie);
04715 pPoseCookie->handler = handler;
04716 pPoseCookie->pPoseCookie = pCookie;
04717
04718 nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback);
04719 if (nRetVal != XN_STATUS_OK)
04720 {
04721 xnOSFree(pPoseCookie);
04722 return nRetVal;
04723 }
04724 hCallback = pPoseCookie;
04725 return XN_STATUS_OK;
04726 }
04730 inline void UnregisterFromPoseDetected(XnCallbackHandle hCallback)
04731 {
04732 PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04733 xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback);
04734 xnOSFree(pPoseCookie);
04735 }
04739 inline void UnregisterFromOutOfPose(XnCallbackHandle hCallback)
04740 {
04741 PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback;
04742 xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback);
04743 xnOSFree(pPoseCookie);
04744 }
04745
04755 typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie);
04759 inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback)
04760 {
04761 XnStatus nRetVal = XN_STATUS_OK;
04762
04763 PoseInProgressCookie* pPoseCookie;
04764 XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie);
04765 pPoseCookie->handler = handler;
04766 pPoseCookie->pPoseCookie = pCookie;
04767
04768 nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback);
04769 if (nRetVal != XN_STATUS_OK)
04770 {
04771 xnOSFree(pPoseCookie);
04772 return (nRetVal);
04773 }
04774
04775 hCallback = pPoseCookie;
04776
04777 return (XN_STATUS_OK);
04778 }
04779
04783 inline void UnregisterFromPoseInProgress(XnCallbackHandle hCallback)
04784 {
04785 PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback;
04786 xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback);
04787 xnOSFree(pPoseCookie);
04788 }
04789
04790 private:
04791 typedef struct PoseCookie
04792 {
04793 PoseDetection startHandler;
04794 PoseDetection endHandler;
04795 void* pPoseCookie;
04796 XnCallbackHandle hCallback;
04797 } PoseCookie;
04798
04799 static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04800 {
04801 PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04802 PoseDetectionCapability cap(hNode);
04803 if (pPoseCookie->startHandler != NULL)
04804 {
04805 pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04806 }
04807 }
04808
04809 static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04810 {
04811 PoseCookie* pPoseCookie = (PoseCookie*)pCookie;
04812 PoseDetectionCapability cap(hNode);
04813 if (pPoseCookie->endHandler != NULL)
04814 {
04815 pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie);
04816 }
04817 }
04818 typedef struct PoseDetectionCookie
04819 {
04820 PoseDetection handler;
04821 void* pPoseCookie;
04822 XnCallbackHandle hCallback;
04823 } PoseDetectionCookie;
04824 static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie)
04825 {
04826 PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie;
04827 PoseDetectionCapability cap(hNode);
04828 if (pPoseDetectionCookie->handler != NULL)
04829 {
04830 pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie);
04831 }
04832 }
04833
04834 typedef struct PoseInProgressCookie
04835 {
04836 PoseInProgress handler;
04837 void* pPoseCookie;
04838 XnCallbackHandle hCallback;
04839 } PoseInProgressCookie;
04840
04841 static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie)
04842 {
04843 PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie;
04844 PoseDetectionCapability cap(hNode);
04845 if (pPoseCookie->handler != NULL)
04846 {
04847 pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie);
04848 }
04849 }
04850 };
04851
04856 class UserGenerator : public Generator
04857 {
04858 public:
04864 inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
04865 inline UserGenerator(const NodeWrapper& other) : Generator(other) {}
04866
04870 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
04871
04872 typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie);
04873
04877 inline XnUInt16 GetNumberOfUsers() const
04878 {
04879 return xnGetNumberOfUsers(GetHandle());
04880 }
04881
04885 inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const
04886 {
04887 return xnGetUsers(GetHandle(), aUsers, &nUsers);
04888 }
04889
04893 inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const
04894 {
04895 return xnGetUserCoM(GetHandle(), user, &com);
04896 }
04897
04901 inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd) const
04902 {
04903 return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying());
04904 }
04905
04909 inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback)
04910 {
04911 XnStatus nRetVal = XN_STATUS_OK;
04912
04913 UserCookie* pUserCookie;
04914 XN_VALIDATE_ALLOC(pUserCookie, UserCookie);
04915 pUserCookie->newHandler = NewUserCB;
04916 pUserCookie->lostHandler = LostUserCB;
04917 pUserCookie->pUserCookie = pCookie;
04918
04919 nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback);
04920 if (nRetVal != XN_STATUS_OK)
04921 {
04922 xnOSFree(pUserCookie);
04923 return (nRetVal);
04924 }
04925
04926 hCallback = pUserCookie;
04927
04928 return (XN_STATUS_OK);
04929 }
04930
04934 inline void UnregisterUserCallbacks(XnCallbackHandle hCallback)
04935 {
04936 UserCookie* pUserCookie = (UserCookie*)hCallback;
04937 xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback);
04938 xnOSFree(pUserCookie);
04939 }
04940
04946 inline const SkeletonCapability GetSkeletonCap() const
04947 {
04948 return SkeletonCapability(GetHandle());
04949 }
04950
04956 inline SkeletonCapability GetSkeletonCap()
04957 {
04958 return SkeletonCapability(GetHandle());
04959 }
04960
04966 inline const PoseDetectionCapability GetPoseDetectionCap() const
04967 {
04968 return PoseDetectionCapability(GetHandle());
04969 }
04970
04976 inline PoseDetectionCapability GetPoseDetectionCap()
04977 {
04978 return PoseDetectionCapability(GetHandle());
04979 }
04980
04984 inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
04985 {
04986 XnStatus nRetVal = XN_STATUS_OK;
04987
04988 UserSingleCookie* pUserCookie;
04989 XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
04990 pUserCookie->handler = handler;
04991 pUserCookie->pUserCookie = pCookie;
04992
04993 nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
04994 if (nRetVal != XN_STATUS_OK)
04995 {
04996 xnOSFree(pUserCookie);
04997 return (nRetVal);
04998 }
04999
05000 hCallback = pUserCookie;
05001
05002 return (XN_STATUS_OK);
05003 }
05004
05008 inline void UnregisterFromUserExit(XnCallbackHandle hCallback)
05009 {
05010 UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
05011 xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback);
05012 xnOSFree(pUserCookie);
05013 }
05014
05018 inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05019 {
05020 XnStatus nRetVal = XN_STATUS_OK;
05021
05022 UserSingleCookie* pUserCookie;
05023 XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie);
05024 pUserCookie->handler = handler;
05025 pUserCookie->pUserCookie = pCookie;
05026
05027 nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback);
05028 if (nRetVal != XN_STATUS_OK)
05029 {
05030 xnOSFree(pUserCookie);
05031 return (nRetVal);
05032 }
05033
05034 hCallback = pUserCookie;
05035
05036 return (XN_STATUS_OK);
05037 }
05038
05042 inline void UnregisterFromUserReEnter(XnCallbackHandle hCallback)
05043 {
05044 UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback;
05045 xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback);
05046 xnOSFree(pUserCookie);
05047 }
05048
05049 private:
05050 typedef struct UserCookie
05051 {
05052 UserHandler newHandler;
05053 UserHandler lostHandler;
05054 void* pUserCookie;
05055 XnCallbackHandle hCallback;
05056 } UserCookie;
05057
05058 static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05059 {
05060 UserCookie* pUserCookie = (UserCookie*)pCookie;
05061 UserGenerator gen(hNode);
05062 if (pUserCookie->newHandler != NULL)
05063 {
05064 pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie);
05065 }
05066 }
05067
05068 static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05069 {
05070 UserCookie* pUserCookie = (UserCookie*)pCookie;
05071 UserGenerator gen(hNode);
05072 if (pUserCookie->lostHandler != NULL)
05073 {
05074 pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie);
05075 }
05076 }
05077
05078 typedef struct UserSingleCookie
05079 {
05080 UserHandler handler;
05081 void* pUserCookie;
05082 XnCallbackHandle hCallback;
05083 } UserSingleCookie;
05084
05085 static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie)
05086 {
05087 UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie;
05088 UserGenerator gen(hNode);
05089 if (pUserCookie->handler != NULL)
05090 {
05091 pUserCookie->handler(gen, user, pUserCookie->pUserCookie);
05092 }
05093 }
05094 };
05095
05100 class AudioGenerator : public Generator
05101 {
05102 public:
05108 inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05109 inline AudioGenerator(const NodeWrapper& other) : Generator(other) {}
05110
05114 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL);
05115
05119 inline void GetMetaData(AudioMetaData& metaData) const
05120 {
05121 xnGetAudioMetaData(GetHandle(), metaData.GetUnderlying());
05122 }
05123
05127 inline const XnUChar* GetAudioBuffer() const
05128 {
05129 return xnGetAudioBuffer(GetHandle());
05130 }
05131
05135 inline XnUInt32 GetSupportedWaveOutputModesCount() const
05136 {
05137 return xnGetSupportedWaveOutputModesCount(GetHandle());
05138 }
05139
05143 inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const
05144 {
05145 return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount);
05146 }
05147
05151 inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode)
05152 {
05153 return xnSetWaveOutputMode(GetHandle(), &OutputMode);
05154 }
05155
05159 inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const
05160 {
05161 return xnGetWaveOutputMode(GetHandle(), &OutputMode);
05162 }
05163
05167 inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05168 {
05169 return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback);
05170 }
05171
05175 inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback)
05176 {
05177 _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback);
05178 }
05179 };
05180
05185 class MockAudioGenerator : public AudioGenerator
05186 {
05187 public:
05193 inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {}
05194 inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {}
05195
05202 XnStatus Create(Context& context, const XnChar* strName = NULL);
05203
05210 XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL);
05211
05215 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer)
05216 {
05217 return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer);
05218 }
05219
05227 inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp)
05228 {
05229 return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data());
05230 }
05231
05237 inline XnStatus SetData(const AudioMetaData& audioMD)
05238 {
05239 return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp());
05240 }
05241 };
05242
05243 class MockRawGenerator : public Generator
05244 {
05245 public:
05246 MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {}
05247 MockRawGenerator(const NodeWrapper& other) : Generator(other) {}
05248
05249 inline XnStatus Create(Context& context, const XnChar* strName = NULL);
05250
05251 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData)
05252 {
05253 return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData);
05254 }
05255
05256 };
05257
05262 class Codec : public ProductionNode
05263 {
05264 public:
05270 inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05271 inline Codec(const NodeWrapper& other) : ProductionNode(other) {}
05272
05276 inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode);
05277
05281 inline XnCodecID GetCodecID() const
05282 {
05283 return xnGetCodecID(GetHandle());
05284 }
05285
05289 inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05290 {
05291 return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05292 }
05293
05297 inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const
05298 {
05299 return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten);
05300 }
05301 };
05302
05307 class ScriptNode : public ProductionNode
05308 {
05309 public:
05315 inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {}
05316 inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {}
05317
05318 inline XnStatus Create(Context& context, const XnChar* strFormat);
05319
05320 inline const XnChar* GetSupportedFormat()
05321 {
05322 return xnScriptNodeGetSupportedFormat(GetHandle());
05323 }
05324
05325 inline XnStatus LoadScriptFromFile(const XnChar* strFileName)
05326 {
05327 return xnLoadScriptFromFile(GetHandle(), strFileName);
05328 }
05329
05330 inline XnStatus LoadScriptFromString(const XnChar* strScript)
05331 {
05332 return xnLoadScriptFromString(GetHandle(), strScript);
05333 }
05334
05335 inline XnStatus Run(EnumerationErrors* pErrors);
05336 };
05337
05338
05339
05340
05345 class EnumerationErrors
05346 {
05347 public:
05349 inline EnumerationErrors() : m_bAllocated(TRUE), m_pErrors(NULL) { xnEnumerationErrorsAllocate(&m_pErrors); }
05350
05357 inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_bAllocated(bOwn), m_pErrors(pErrors) {}
05358
05360 ~EnumerationErrors() { Free(); }
05361
05363 class Iterator
05364 {
05365 public:
05366 friend class EnumerationErrors;
05367
05373 XnBool operator==(const Iterator& other) const
05374 {
05375 return m_it == other.m_it;
05376 }
05377
05383 XnBool operator!=(const Iterator& other) const
05384 {
05385 return m_it != other.m_it;
05386 }
05387
05392 inline Iterator& operator++()
05393 {
05394 m_it = xnEnumerationErrorsGetNext(m_it);
05395 return *this;
05396 }
05397
05402 inline Iterator operator++(int)
05403 {
05404 return Iterator(xnEnumerationErrorsGetNext(m_it));
05405 }
05406
05408 inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); }
05410 inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); }
05411
05412 private:
05413 inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {}
05414
05415 XnEnumerationErrorsIterator m_it;
05416 };
05417
05419 inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); }
05421 inline Iterator End() const { return Iterator(NULL); }
05422
05426 inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize)
05427 {
05428 return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize);
05429 }
05430
05434 inline void Free()
05435 {
05436 if (m_bAllocated)
05437 {
05438 xnEnumerationErrorsFree(m_pErrors);
05439 m_pErrors = NULL;
05440 m_bAllocated = FALSE;
05441 }
05442 }
05443
05445 inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; }
05446
05447 private:
05448 XnEnumerationErrors* m_pErrors;
05449 XnBool m_bAllocated;
05450 };
05451
05452
05453
05454
05455
05460 class Context
05461 {
05462 public:
05464 inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {}
05465
05471 inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05472 {
05473 SetHandle(pContext);
05474 }
05475
05482 inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL)
05483 {
05484 SetHandle(other.m_pContext);
05485 }
05486
05488 ~Context()
05489 {
05490 SetHandle(NULL);
05491 }
05492
05493 inline Context& operator=(const Context& other)
05494 {
05495 SetHandle(other.m_pContext);
05496 return *this;
05497 }
05498
05500 inline XnContext* GetUnderlyingObject() const { return m_pContext; }
05501
05505 inline XnStatus Init()
05506 {
05507 XnContext* pContext = NULL;
05508 XnStatus nRetVal = xnInit(&pContext);
05509 XN_IS_STATUS_OK(nRetVal);
05510
05511 TakeOwnership(pContext);
05512 m_bAllocated = TRUE;
05513
05514 return (XN_STATUS_OK);
05515 }
05516
05520 inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL)
05521 {
05522 m_bUsingDeprecatedAPI = TRUE;
05523 #pragma warning (push)
05524 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05525 return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05526 #pragma warning (pop)
05527 }
05528
05532 inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05533 {
05534 XnStatus nRetVal = XN_STATUS_OK;
05535
05536 XnNodeHandle hScriptNode;
05537 nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05538 XN_IS_STATUS_OK(nRetVal);
05539
05540 scriptNode.TakeOwnership(hScriptNode);
05541
05542 return (XN_STATUS_OK);
05543 }
05544
05548 inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05549 {
05550 m_bUsingDeprecatedAPI = TRUE;
05551 #pragma warning (push)
05552 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05553 return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05554 #pragma warning (pop)
05555 }
05556
05560 inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05561 {
05562 XnStatus nRetVal = XN_STATUS_OK;
05563
05564 XnNodeHandle hScriptNode;
05565 nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05566 XN_IS_STATUS_OK(nRetVal);
05567
05568 scriptNode.TakeOwnership(hScriptNode);
05569
05570 return (XN_STATUS_OK);
05571 }
05572
05576 inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL)
05577 {
05578 XnContext* pContext = NULL;
05579 m_bUsingDeprecatedAPI = TRUE;
05580
05581 #pragma warning (push)
05582 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05583 XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05584 #pragma warning (pop)
05585 XN_IS_STATUS_OK(nRetVal);
05586
05587 TakeOwnership(pContext);
05588 m_bAllocated = TRUE;
05589
05590 return (XN_STATUS_OK);
05591 }
05592
05596 inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL)
05597 {
05598 XnContext* pContext = NULL;
05599
05600 XnNodeHandle hScriptNode;
05601 XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode);
05602 XN_IS_STATUS_OK(nRetVal);
05603
05604 scriptNode.TakeOwnership(hScriptNode);
05605 TakeOwnership(pContext);
05606 m_bAllocated = TRUE;
05607
05608 return (XN_STATUS_OK);
05609 }
05610
05614 inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName)
05615 {
05616 m_bUsingDeprecatedAPI = TRUE;
05617 #pragma warning (push)
05618 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05619 return xnContextOpenFileRecording(m_pContext, strFileName);
05620 #pragma warning (pop)
05621 }
05622
05626 inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode)
05627 {
05628 XnStatus nRetVal = XN_STATUS_OK;
05629
05630 XnNodeHandle hPlayer;
05631 nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer);
05632 XN_IS_STATUS_OK(nRetVal);
05633
05634 playerNode.TakeOwnership(hPlayer);
05635
05636 return (XN_STATUS_OK);
05637 }
05638
05642 inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode)
05643 {
05644 XnStatus nRetVal = XN_STATUS_OK;
05645
05646 XnNodeHandle hMockNode;
05647 nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode);
05648 XN_IS_STATUS_OK(nRetVal);
05649
05650 mockNode.TakeOwnership(hMockNode);
05651
05652 return (XN_STATUS_OK);
05653 }
05654
05658 inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode)
05659 {
05660 XnStatus nRetVal = XN_STATUS_OK;
05661
05662 XnNodeHandle hMockNode;
05663 nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode);
05664 XN_IS_STATUS_OK(nRetVal);
05665
05666 mockNode.TakeOwnership(hMockNode);
05667
05668 return (XN_STATUS_OK);
05669 }
05670
05674 inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec)
05675 {
05676 XnStatus nRetVal = XN_STATUS_OK;
05677
05678 XnNodeHandle hCodec;
05679 nRetVal = xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec);
05680 XN_IS_STATUS_OK(nRetVal);
05681
05682 codec.TakeOwnership(hCodec);
05683
05684 return (XN_STATUS_OK);
05685 }
05686
05690 inline XnStatus AddRef()
05691 {
05692 return xnContextAddRef(m_pContext);
05693 }
05694
05698 inline void Release()
05699 {
05700 SetHandle(NULL);
05701 }
05702
05706 inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown()
05707 {
05708 if (m_pContext != NULL)
05709 {
05710 #pragma warning (push)
05711 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS)
05712 xnShutdown(m_pContext);
05713 #pragma warning (pop)
05714 m_pContext = NULL;
05715 }
05716 }
05717
05721 inline XnStatus AddLicense(const XnLicense& License)
05722 {
05723 return xnAddLicense(m_pContext, &License);
05724 }
05725
05729 inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const
05730 {
05731 return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount);
05732 }
05733
05737 inline static void FreeLicensesList(XnLicense aLicenses[])
05738 {
05739 xnFreeLicensesList(aLicenses);
05740 }
05741
05745 XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const
05746 {
05747 XnStatus nRetVal = XN_STATUS_OK;
05748
05749 const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05750
05751 XnNodeInfoList* pList = NULL;
05752 nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05753 XN_IS_STATUS_OK(nRetVal);
05754
05755 TreesList.ReplaceUnderlyingObject(pList);
05756
05757 return (XN_STATUS_OK);
05758 }
05759
05763 XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL)
05764 {
05765 XnStatus nRetVal = XN_STATUS_OK;
05766
05767 XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL;
05768
05769 XnNodeHandle hNode;
05770 nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying());
05771 XN_IS_STATUS_OK(nRetVal);
05772
05773 node.TakeOwnership(hNode);
05774
05775 return (XN_STATUS_OK);
05776 }
05777
05781 XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree)
05782 {
05783 XnStatus nRetVal = XN_STATUS_OK;
05784
05785 XnNodeHandle hNode;
05786 nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05787 XN_IS_STATUS_OK(nRetVal);
05788
05789 Tree.m_bOwnerOfNode = TRUE;
05790
05791 return (XN_STATUS_OK);
05792 }
05793
05797 XnStatus CreateProductionTree(NodeInfo& Tree, ProductionNode& node)
05798 {
05799 XnStatus nRetVal = XN_STATUS_OK;
05800
05801 XnNodeHandle hNode;
05802 nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode);
05803 XN_IS_STATUS_OK(nRetVal);
05804
05805 node.TakeOwnership(hNode);
05806
05807 return (XN_STATUS_OK);
05808 }
05809
05813 XnStatus EnumerateExistingNodes(NodeInfoList& list) const
05814 {
05815 XnNodeInfoList* pList;
05816 XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList);
05817 XN_IS_STATUS_OK(nRetVal);
05818
05819 list.ReplaceUnderlyingObject(pList);
05820
05821 return (XN_STATUS_OK);
05822 }
05823
05827 XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const
05828 {
05829 XnNodeInfoList* pList;
05830 XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList);
05831 XN_IS_STATUS_OK(nRetVal);
05832
05833 list.ReplaceUnderlyingObject(pList);
05834
05835 return (XN_STATUS_OK);
05836 }
05837
05841 XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const
05842 {
05843 XnStatus nRetVal = XN_STATUS_OK;
05844
05845 XnNodeHandle hNode;
05846 nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode);
05847 XN_IS_STATUS_OK(nRetVal);
05848
05849 node.TakeOwnership(hNode);
05850
05851 return (XN_STATUS_OK);
05852 }
05853
05857 XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const
05858 {
05859 XnStatus nRetVal = XN_STATUS_OK;
05860
05861 XnNodeHandle hNode;
05862 nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05863 XN_IS_STATUS_OK(nRetVal);
05864
05865 node.TakeOwnership(hNode);
05866
05867 return (XN_STATUS_OK);
05868 }
05869
05873 XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const
05874 {
05875 XnStatus nRetVal = XN_STATUS_OK;
05876
05877 XnNodeHandle hNode;
05878 nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode);
05879 XN_IS_STATUS_OK(nRetVal);
05880
05881 xnProductionNodeRelease(hNode);
05882
05883 nodeInfo = NodeInfo(xnGetNodeInfo(hNode));
05884
05885 return (XN_STATUS_OK);
05886 }
05887
05891 inline XnStatus StartGeneratingAll()
05892 {
05893 return xnStartGeneratingAll(m_pContext);
05894 }
05895
05899 inline XnStatus StopGeneratingAll()
05900 {
05901 return xnStopGeneratingAll(m_pContext);
05902 }
05903
05907 inline XnStatus SetGlobalMirror(XnBool bMirror)
05908 {
05909 return xnSetGlobalMirror(m_pContext, bMirror);
05910 }
05911
05915 inline XnBool GetGlobalMirror()
05916 {
05917 return xnGetGlobalMirror(m_pContext);
05918 }
05919
05923 inline XnStatus GetGlobalErrorState()
05924 {
05925 return xnGetGlobalErrorState(m_pContext);
05926 }
05927
05931 inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
05932 {
05933 return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback);
05934 }
05935
05939 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback)
05940 {
05941 xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback);
05942 }
05943
05947 inline XnStatus WaitAndUpdateAll()
05948 {
05949 return xnWaitAndUpdateAll(m_pContext);
05950 }
05951
05955 inline XnStatus WaitAnyUpdateAll()
05956 {
05957 return xnWaitAnyUpdateAll(m_pContext);
05958 }
05959
05963 inline XnStatus WaitOneUpdateAll(ProductionNode& node)
05964 {
05965 return xnWaitOneUpdateAll(m_pContext, node.GetHandle());
05966 }
05967
05971 inline XnStatus WaitNoneUpdateAll()
05972 {
05973 return xnWaitNoneUpdateAll(m_pContext);
05974 }
05975
05979 inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const
05980 {
05981 return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject());
05982 }
05983
05985 inline void SetHandle(XnContext* pContext)
05986 {
05987 if (m_pContext == pContext)
05988 {
05989 return;
05990 }
05991
05992 if (m_pContext != NULL)
05993 {
05994 if (m_bUsingDeprecatedAPI && m_bAllocated)
05995 {
05996
05997
05998 xnForceShutdown(m_pContext);
05999 }
06000 else
06001 {
06002 xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback);
06003 xnContextRelease(m_pContext);
06004 }
06005 }
06006
06007 if (pContext != NULL)
06008 {
06009 XnStatus nRetVal = xnContextAddRef(pContext);
06010 XN_ASSERT(nRetVal == XN_STATUS_OK);
06011
06012 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback);
06013 XN_ASSERT(nRetVal == XN_STATUS_OK);
06014 }
06015
06016 m_pContext = pContext;
06017 }
06018
06019 inline void TakeOwnership(XnContext* pContext)
06020 {
06021 SetHandle(pContext);
06022
06023 if (pContext != NULL)
06024 {
06025 xnContextRelease(pContext);
06026 }
06027 }
06028
06029 private:
06030 static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* , void* pCookie)
06031 {
06032 Context* pThis = (Context*)pCookie;
06033 pThis->m_pContext = NULL;
06034 }
06035
06036 XnContext* m_pContext;
06037 XnBool m_bUsingDeprecatedAPI;
06038 XnBool m_bAllocated;
06039 XnCallbackHandle m_hShuttingDownCallback;
06040 };
06041
06046 class Resolution
06047 {
06048 public:
06054 inline Resolution(XnResolution res) : m_Res(res)
06055 {
06056 m_nXRes = xnResolutionGetXRes(res);
06057 m_nYRes = xnResolutionGetYRes(res);
06058 m_strName = xnResolutionGetName(res);
06059 }
06060
06067 inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes)
06068 {
06069 m_Res = xnResolutionGetFromXYRes(xRes, yRes);
06070 m_strName = xnResolutionGetName(m_Res);
06071 }
06072
06078 inline Resolution(const XnChar* strName)
06079 {
06080 m_Res = xnResolutionGetFromName(strName);
06081 m_nXRes = xnResolutionGetXRes(m_Res);
06082 m_nYRes = xnResolutionGetYRes(m_Res);
06083 m_strName = xnResolutionGetName(m_Res);
06084 }
06085
06087 inline XnResolution GetResolution() const { return m_Res; }
06089 inline XnUInt32 GetXResolution() const { return m_nXRes; }
06091 inline XnUInt32 GetYResolution() const { return m_nYRes; }
06093 inline const XnChar* GetName() const { return m_strName; }
06094
06095 private:
06096 XnResolution m_Res;
06097 XnUInt32 m_nXRes;
06098 XnUInt32 m_nYRes;
06099 const XnChar* m_strName;
06100 };
06101
06102
06103
06104
06105 inline XnStatus NodeInfoList::FilterList(Context& context, Query& query)
06106 {
06107 return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList);
06108 }
06109
06110 inline void ProductionNode::GetContext(Context& context) const
06111 {
06112 context.TakeOwnership(xnGetRefContextFromNodeHandle(GetHandle()));
06113 }
06114
06115 inline NodeInfoList& NodeInfo::GetNeededNodes() const
06116 {
06117 if (m_pNeededNodes == NULL)
06118 {
06119 XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo);
06120 m_pNeededNodes = XN_NEW(NodeInfoList, pList);
06121 }
06122
06123 return *m_pNeededNodes;
06124 }
06125
06126 inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo)
06127 {
06128 if (m_pNeededNodes != NULL)
06129 {
06130 XN_DELETE(m_pNeededNodes);
06131 }
06132
06133 m_bOwnerOfNode = FALSE;
06134 m_pInfo = pInfo;
06135 m_pNeededNodes = NULL;
06136 }
06137
06138 inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other) const
06139 {
06140 return xnCanFrameSyncWith(GetHandle(), other.GetHandle());
06141 }
06142
06143 inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other)
06144 {
06145 return xnFrameSyncWith(GetHandle(), other.GetHandle());
06146 }
06147
06148 inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other)
06149 {
06150 return xnStopFrameSyncWith(GetHandle(), other.GetHandle());
06151 }
06152
06153 inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other) const
06154 {
06155 return xnIsFrameSyncedWith(GetHandle(), other.GetHandle());
06156 }
06157
06158 inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const
06159 {
06160 if (m_pInfo == NULL)
06161 {
06162 return XN_STATUS_INVALID_OPERATION;
06163 }
06164
06165 XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo);
06166 node.TakeOwnership(hNode);
06167
06168 if (m_bOwnerOfNode)
06169 {
06170 xnProductionNodeRelease(hNode);
06171 }
06172
06173 return (XN_STATUS_OK);
06174 }
06175
06176
06177
06178
06179
06180 inline XnStatus Device::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06181 {
06182 XnNodeHandle hNode;
06183 XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06184 XN_IS_STATUS_OK(nRetVal);
06185 TakeOwnership(hNode);
06186 return (XN_STATUS_OK);
06187 }
06188
06189 inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName )
06190 {
06191 XnNodeHandle hNode;
06192 XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode);
06193 XN_IS_STATUS_OK(nRetVal);
06194 TakeOwnership(hNode);
06195 return (XN_STATUS_OK);
06196 }
06197
06198 inline XnStatus Player::Create(Context& context, const XnChar* strFormatName)
06199 {
06200 XnNodeHandle hNode;
06201 XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode);
06202 XN_IS_STATUS_OK(nRetVal);
06203 TakeOwnership(hNode);
06204 return (XN_STATUS_OK);
06205 }
06206
06207 inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06208 {
06209 XnNodeHandle hNode;
06210 XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06211 XN_IS_STATUS_OK(nRetVal);
06212 TakeOwnership(hNode);
06213 return (XN_STATUS_OK);
06214 }
06215
06216 inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName )
06217 {
06218 XnNodeHandle hNode;
06219 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode);
06220 XN_IS_STATUS_OK(nRetVal);
06221 TakeOwnership(hNode);
06222 return (XN_STATUS_OK);
06223 }
06224
06225 inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName )
06226 {
06227 Context context;
06228 other.GetContext(context);
06229 XnNodeHandle hNode;
06230 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06231 XN_IS_STATUS_OK(nRetVal);
06232 TakeOwnership(hNode);
06233 return (XN_STATUS_OK);
06234 }
06235
06236 inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06237 {
06238 XnNodeHandle hNode;
06239 XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06240 XN_IS_STATUS_OK(nRetVal);
06241 TakeOwnership(hNode);
06242 return (XN_STATUS_OK);
06243 }
06244
06245 inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName )
06246 {
06247 XnNodeHandle hNode;
06248 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode);
06249 XN_IS_STATUS_OK(nRetVal);
06250 TakeOwnership(hNode);
06251 return (XN_STATUS_OK);
06252 }
06253
06254 inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName )
06255 {
06256 Context context;
06257 other.GetContext(context);
06258 XnNodeHandle hNode;
06259 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06260 XN_IS_STATUS_OK(nRetVal);
06261 TakeOwnership(hNode);
06262 return (XN_STATUS_OK);
06263 }
06264
06265 inline XnStatus IRGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06266 {
06267 XnNodeHandle hNode;
06268 XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06269 XN_IS_STATUS_OK(nRetVal);
06270 TakeOwnership(hNode);
06271 return (XN_STATUS_OK);
06272 }
06273
06274 inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName )
06275 {
06276 XnNodeHandle hNode;
06277 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode);
06278 XN_IS_STATUS_OK(nRetVal);
06279 TakeOwnership(hNode);
06280 return (XN_STATUS_OK);
06281 }
06282
06283 inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName )
06284 {
06285 Context context;
06286 other.GetContext(context);
06287 XnNodeHandle hNode;
06288 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06289 XN_IS_STATUS_OK(nRetVal);
06290 TakeOwnership(hNode);
06291 return (XN_STATUS_OK);
06292 }
06293
06294 inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06295 {
06296 XnNodeHandle hNode;
06297 XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06298 XN_IS_STATUS_OK(nRetVal);
06299 TakeOwnership(hNode);
06300 return (XN_STATUS_OK);
06301 }
06302
06303 inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06304 {
06305
06306 XnNodeHandle hNode;
06307 XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06308 XN_IS_STATUS_OK(nRetVal);
06309 TakeOwnership(hNode);
06310 return (XN_STATUS_OK);
06311 }
06312
06313 inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06314 {
06315 XnNodeHandle hNode;
06316 XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06317 XN_IS_STATUS_OK(nRetVal);
06318 TakeOwnership(hNode);
06319 return (XN_STATUS_OK);
06320 }
06321
06322 inline XnStatus UserGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06323 {
06324 XnNodeHandle hNode;
06325 XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06326 XN_IS_STATUS_OK(nRetVal);
06327 TakeOwnership(hNode);
06328 return (XN_STATUS_OK);
06329 }
06330
06331 inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery, EnumerationErrors* pErrors)
06332 {
06333 XnNodeHandle hNode;
06334 XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06335 XN_IS_STATUS_OK(nRetVal);
06336 TakeOwnership(hNode);
06337 return (XN_STATUS_OK);
06338 }
06339
06340 inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName )
06341 {
06342 XnNodeHandle hNode;
06343 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode);
06344 XN_IS_STATUS_OK(nRetVal);
06345 TakeOwnership(hNode);
06346 return (XN_STATUS_OK);
06347 }
06348
06349 inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName )
06350 {
06351 Context context;
06352 other.GetContext(context);
06353 XnNodeHandle hNode;
06354 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode);
06355 XN_IS_STATUS_OK(nRetVal);
06356 TakeOwnership(hNode);
06357 return (XN_STATUS_OK);
06358 }
06359
06360 inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName )
06361 {
06362 XnNodeHandle hNode;
06363 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode);
06364 XN_IS_STATUS_OK(nRetVal);
06365 TakeOwnership(hNode);
06366 return (XN_STATUS_OK);
06367 }
06368
06369 inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode)
06370 {
06371 XnNodeHandle hNode;
06372 XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode);
06373 XN_IS_STATUS_OK(nRetVal);
06374 TakeOwnership(hNode);
06375 return (XN_STATUS_OK);
06376 }
06377
06378 inline XnStatus ScriptNode::Run(EnumerationErrors* pErrors)
06379 {
06380 return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying());
06381 }
06382
06383 inline XnStatus ScriptNode::Create(Context& context, const XnChar* strFormat)
06384 {
06385 XnNodeHandle hNode;
06386 XnStatus nRetVal = xnCreateScriptNode(context.GetUnderlyingObject(), strFormat, &hNode);
06387 XN_IS_STATUS_OK(nRetVal);
06388 TakeOwnership(hNode);
06389 return (XN_STATUS_OK);
06390 }
06391
06392
06393
06394
06395
06399 inline void GetVersion(XnVersion& Version)
06400 {
06401 xnGetVersion(&Version);
06402 }
06403
06404
06405
06406
06407
06408 class StateChangedCallbackTranslator
06409 {
06410 public:
06411 StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {}
06412
06413 XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06414 {
06415 return xnFunc(hNode, StateChangedCallback, this, &m_hCallback);
06416 }
06417
06418 void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode)
06419 {
06420 xnFunc(hNode, m_hCallback);
06421 }
06422
06423 static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06424 {
06425 XnStatus nRetVal = XN_STATUS_OK;
06426
06427 StateChangedCallbackTranslator* pTrans;
06428 XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06429
06430 nRetVal = pTrans->Register(xnFunc, hNode);
06431 if (nRetVal != XN_STATUS_OK)
06432 {
06433 XN_DELETE(pTrans);
06434 return (nRetVal);
06435 }
06436
06437 hCallback = pTrans;
06438
06439 return (XN_STATUS_OK);
06440 }
06441
06442 static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06443 {
06444 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06445 pTrans->Unregister(xnFunc, hNode);
06446 XN_DELETE(pTrans);
06447 return XN_STATUS_OK;
06448 }
06449
06450 private:
06451 friend class GeneralIntCapability;
06452
06453 typedef struct StateChangeCookie
06454 {
06455 StateChangedHandler userHandler;
06456 void* pUserCookie;
06457 XnCallbackHandle hCallback;
06458 } StateChangeCookie;
06459
06460 static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie)
06461 {
06462 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie;
06463 ProductionNode node(hNode);
06464 pTrans->m_UserHandler(node, pTrans->m_pUserCookie);
06465 }
06466
06467 StateChangedHandler m_UserHandler;
06468 void* m_pUserCookie;
06469 XnCallbackHandle m_hCallback;
06470 };
06471
06472 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06473 {
06474 return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback);
06475 }
06476
06477 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback)
06478 {
06479 StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback);
06480 }
06481
06482 inline XnStatus GeneralIntCapability::RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback)
06483 {
06484 XnStatus nRetVal = XN_STATUS_OK;
06485
06486 StateChangedCallbackTranslator* pTrans;
06487 XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie);
06488
06489 nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback);
06490 if (nRetVal != XN_STATUS_OK)
06491 {
06492 XN_DELETE(pTrans);
06493 return (nRetVal);
06494 }
06495
06496 hCallback = pTrans;
06497
06498 return (XN_STATUS_OK);
06499 }
06500
06501 inline void GeneralIntCapability::UnregisterFromValueChange(XnCallbackHandle hCallback)
06502 {
06503 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback;
06504 xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback);
06505 XN_DELETE(pTrans);
06506 }
06507
06509 };
06510
06511 #endif // __XN_CPP_WRAPPER_H__