![]() |
OpenNI 1.5.7
|
00001 /***************************************************************************** 00002 * * 00003 * OpenNI 1.x Alpha * 00004 * Copyright (C) 2012 PrimeSense Ltd. * 00005 * * 00006 * This file is part of OpenNI. * 00007 * * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); * 00009 * you may not use this file except in compliance with the License. * 00010 * You may obtain a copy of the License at * 00011 * * 00012 * http://www.apache.org/licenses/LICENSE-2.0 * 00013 * * 00014 * Unless required by applicable law or agreed to in writing, software * 00015 * distributed under the License is distributed on an "AS IS" BASIS, * 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00017 * See the License for the specific language governing permissions and * 00018 * limitations under the License. * 00019 * * 00020 *****************************************************************************/ 00021 #ifndef __XN_CPP_WRAPPER_H__ 00022 #define __XN_CPP_WRAPPER_H__ 00023 00024 //--------------------------------------------------------------------------- 00025 // Includes 00026 //--------------------------------------------------------------------------- 00027 #include <XnOpenNI.h> 00028 #include <XnCodecIDs.h> 00029 00030 //--------------------------------------------------------------------------- 00031 // Types 00032 //--------------------------------------------------------------------------- 00033 namespace xn 00034 { 00035 //--------------------------------------------------------------------------- 00036 // Forward Declarations 00037 //--------------------------------------------------------------------------- 00038 class ProductionNode; 00039 class EnumerationErrors; 00040 class NodeInfo; 00041 class NodeInfoList; 00042 class Context; 00043 class Query; 00044 class Generator; 00045 00071 //--------------------------------------------------------------------------- 00072 // Types 00073 //--------------------------------------------------------------------------- 00074 00100 typedef void (XN_CALLBACK_TYPE* StateChangedHandler)(ProductionNode& node, void* pCookie); 00101 00102 //--------------------------------------------------------------------------- 00103 // Internal stuff 00104 //--------------------------------------------------------------------------- 00105 typedef XnStatus (*_XnRegisterStateChangeFuncPtr)(XnNodeHandle hNode, XnStateChangedHandler handler, void* pCookie, XnCallbackHandle* phCallback); 00106 typedef void (*_XnUnregisterStateChangeFuncPtr)(XnNodeHandle hNode, XnCallbackHandle hCallback); 00107 00108 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback); 00109 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback); 00110 00111 //--------------------------------------------------------------------------- 00112 // Some Utilities 00113 //--------------------------------------------------------------------------- 00118 class Version 00119 { 00120 public: 00121 Version(const XnVersion& version) : m_version(version) {} 00122 Version(XnUInt8 nMajor, XnUInt8 nMinor, XnUInt16 nMaintenance, XnUInt32 nBuild) 00123 { 00124 m_version.nMajor = nMajor; 00125 m_version.nMinor = nMinor; 00126 m_version.nMaintenance = nMaintenance; 00127 m_version.nBuild = nBuild; 00128 } 00129 00130 bool operator==(const Version& other) const 00131 { 00132 return (xnVersionCompare(&m_version, &other.m_version) == 0); 00133 } 00134 bool operator!=(const Version& other) const 00135 { 00136 return (xnVersionCompare(&m_version, &other.m_version) != 0); 00137 } 00138 bool operator<(const Version& other) const 00139 { 00140 return (xnVersionCompare(&m_version, &other.m_version) < 0); 00141 } 00142 bool operator<=(const Version& other) const 00143 { 00144 return (xnVersionCompare(&m_version, &other.m_version) <= 0); 00145 } 00146 bool operator>(const Version& other) const 00147 { 00148 return (xnVersionCompare(&m_version, &other.m_version) > 0); 00149 } 00150 bool operator>=(const Version& other) const 00151 { 00152 return (xnVersionCompare(&m_version, &other.m_version) >= 0); 00153 } 00154 00155 static Version Current() 00156 { 00157 XnVersion version; 00158 xnGetVersion(&version); 00159 return Version(version); 00160 } 00161 00162 XnUInt8 Major() const { return m_version.nMajor; } 00163 XnUInt8 Minor() const { return m_version.nMinor; } 00164 XnUInt16 Maintenance() const { return m_version.nMaintenance; } 00165 XnUInt32 Build() const { return m_version.nBuild; } 00166 00167 XnUInt8& Major() { return m_version.nMajor; } 00168 XnUInt8& Minor() { return m_version.nMinor; } 00169 XnUInt16& Maintenance() { return m_version.nMaintenance; } 00170 XnUInt32& Build() { return m_version.nBuild; } 00171 00172 const XnVersion* GetUnderlying() const { return &m_version; } 00173 XnVersion* GetUnderlying() { return &m_version; } 00174 00175 private: 00176 XnVersion m_version; 00177 }; 00178 00179 //--------------------------------------------------------------------------- 00180 // Meta Data 00181 //--------------------------------------------------------------------------- 00182 00197 class OutputMetaData 00198 { 00199 public: 00205 inline OutputMetaData(const XnUInt8** ppData) : m_pAllocatedData(NULL), m_ppData(ppData), m_nAllocatedSize(0) 00206 { 00207 xnOSMemSet(&m_output, 0, sizeof(XnOutputMetaData)); 00208 } 00209 00213 virtual ~OutputMetaData() { Free(); } 00214 00218 inline XnUInt64 Timestamp() const { return m_output.nTimestamp; } 00219 00223 inline XnUInt64& Timestamp() { return m_output.nTimestamp; } 00224 00229 inline XnUInt32 FrameID() const { return m_output.nFrameID; } 00230 00235 inline XnUInt32& FrameID() { return m_output.nFrameID; } 00236 00245 inline XnUInt32 DataSize() const { return m_output.nDataSize; } 00246 00255 inline XnUInt32& DataSize() { return m_output.nDataSize; } 00256 00261 inline XnBool IsDataNew() const { return m_output.bIsNew; } 00262 00267 inline XnBool& IsDataNew() { return m_output.bIsNew; } 00268 00272 inline const XnOutputMetaData* GetUnderlying() const { return &m_output; } 00276 inline XnOutputMetaData* GetUnderlying() { return &m_output; } 00277 00282 inline const XnUInt8* Data() const { return *m_ppData; } 00287 inline const XnUInt8*& Data() { return *m_ppData; } 00288 00292 inline XnUInt8* WritableData() 00293 { 00294 MakeDataWritable(); 00295 return m_pAllocatedData; 00296 } 00297 00306 XnStatus AllocateData(XnUInt32 nBytes) 00307 { 00308 if (nBytes > m_nAllocatedSize) 00309 { 00310 // reallocate 00311 XnUInt8* pData = (XnUInt8*)xnOSMallocAligned(nBytes, XN_DEFAULT_MEM_ALIGN); 00312 XN_VALIDATE_ALLOC_PTR(pData); 00313 00314 // allocation succeeded, replace 00315 Free(); 00316 m_pAllocatedData = pData; 00317 m_nAllocatedSize = nBytes; 00318 } 00319 00320 DataSize() = nBytes; 00321 *m_ppData = m_pAllocatedData; 00322 00323 return XN_STATUS_OK; 00324 } 00325 00329 void Free() 00330 { 00331 if (m_nAllocatedSize != 0) 00332 { 00333 xnOSFreeAligned(m_pAllocatedData); 00334 m_pAllocatedData = NULL; 00335 m_nAllocatedSize = 0; 00336 } 00337 } 00338 00343 XnStatus MakeDataWritable() 00344 { 00345 XnStatus nRetVal = XN_STATUS_OK; 00346 00347 // check data isn't already writable 00348 if (Data() != m_pAllocatedData || DataSize() > m_nAllocatedSize) 00349 { 00350 const XnUInt8* pOrigData = *m_ppData; 00351 00352 nRetVal = AllocateData(DataSize()); 00353 XN_IS_STATUS_OK(nRetVal); 00354 00355 if (pOrigData != NULL) 00356 { 00357 xnOSMemCopy(m_pAllocatedData, pOrigData, DataSize()); 00358 } 00359 else 00360 { 00361 xnOSMemSet(m_pAllocatedData, 0, DataSize()); 00362 } 00363 } 00364 00365 return (XN_STATUS_OK); 00366 } 00367 00368 protected: 00369 XnUInt8* m_pAllocatedData; 00370 00371 private: 00372 XnOutputMetaData m_output; 00373 00374 const XnUInt8** m_ppData; 00375 XnUInt32 m_nAllocatedSize; 00376 }; 00377 00390 class MapMetaData : public OutputMetaData 00391 { 00392 public: 00399 inline MapMetaData(XnPixelFormat format, const XnUInt8** ppData) : OutputMetaData(ppData) 00400 { 00401 xnOSMemSet(&m_map, 0, sizeof(XnMapMetaData)); 00402 m_map.pOutput = OutputMetaData::GetUnderlying(); 00403 m_map.PixelFormat = format; 00404 } 00405 00411 inline XnUInt32 XRes() const { return m_map.Res.X; } 00417 inline XnUInt32& XRes() { return m_map.Res.X; } 00418 00424 inline XnUInt32 YRes() const { return m_map.Res.Y; } 00430 inline XnUInt32& YRes() { return m_map.Res.Y; } 00431 00440 inline XnUInt32 XOffset() const { return m_map.Offset.X; } 00449 inline XnUInt32& XOffset() { return m_map.Offset.X; } 00450 00459 inline XnUInt32 YOffset() const { return m_map.Offset.Y; } 00468 inline XnUInt32& YOffset() { return m_map.Offset.Y; } 00469 00474 inline XnUInt32 FullXRes() const { return m_map.FullRes.X; } 00475 00476 00481 inline XnUInt32& FullXRes() { return m_map.FullRes.X; } 00482 00486 inline XnUInt32 FullYRes() const { return m_map.FullRes.Y; } 00490 inline XnUInt32& FullYRes() { return m_map.FullRes.Y; } 00491 00495 inline XnUInt32 FPS() const { return m_map.nFPS; } 00499 inline XnUInt32& FPS() { return m_map.nFPS; } 00500 00504 inline XnPixelFormat PixelFormat() const { return m_map.PixelFormat; } 00505 00509 inline const XnMapMetaData* GetUnderlying() const { return &m_map; } 00513 inline XnMapMetaData* GetUnderlying() { return &m_map; } 00514 00518 inline XnUInt32 BytesPerPixel() const 00519 { 00520 switch (PixelFormat()) 00521 { 00522 case XN_PIXEL_FORMAT_RGB24: 00523 return sizeof(XnRGB24Pixel); 00524 case XN_PIXEL_FORMAT_YUV422: 00525 return sizeof(XnYUV422DoublePixel)/2; 00526 case XN_PIXEL_FORMAT_GRAYSCALE_8_BIT: 00527 return sizeof(XnGrayscale8Pixel); 00528 case XN_PIXEL_FORMAT_GRAYSCALE_16_BIT: 00529 return sizeof(XnGrayscale16Pixel); 00530 case XN_PIXEL_FORMAT_MJPEG: 00531 return 2; 00532 default: 00533 XN_ASSERT(FALSE); 00534 return 0; 00535 } 00536 } 00537 00544 XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes) 00545 { 00546 XnStatus nRetVal = XN_STATUS_OK; 00547 00548 XnUInt32 nSize = nXRes * nYRes * BytesPerPixel(); 00549 nRetVal = OutputMetaData::AllocateData(nSize); 00550 XN_IS_STATUS_OK(nRetVal); 00551 00552 FullXRes() = XRes() = nXRes; 00553 FullYRes() = YRes() = nYRes; 00554 XOffset() = YOffset() = 0; 00555 00556 return (XN_STATUS_OK); 00557 } 00558 00567 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnUInt8* pExternalBuffer) 00568 { 00569 XnStatus nRetVal = XN_STATUS_OK; 00570 00571 if (pExternalBuffer == NULL) 00572 { 00573 nRetVal = AllocateData(nXRes, nYRes); 00574 XN_IS_STATUS_OK(nRetVal); 00575 } 00576 else 00577 { 00578 FullXRes() = XRes() = nXRes; 00579 FullYRes() = YRes() = nYRes; 00580 XOffset() = YOffset() = 0; 00581 Data() = pExternalBuffer; 00582 DataSize() = nXRes * nYRes * BytesPerPixel(); 00583 } 00584 00585 return (XN_STATUS_OK); 00586 } 00587 00588 protected: 00589 XnPixelFormat& PixelFormatImpl() { return m_map.PixelFormat; } 00590 00591 private: 00592 // block copy ctor and assignment operator 00593 MapMetaData& operator=(const MapMetaData&); 00594 inline MapMetaData(const MapMetaData& other); 00595 00596 // Members 00597 XnMapMetaData m_map; 00598 }; 00599 00607 template<class _pixelType> 00608 class Map 00609 { 00610 public: 00611 inline Map(_pixelType*& pData, XnUInt32& nXRes, XnUInt32 &nYRes) : 00612 m_pData(pData), m_nXRes(nXRes), m_nYRes(nYRes) 00613 {} 00614 00622 inline XnUInt32 XRes() const { return m_nXRes; } 00630 inline XnUInt32 YRes() const { return m_nYRes; } 00631 00643 inline const _pixelType& operator[](XnUInt32 nIndex) const 00644 { 00645 XN_ASSERT(nIndex < (m_nXRes * m_nYRes)); 00646 return m_pData[nIndex]; 00647 } 00659 inline _pixelType& operator[](XnUInt32 nIndex) 00660 { 00661 XN_ASSERT(nIndex < (m_nXRes *m_nYRes)); 00662 return m_pData[nIndex]; 00663 } 00664 00673 inline const _pixelType& operator()(XnUInt32 x, XnUInt32 y) const 00674 { 00675 XN_ASSERT(x < m_nXRes && y < m_nYRes); 00676 return m_pData[y*m_nXRes + x]; 00677 } 00686 inline _pixelType& operator()(XnUInt32 x, XnUInt32 y) 00687 { 00688 XN_ASSERT(x < m_nXRes && y < m_nYRes); 00689 return m_pData[y*m_nXRes + x]; 00690 } 00691 00692 private: 00693 /* block copy ctor and assignment operator */ 00694 Map(const Map& other); 00695 Map& operator=(const Map&); 00696 00697 _pixelType*& m_pData; 00698 XnUInt32& m_nXRes; 00699 XnUInt32& m_nYRes; 00700 }; 00701 00706 typedef Map<XnDepthPixel> DepthMap; 00708 typedef Map<XnUInt8> ImageMap; 00710 typedef Map<XnRGB24Pixel> RGB24Map; 00712 typedef Map<XnGrayscale16Pixel> Grayscale16Map; 00714 typedef Map<XnGrayscale8Pixel> Grayscale8Map; 00716 typedef Map<XnIRPixel> IRMap; 00718 typedef Map<XnLabel> LabelMap; 00753 class DepthMetaData : public MapMetaData 00754 { 00755 public: 00759 inline DepthMetaData() : 00760 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_depth.pData), 00761 m_depthMap(const_cast<XnDepthPixel*&>(m_depth.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00762 m_writableDepthMap((XnDepthPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y) 00763 { 00764 xnOSMemSet(&m_depth, 0, sizeof(XnDepthMetaData)); 00765 m_depth.pMap = MapMetaData::GetUnderlying(); 00766 } 00767 00775 inline void InitFrom(const DepthMetaData& other) 00776 { 00777 xnCopyDepthMetaData(&m_depth, &other.m_depth); 00778 } 00779 00790 inline XnStatus InitFrom(const DepthMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer) 00791 { 00792 InitFrom(other); 00793 return ReAdjust(nXRes, nYRes, pExternalBuffer); 00794 } 00795 00802 XnStatus CopyFrom(const DepthMetaData& other) 00803 { 00804 // copy props 00805 InitFrom(other); 00806 // and make a copy of the data (this will allocate and copy data) 00807 return MakeDataWritable(); 00808 } 00809 00813 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnDepthPixel* pExternalBuffer = NULL) 00814 { 00815 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer); 00816 } 00817 00823 inline XnDepthPixel ZRes() const { return m_depth.nZRes; } 00829 inline XnDepthPixel& ZRes() { return m_depth.nZRes; } 00830 00843 inline const XnDepthPixel* Data() const { return (const XnDepthPixel*)MapMetaData::Data(); } 00856 inline const XnDepthPixel*& Data() { return (const XnDepthPixel*&)MapMetaData::Data(); } 00857 00858 00862 inline XnDepthPixel* WritableData() { return (XnDepthPixel*)MapMetaData::WritableData(); } 00863 00867 inline const xn::DepthMap& DepthMap() const { return m_depthMap; } 00871 inline xn::DepthMap& WritableDepthMap() 00872 { 00873 MakeDataWritable(); 00874 return m_writableDepthMap; 00875 } 00876 00882 inline const XnDepthPixel& operator[](XnUInt32 nIndex) const 00883 { 00884 XN_ASSERT(nIndex < (XRes()*YRes())); 00885 return Data()[nIndex]; 00886 } 00887 00894 inline const XnDepthPixel& operator()(XnUInt32 x, XnUInt32 y) const 00895 { 00896 XN_ASSERT(x < XRes() && y < YRes()); 00897 return Data()[y*XRes() + x]; 00898 } 00899 00903 inline const XnDepthMetaData* GetUnderlying() const { return &m_depth; } 00907 inline XnDepthMetaData* GetUnderlying() { return &m_depth; } 00908 00909 private: 00910 // block copy ctor and assignment operator (because we can't return errors in those) 00911 DepthMetaData(const DepthMetaData& other); 00912 DepthMetaData& operator=(const DepthMetaData&); 00913 00914 XnDepthMetaData m_depth; 00915 const xn::DepthMap m_depthMap; 00916 xn::DepthMap m_writableDepthMap; 00917 }; 00918 00945 class ImageMetaData : public MapMetaData 00946 { 00947 public: 00948 inline ImageMetaData() : 00949 MapMetaData(XN_PIXEL_FORMAT_RGB24, &m_image.pData), 00950 m_imageMap(const_cast<XnUInt8*&>(m_image.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00951 m_writableImageMap((XnUInt8*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00952 m_rgb24Map((XnRGB24Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00953 m_writableRgb24Map((XnRGB24Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00954 m_gray16Map((XnGrayscale16Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00955 m_writableGray16Map((XnGrayscale16Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00956 m_gray8Map((XnGrayscale8Pixel*&)m_image.pData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 00957 m_writableGray8Map((XnGrayscale8Pixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y) 00958 { 00959 xnOSMemSet(&m_image, 0, sizeof(XnImageMetaData)); 00960 m_image.pMap = MapMetaData::GetUnderlying(); 00961 } 00962 00970 inline void InitFrom(const ImageMetaData& other) 00971 { 00972 xnCopyImageMetaData(&m_image, &other.m_image); 00973 } 00974 00986 inline XnStatus InitFrom(const ImageMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer) 00987 { 00988 InitFrom(other); 00989 XnStatus nRetVal = ReAdjust(nXRes, nYRes, format, pExternalBuffer); 00990 XN_IS_STATUS_OK(nRetVal); 00991 PixelFormat() = format; 00992 return XN_STATUS_OK; 00993 } 00994 01002 inline XnStatus AllocateData(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format) 01003 { 01004 XnPixelFormat origFormat = PixelFormat(); 01005 PixelFormat() = format; 01006 XnStatus nRetVal = MapMetaData::AllocateData(nXRes, nYRes); 01007 if (nRetVal != XN_STATUS_OK) 01008 { 01009 PixelFormat() = origFormat; 01010 return (nRetVal); 01011 } 01012 01013 return XN_STATUS_OK; 01014 } 01015 01021 inline XnStatus CopyFrom(const ImageMetaData& other) 01022 { 01023 // copy props 01024 xnCopyImageMetaData(&m_image, &other.m_image); 01025 // and make a copy of the data (this will allocate and copy data) 01026 return MakeDataWritable(); 01027 } 01028 01038 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, XnPixelFormat format, const XnUInt8* pExternalBuffer = NULL) 01039 { 01040 XnPixelFormat origFormat = PixelFormat(); 01041 PixelFormat() = format; 01042 XnStatus nRetVal = MapMetaData::ReAdjust(nXRes, nYRes, pExternalBuffer); 01043 if (nRetVal != XN_STATUS_OK) 01044 { 01045 PixelFormat() = origFormat; 01046 return (nRetVal); 01047 } 01048 01049 return XN_STATUS_OK; 01050 } 01051 01063 inline XnPixelFormat PixelFormat() const { return MapMetaData::PixelFormat(); } 01073 inline XnPixelFormat& PixelFormat() { return MapMetaData::PixelFormatImpl(); } 01074 01078 inline XnUInt8* WritableData() { return MapMetaData::WritableData(); } 01079 01084 inline const XnRGB24Pixel* RGB24Data() const { return (const XnRGB24Pixel*)MapMetaData::Data(); } 01089 inline const XnRGB24Pixel*& RGB24Data() { return (const XnRGB24Pixel*&)MapMetaData::Data(); } 01093 inline XnRGB24Pixel* WritableRGB24Data() { return (XnRGB24Pixel*)MapMetaData::WritableData(); } 01094 01100 inline const XnYUV422DoublePixel* YUV422Data() const { return (const XnYUV422DoublePixel*)MapMetaData::Data(); } 01106 inline const XnYUV422DoublePixel*& YUV422Data() { return (const XnYUV422DoublePixel*&)MapMetaData::Data(); } 01110 inline XnYUV422DoublePixel* WritableYUV422Data() { return (XnYUV422DoublePixel*)MapMetaData::WritableData(); } 01111 01116 inline const XnGrayscale8Pixel* Grayscale8Data() const { return (const XnGrayscale8Pixel*)MapMetaData::Data(); } 01121 inline const XnGrayscale8Pixel*& Grayscale8Data() { return (const XnGrayscale8Pixel*&)MapMetaData::Data(); } 01125 inline XnGrayscale8Pixel* WritableGrayscale8Data() { return (XnGrayscale8Pixel*)MapMetaData::WritableData(); } 01126 01131 inline const XnGrayscale16Pixel* Grayscale16Data() const { return (const XnGrayscale16Pixel*)MapMetaData::Data(); } 01136 inline const XnGrayscale16Pixel*& Grayscale16Data() { return (const XnGrayscale16Pixel*&)MapMetaData::Data(); } 01140 inline XnGrayscale16Pixel* WritableGrayscale16Data() { return (XnGrayscale16Pixel*)MapMetaData::WritableData(); } 01141 01145 inline const xn::ImageMap& ImageMap() const { return m_imageMap; } 01149 inline xn::ImageMap& WritableImageMap() { MakeDataWritable(); return m_writableImageMap; } 01150 01156 inline const xn::RGB24Map& RGB24Map() const { return m_rgb24Map; } 01160 inline xn::RGB24Map& WritableRGB24Map() { MakeDataWritable(); return m_writableRgb24Map; } 01161 01165 inline const xn::Grayscale8Map& Grayscale8Map() const { return m_gray8Map; } 01169 inline xn::Grayscale8Map& WritableGrayscale8Map() { MakeDataWritable(); return m_writableGray8Map; } 01170 01175 inline const xn::Grayscale16Map& Grayscale16Map() const { return m_gray16Map; } 01179 inline xn::Grayscale16Map& WritableGrayscale16Map() { MakeDataWritable(); return m_writableGray16Map; } 01180 01184 inline const XnImageMetaData* GetUnderlying() const { return &m_image; } 01188 inline XnImageMetaData* GetUnderlying() { return &m_image; } 01189 01190 private: 01191 // block copy ctor and assignment operator 01192 ImageMetaData(const ImageMetaData& other); 01193 ImageMetaData& operator=(const ImageMetaData&); 01194 01195 XnImageMetaData m_image; 01196 const xn::ImageMap m_imageMap; 01197 xn::ImageMap m_writableImageMap; 01198 const xn::RGB24Map m_rgb24Map; 01199 xn::RGB24Map m_writableRgb24Map; 01200 const xn::Grayscale16Map m_gray16Map; 01201 xn::Grayscale16Map m_writableGray16Map; 01202 const xn::Grayscale8Map m_gray8Map; 01203 xn::Grayscale8Map m_writableGray8Map; 01204 }; 01205 01215 class IRMetaData : public MapMetaData 01216 { 01217 public: 01218 inline IRMetaData() : 01219 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_ir.pData), 01220 m_irMap(const_cast<XnIRPixel*&>(m_ir.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 01221 m_writableIRMap((XnIRPixel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y) 01222 { 01223 xnOSMemSet(&m_ir, 0, sizeof(XnIRMetaData)); 01224 m_ir.pMap = MapMetaData::GetUnderlying(); 01225 } 01226 01234 inline void InitFrom(const IRMetaData& other) 01235 { 01236 xnCopyIRMetaData(&m_ir, &other.m_ir); 01237 } 01238 01248 inline XnStatus InitFrom(const IRMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer) 01249 { 01250 InitFrom(other); 01251 return ReAdjust(nXRes, nYRes, pExternalBuffer); 01252 } 01253 01259 XnStatus CopyFrom(const IRMetaData& other) 01260 { 01261 // copy props 01262 xnCopyIRMetaData(&m_ir, &other.m_ir); 01263 // and make a copy of the data (this will allocate and copy data) 01264 return MakeDataWritable(); 01265 } 01266 01270 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnIRPixel* pExternalBuffer = NULL) 01271 { 01272 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer); 01273 } 01274 01287 inline const XnIRPixel* Data() const { return (const XnIRPixel*)MapMetaData::Data(); } 01300 inline const XnIRPixel*& Data() { return (const XnIRPixel*&)MapMetaData::Data(); } 01304 inline XnIRPixel* WritableData() { return (XnIRPixel*)MapMetaData::WritableData(); } 01305 01311 inline const XnIRPixel& operator[](XnUInt32 nIndex) const 01312 { 01313 XN_ASSERT(nIndex < (XRes()*YRes())); 01314 return Data()[nIndex]; 01315 } 01316 01323 inline const XnIRPixel& operator()(XnUInt32 x, XnUInt32 y) const 01324 { 01325 XN_ASSERT(x < XRes() && y < YRes()); 01326 return Data()[y*XRes() + x]; 01327 } 01328 01337 inline const xn::IRMap& IRMap() const { return m_irMap; } 01346 inline xn::IRMap& WritableIRMap() { MakeDataWritable(); return m_writableIRMap; } 01347 01351 inline const XnIRMetaData* GetUnderlying() const { return &m_ir; } 01355 inline XnIRMetaData* GetUnderlying() { return &m_ir; } 01356 01357 private: 01358 // block copy ctor and assignment operator 01359 IRMetaData(const IRMetaData& other); 01360 IRMetaData& operator=(const IRMetaData&); 01361 01362 XnIRMetaData m_ir; 01363 const xn::IRMap m_irMap; 01364 xn::IRMap m_writableIRMap; 01365 }; 01366 01373 class AudioMetaData : public OutputMetaData 01374 { 01375 public: 01376 XN_PRAGMA_START_DISABLED_WARNING_SECTION(XN_UNALIGNED_ADDRESS_WARNING_ID); 01377 inline AudioMetaData() : OutputMetaData(&m_audio.pData) 01378 { 01379 xnOSMemSet(&m_audio, 0, sizeof(XnAudioMetaData)); 01380 m_audio.pOutput = OutputMetaData::GetUnderlying(); 01381 } 01382 01383 XN_PRAGMA_STOP_DISABLED_WARNING_SECTION; 01384 01392 inline void InitFrom(const AudioMetaData& other) 01393 { 01394 xnCopyAudioMetaData(&m_audio, &other.m_audio); 01395 } 01396 01400 inline XnUInt8 NumberOfChannels() const { return m_audio.Wave.nChannels; } 01404 inline XnUInt8& NumberOfChannels() { return m_audio.Wave.nChannels; } 01405 01409 inline XnUInt32 SampleRate() const { return m_audio.Wave.nSampleRate; } 01413 inline XnUInt32& SampleRate() { return m_audio.Wave.nSampleRate; } 01414 01418 inline XnUInt16 BitsPerSample() const { return m_audio.Wave.nBitsPerSample; } 01422 inline XnUInt16& BitsPerSample() { return m_audio.Wave.nBitsPerSample; } 01423 01427 inline const XnAudioMetaData* GetUnderlying() const { return &m_audio; } 01431 inline XnAudioMetaData* GetUnderlying() { return &m_audio; } 01432 01433 private: 01434 // block copy ctor and assignment operator 01435 AudioMetaData(const AudioMetaData& other); 01436 AudioMetaData& operator=(const AudioMetaData&); 01437 01438 XnAudioMetaData m_audio; 01439 }; 01440 01449 class SceneMetaData : public MapMetaData 01450 { 01451 public: 01452 inline SceneMetaData() : 01453 MapMetaData(XN_PIXEL_FORMAT_GRAYSCALE_16_BIT, (const XnUInt8**)&m_scene.pData), 01454 m_labelMap(const_cast<XnLabel*&>(m_scene.pData), MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y), 01455 m_writableLabelMap((XnLabel*&)m_pAllocatedData, MapMetaData::GetUnderlying()->Res.X, MapMetaData::GetUnderlying()->Res.Y) 01456 { 01457 xnOSMemSet(&m_scene, 0, sizeof(XnSceneMetaData)); 01458 m_scene.pMap = MapMetaData::GetUnderlying(); 01459 } 01460 01468 inline void InitFrom(const SceneMetaData& other) 01469 { 01470 xnCopySceneMetaData(&m_scene, &other.m_scene); 01471 } 01472 01482 inline XnStatus InitFrom(const SceneMetaData& other, XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer) 01483 { 01484 InitFrom(other); 01485 return ReAdjust(nXRes, nYRes, pExternalBuffer); 01486 } 01487 01493 XnStatus CopyFrom(const SceneMetaData& other) 01494 { 01495 // copy props 01496 xnCopySceneMetaData(&m_scene, &other.m_scene); 01497 // and make a copy of the data (this will allocate and copy data) 01498 return MakeDataWritable(); 01499 } 01500 01504 XnStatus ReAdjust(XnUInt32 nXRes, XnUInt32 nYRes, const XnLabel* pExternalBuffer = NULL) 01505 { 01506 return MapMetaData::ReAdjust(nXRes, nYRes, (const XnUInt8*)pExternalBuffer); 01507 } 01508 01522 inline const XnLabel* Data() const { return (const XnLabel*)MapMetaData::Data(); } 01536 inline const XnLabel*& Data() { return (const XnLabel*&)MapMetaData::Data(); } 01537 01541 inline XnLabel* WritableData() { return (XnLabel*)MapMetaData::WritableData(); } 01542 01546 inline const xn::LabelMap& LabelMap() const { return m_labelMap; } 01550 inline xn::LabelMap& WritableLabelMap() { MakeDataWritable(); return m_writableLabelMap; } 01551 01562 inline const XnLabel& operator[](XnUInt32 nIndex) const 01563 { 01564 XN_ASSERT(nIndex < (XRes()*YRes())); 01565 return Data()[nIndex]; 01566 } 01567 01579 inline const XnLabel& operator()(XnUInt32 x, XnUInt32 y) const 01580 { 01581 XN_ASSERT(x < XRes() && y < YRes()); 01582 return (*this)[y*XRes() + x]; 01583 } 01584 01588 inline const XnSceneMetaData* GetUnderlying() const { return &m_scene; } 01592 inline XnSceneMetaData* GetUnderlying() { return &m_scene; } 01593 01594 private: 01595 // block copy ctor and assignment operator 01596 SceneMetaData(const SceneMetaData& other); 01597 SceneMetaData& operator=(const SceneMetaData&); 01598 01599 XnSceneMetaData m_scene; 01600 const xn::LabelMap m_labelMap; 01601 xn::LabelMap m_writableLabelMap; 01602 }; 01603 01604 //--------------------------------------------------------------------------- 01605 // NodeWrapper 01606 //--------------------------------------------------------------------------- 01607 01627 class NodeWrapper 01628 { 01629 public: 01630 friend class Context; 01631 01637 inline NodeWrapper(XnNodeHandle hNode) : m_hNode(NULL), m_hShuttingDownCallback(NULL) 01638 { 01639 SetHandle(hNode); 01640 } 01641 01642 inline NodeWrapper(const NodeWrapper& other) : m_hNode(NULL), m_hShuttingDownCallback(NULL) 01643 { 01644 SetHandle(other.GetHandle()); 01645 } 01646 01647 inline NodeWrapper& operator=(const NodeWrapper& other) 01648 { 01649 SetHandle(other.GetHandle()); 01650 return *this; 01651 } 01652 01653 inline ~NodeWrapper() 01654 { 01655 SetHandle(NULL); 01656 } 01657 01658 inline operator XnNodeHandle() const { return GetHandle(); } 01659 01663 inline XnNodeHandle GetHandle() const { return m_hNode; } 01664 01670 inline XnBool operator==(const NodeWrapper& other) 01671 { 01672 return (GetHandle() == other.GetHandle()); 01673 } 01674 01680 inline XnBool operator!=(const NodeWrapper& other) 01681 { 01682 return (GetHandle() != other.GetHandle()); 01683 } 01684 01698 inline XnBool IsValid() const { return (GetHandle() != NULL); } 01699 01700 /* 01701 * @brief Gets the instance name of a node. Unless the application made a specific 01702 * request for a specific name, the name will be of the form: "Depth1", "Image2", etc. 01703 */ 01704 const XnChar* GetName() const {return xnGetNodeName(GetHandle()); } 01705 01710 inline XnStatus AddRef() { return xnProductionNodeAddRef(GetHandle()); } 01711 01716 inline void Release() 01717 { 01718 SetHandle(NULL); 01719 } 01720 01721 01725 inline void SetHandle(XnNodeHandle hNode) 01726 { 01727 if (m_hNode == hNode) 01728 { 01729 // Optimization: do nothing 01730 return; 01731 } 01732 01733 // check currently held node. If we're holding a node, release it 01734 if (m_hNode != NULL) 01735 { 01736 XnContext* pContext = xnGetRefContextFromNodeHandle(m_hNode); 01737 xnContextUnregisterFromShutdown(pContext, m_hShuttingDownCallback); 01738 xnContextRelease(pContext); 01739 xnProductionNodeRelease(m_hNode); 01740 } 01741 01742 // check new node handle, if it points to a node, add ref to it 01743 if (hNode != NULL) 01744 { 01745 XnStatus nRetVal = xnProductionNodeAddRef(hNode); 01746 XN_ASSERT(nRetVal == XN_STATUS_OK); 01747 XN_REFERENCE_VARIABLE(nRetVal); 01748 01749 XnContext* pContext = xnGetRefContextFromNodeHandle(hNode); 01750 01751 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback); 01752 XN_ASSERT(nRetVal == XN_STATUS_OK); 01753 01754 xnContextRelease(pContext); 01755 } 01756 01757 m_hNode = hNode; 01758 } 01759 01760 inline void TakeOwnership(XnNodeHandle hNode) 01761 { 01762 SetHandle(hNode); 01763 01764 if (hNode != NULL) 01765 { 01766 xnProductionNodeRelease(hNode); 01767 } 01768 } 01769 01771 inline XnStatus XN_API_DEPRECATED("Please use AddRef() instead.") Ref() { return AddRef(); } 01772 inline void XN_API_DEPRECATED("Please use Release() instead.") Unref() { Release(); } 01775 private: 01776 XnNodeHandle m_hNode; 01777 XnCallbackHandle m_hShuttingDownCallback; 01778 01779 static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie) 01780 { 01781 NodeWrapper* pThis = (NodeWrapper*)pCookie; 01782 pThis->m_hNode = NULL; 01783 } 01784 }; 01785 01786 //--------------------------------------------------------------------------- 01787 // Node Info 01788 //--------------------------------------------------------------------------- 01789 01801 class NodeInfo 01802 { 01803 public: 01809 NodeInfo(XnNodeInfo* pInfo) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE) 01810 { 01811 SetUnderlyingObject(pInfo); 01812 } 01813 01819 NodeInfo(const NodeInfo& other) : m_pNeededNodes(NULL), m_bOwnerOfNode(FALSE) 01820 { 01821 SetUnderlyingObject(other.m_pInfo); 01822 } 01823 01827 ~NodeInfo() 01828 { 01829 SetUnderlyingObject(NULL); 01830 } 01831 01837 inline NodeInfo& operator=(const NodeInfo& other) 01838 { 01839 SetUnderlyingObject(other.m_pInfo); 01840 return *this; 01841 } 01842 01846 inline operator XnNodeInfo*() 01847 { 01848 return m_pInfo; 01849 } 01850 01856 inline XnStatus SetInstanceName(const XnChar* strName) 01857 { 01858 return xnNodeInfoSetInstanceName(m_pInfo, strName); 01859 } 01860 01874 inline const XnProductionNodeDescription& GetDescription() const 01875 { 01876 return *xnNodeInfoGetDescription(m_pInfo); 01877 } 01878 01890 inline const XnChar* GetInstanceName() const 01891 { 01892 return xnNodeInfoGetInstanceName(m_pInfo); 01893 } 01894 01906 inline const XnChar* GetCreationInfo() const 01907 { 01908 return xnNodeInfoGetCreationInfo(m_pInfo); 01909 } 01910 01911 /* 01912 * @brief Gets the list of dependant nodes for this node alternative. 01913 * These are any other node alternatives that the node is dependant on. 01914 */ 01915 inline NodeInfoList& GetNeededNodes() const; 01916 01924 inline XnStatus GetInstance(ProductionNode& node) const; 01925 01930 inline const void* GetAdditionalData() const 01931 { 01932 return xnNodeInfoGetAdditionalData(m_pInfo); 01933 } 01934 01939 inline XnStatus GetTreeStringRepresentation(XnChar* csResultBuffer, XnUInt32 nBufferSize) const 01940 { 01941 return xnNodeInfoGetTreeStringRepresentation(m_pInfo, csResultBuffer, nBufferSize); 01942 } 01943 01944 private: 01945 inline void SetUnderlyingObject(XnNodeInfo* pInfo); 01946 01947 XnNodeInfo* m_pInfo; 01948 mutable NodeInfoList* m_pNeededNodes; 01949 XnBool m_bOwnerOfNode; // backwards compatibility 01950 friend class Context; 01951 }; 01952 01953 //--------------------------------------------------------------------------- 01954 // Query 01955 //--------------------------------------------------------------------------- 01956 01975 class Query 01976 { 01977 public: 01978 inline Query() : m_bAllocated(TRUE) 01979 { 01980 xnNodeQueryAllocate(&m_pQuery); 01981 } 01982 01983 inline Query(XnNodeQuery* pNodeQuery) : m_pQuery(pNodeQuery), m_bAllocated(FALSE) 01984 { 01985 } 01986 01987 ~Query() 01988 { 01989 if (m_bAllocated) 01990 { 01991 xnNodeQueryFree(m_pQuery); 01992 } 01993 } 01994 01998 inline const XnNodeQuery* GetUnderlyingObject() const { return m_pQuery; } 01999 inline XnNodeQuery* GetUnderlyingObject() { return m_pQuery; } 02000 02005 inline XnStatus SetVendor(const XnChar* strVendor) 02006 { 02007 return xnNodeQuerySetVendor(m_pQuery, strVendor); 02008 } 02009 02018 inline XnStatus SetName(const XnChar* strName) 02019 { 02020 return xnNodeQuerySetName(m_pQuery, strName); 02021 } 02022 02026 inline XnStatus SetMinVersion(const XnVersion& minVersion) 02027 { 02028 return xnNodeQuerySetMinVersion(m_pQuery, &minVersion); 02029 } 02030 02034 inline XnStatus SetMinVersion(const Version& minVersion) 02035 { 02036 return xnNodeQuerySetMinVersion(m_pQuery, minVersion.GetUnderlying()); 02037 } 02038 02042 inline XnStatus SetMaxVersion(const XnVersion& maxVersion) 02043 { 02044 return xnNodeQuerySetMaxVersion(m_pQuery, &maxVersion); 02045 } 02046 02050 inline XnStatus SetMaxVersion(const Version& maxVersion) 02051 { 02052 return xnNodeQuerySetMaxVersion(m_pQuery, maxVersion.GetUnderlying()); 02053 } 02054 02067 inline XnStatus AddSupportedCapability(const XnChar* strNeededCapability) 02068 { 02069 return xnNodeQueryAddSupportedCapability(m_pQuery, strNeededCapability); 02070 } 02071 02082 inline XnStatus AddSupportedMapOutputMode(const XnMapOutputMode& MapOutputMode) 02083 { 02084 return xnNodeQueryAddSupportedMapOutputMode(m_pQuery, &MapOutputMode); 02085 } 02086 02091 inline XnStatus SetSupportedMinUserPositions(const XnUInt32 nCount) 02092 { 02093 return xnNodeQuerySetSupportedMinUserPositions(m_pQuery, nCount); 02094 } 02095 02107 inline XnStatus SetExistingNodeOnly(XnBool bExistingNode) 02108 { 02109 return xnNodeQuerySetExistingNodeOnly(m_pQuery, bExistingNode); 02110 } 02111 02116 inline XnStatus AddNeededNode(const XnChar* strInstanceName) 02117 { 02118 return xnNodeQueryAddNeededNode(m_pQuery, strInstanceName); 02119 } 02120 02125 inline XnStatus SetCreationInfo(const XnChar* strCreationInfo) 02126 { 02127 return xnNodeQuerySetCreationInfo(m_pQuery, strCreationInfo); 02128 } 02129 02130 private: 02131 XnNodeQuery* m_pQuery; 02132 XnBool m_bAllocated; 02133 }; 02134 02135 //--------------------------------------------------------------------------- 02136 // Node Info List 02137 //--------------------------------------------------------------------------- 02138 02143 class NodeInfoList 02144 { 02145 public: 02149 class Iterator 02150 { 02151 public: 02152 friend class NodeInfoList; 02153 02166 XnBool operator==(const Iterator& other) const 02167 { 02168 return m_it.pCurrent == other.m_it.pCurrent; 02169 } 02170 02177 XnBool operator!=(const Iterator& other) const 02178 { 02179 return m_it.pCurrent != other.m_it.pCurrent; 02180 } 02181 02186 inline Iterator& operator++() 02187 { 02188 UpdateInternalObject(xnNodeInfoListGetNext(m_it)); 02189 return *this; 02190 } 02191 02196 inline Iterator operator++(int) 02197 { 02198 XnNodeInfoListIterator curr = m_it; 02199 UpdateInternalObject(xnNodeInfoListGetNext(m_it)); 02200 return Iterator(curr); 02201 } 02202 02206 inline Iterator& operator--() 02207 { 02208 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it)); 02209 return *this; 02210 } 02211 02215 inline Iterator operator--(int) 02216 { 02217 XnNodeInfoListIterator curr = m_it; 02218 UpdateInternalObject(xnNodeInfoListGetPrevious(m_it)); 02219 return Iterator(curr); 02220 } 02221 02225 inline NodeInfo operator*() 02226 { 02227 return m_Info; 02228 } 02229 02230 private: 02231 inline Iterator(XnNodeInfoListIterator it) : m_Info(NULL) 02232 { 02233 UpdateInternalObject(it); 02234 } 02235 02236 inline void UpdateInternalObject(XnNodeInfoListIterator it) 02237 { 02238 m_it = it; 02239 if (xnNodeInfoListIteratorIsValid(it)) 02240 { 02241 XnNodeInfo* pInfo = xnNodeInfoListGetCurrent(it); 02242 m_Info = NodeInfo(pInfo); 02243 } 02244 else 02245 { 02246 m_Info = NodeInfo(NULL); 02247 } 02248 } 02249 02250 NodeInfo m_Info; 02251 XnNodeInfoListIterator m_it; 02252 }; 02253 02257 inline NodeInfoList() 02258 { 02259 xnNodeInfoListAllocate(&m_pList); 02260 m_bAllocated = TRUE; 02261 } 02262 02269 inline NodeInfoList(XnNodeInfoList* pList) : m_pList(pList), m_bAllocated(FALSE) {} 02270 02271 inline ~NodeInfoList() 02272 { 02273 FreeImpl(); 02274 } 02275 02279 inline XnNodeInfoList* GetUnderlyingObject() const { return m_pList; } 02280 02287 inline void ReplaceUnderlyingObject(XnNodeInfoList* pList) 02288 { 02289 FreeImpl(); 02290 m_pList = pList; 02291 m_bAllocated = TRUE; 02292 } 02293 02298 inline XnStatus Add(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes) 02299 { 02300 XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject(); 02301 return xnNodeInfoListAdd(m_pList, &description, strCreationInfo, pList); 02302 } 02303 02308 inline XnStatus AddEx(XnProductionNodeDescription& description, const XnChar* strCreationInfo, NodeInfoList* pNeededNodes, const void* pAdditionalData, XnFreeHandler pFreeHandler) 02309 { 02310 XnNodeInfoList* pList = (pNeededNodes == NULL) ? NULL : pNeededNodes->GetUnderlyingObject(); 02311 return xnNodeInfoListAddEx(m_pList, &description, strCreationInfo, pList, pAdditionalData, pFreeHandler); 02312 } 02313 02318 inline XnStatus AddNode(NodeInfo& info) 02319 { 02320 return xnNodeInfoListAddNode(m_pList, info); 02321 } 02322 02327 inline XnStatus AddNodeFromAnotherList(Iterator& it) 02328 { 02329 return xnNodeInfoListAddNodeFromList(m_pList, it.m_it); 02330 } 02331 02336 inline Iterator Begin() const 02337 { 02338 return Iterator(xnNodeInfoListGetFirst(m_pList)); 02339 } 02340 02345 inline Iterator End() const 02346 { 02347 XnNodeInfoListIterator it = { NULL }; 02348 return Iterator(it); 02349 } 02350 02355 inline Iterator RBegin() const 02356 { 02357 return Iterator(xnNodeInfoListGetLast(m_pList)); 02358 } 02359 02364 inline Iterator REnd() const 02365 { 02366 XnNodeInfoListIterator it = { NULL }; 02367 return Iterator(it); 02368 } 02369 02374 inline XnStatus Remove(Iterator& it) 02375 { 02376 return xnNodeInfoListRemove(m_pList, it.m_it); 02377 } 02378 02383 inline XnStatus Clear() 02384 { 02385 return xnNodeInfoListClear(m_pList); 02386 } 02387 02392 inline XnStatus Append(NodeInfoList& other) 02393 { 02394 return xnNodeInfoListAppend(m_pList, other.GetUnderlyingObject()); 02395 } 02396 02400 inline XnBool IsEmpty() 02401 { 02402 return xnNodeInfoListIsEmpty(m_pList); 02403 } 02404 02409 inline XnStatus FilterList(Context& context, Query& query); 02410 02411 private: 02412 inline void FreeImpl() 02413 { 02414 if (m_bAllocated) 02415 { 02416 xnNodeInfoListFree(m_pList); 02417 m_bAllocated = FALSE; 02418 m_pList = NULL; 02419 } 02420 } 02421 02422 XnNodeInfoList* m_pList; 02423 XnBool m_bAllocated; 02424 }; 02425 02426 //--------------------------------------------------------------------------- 02427 // Production Nodes Functionality 02428 //--------------------------------------------------------------------------- 02429 02434 class Capability : public NodeWrapper 02435 { 02436 public: 02442 Capability(XnNodeHandle hNode) : NodeWrapper(hNode) {} 02443 Capability(const NodeWrapper& node) : NodeWrapper(node) {} 02444 }; 02445 02479 class ErrorStateCapability : public Capability 02480 { 02481 public: 02487 ErrorStateCapability(XnNodeHandle hNode) : Capability(hNode) {} 02488 ErrorStateCapability(const NodeWrapper& node) : Capability(node) {} 02489 02493 inline XnStatus GetErrorState() const 02494 { 02495 return xnGetNodeErrorState(GetHandle()); 02496 } 02497 02507 inline XnStatus RegisterToErrorStateChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 02508 { 02509 return _RegisterToStateChange(xnRegisterToNodeErrorStateChange, GetHandle(), handler, pCookie, hCallback); 02510 } 02511 02519 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback) 02520 { 02521 _UnregisterFromStateChange(xnUnregisterFromNodeErrorStateChange, GetHandle(), hCallback); 02522 } 02523 }; 02524 02530 class GeneralIntCapability : public Capability 02531 { 02532 public: 02539 GeneralIntCapability(XnNodeHandle hNode, const XnChar* strCap) : Capability(hNode), m_strCap(strCap) {} 02540 GeneralIntCapability(const NodeWrapper& node, const XnChar* strCap) : Capability(node), m_strCap(strCap) {} 02541 02546 inline void GetRange(XnInt32& nMin, XnInt32& nMax, XnInt32& nStep, XnInt32& nDefault, XnBool& bIsAutoSupported) const 02547 { 02548 xnGetGeneralIntRange(GetHandle(), m_strCap, &nMin, &nMax, &nStep, &nDefault, &bIsAutoSupported); 02549 } 02550 02555 inline XnInt32 Get() 02556 { 02557 XnInt32 nValue; 02558 xnGetGeneralIntValue(GetHandle(), m_strCap, &nValue); 02559 return nValue; 02560 } 02561 02566 inline XnStatus Set(XnInt32 nValue) 02567 { 02568 return xnSetGeneralIntValue(GetHandle(), m_strCap, nValue); 02569 } 02570 02580 XnStatus RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback); 02581 02589 void UnregisterFromValueChange(XnCallbackHandle hCallback); 02590 02591 private: 02592 const XnChar* m_strCap; 02593 }; 02594 02630 class ProductionNode : public NodeWrapper 02631 { 02632 public: 02638 inline ProductionNode(XnNodeHandle hNode = NULL) : NodeWrapper(hNode) {} 02639 inline ProductionNode(const NodeWrapper& other) : NodeWrapper(other) {} 02640 02649 inline NodeInfo GetInfo() const { return NodeInfo(xnGetNodeInfo(GetHandle())); } 02650 02655 inline XnStatus AddNeededNode(ProductionNode& needed) 02656 { 02657 return xnAddNeededNode(GetHandle(), needed.GetHandle()); 02658 } 02659 02664 inline XnStatus RemoveNeededNode(ProductionNode& needed) 02665 { 02666 return xnRemoveNeededNode(GetHandle(), needed.GetHandle()); 02667 } 02668 02680 inline void GetContext(Context& context) const; 02681 02691 inline Context GetContext() const; 02692 02704 inline XnBool IsCapabilitySupported(const XnChar* strCapabilityName) const 02705 { 02706 return xnIsCapabilitySupported(GetHandle(), strCapabilityName); 02707 } 02708 02713 inline XnStatus SetIntProperty(const XnChar* strName, XnUInt64 nValue) 02714 { 02715 return xnSetIntProperty(GetHandle(), strName, nValue); 02716 } 02717 02722 inline XnStatus SetRealProperty(const XnChar* strName, XnDouble dValue) 02723 { 02724 return xnSetRealProperty(GetHandle(), strName, dValue); 02725 } 02726 02731 inline XnStatus SetStringProperty(const XnChar* strName, const XnChar* strValue) 02732 { 02733 return xnSetStringProperty(GetHandle(), strName, strValue); 02734 } 02735 02740 inline XnStatus SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer) 02741 { 02742 return xnSetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer); 02743 } 02744 02749 inline XnStatus GetIntProperty(const XnChar* strName, XnUInt64& nValue) const 02750 { 02751 return xnGetIntProperty(GetHandle(), strName, &nValue); 02752 } 02753 02758 inline XnStatus GetRealProperty(const XnChar* strName, XnDouble &dValue) const 02759 { 02760 return xnGetRealProperty(GetHandle(), strName, &dValue); 02761 } 02762 02767 inline XnStatus GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const 02768 { 02769 return xnGetStringProperty(GetHandle(), strName, csValue, nBufSize); 02770 } 02771 02776 inline XnStatus GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const 02777 { 02778 return xnGetGeneralProperty(GetHandle(), strName, nBufferSize, pBuffer); 02779 } 02780 02785 inline XnStatus LockForChanges(XnLockHandle* phLock) 02786 { 02787 return xnLockNodeForChanges(GetHandle(), phLock); 02788 } 02789 02794 inline void UnlockForChanges(XnLockHandle hLock) 02795 { 02796 xnUnlockNodeForChanges(GetHandle(), hLock); 02797 } 02798 02803 inline XnStatus LockedNodeStartChanges(XnLockHandle hLock) 02804 { 02805 return xnLockedNodeStartChanges(GetHandle(), hLock); 02806 } 02807 02812 inline void LockedNodeEndChanges(XnLockHandle hLock) 02813 { 02814 xnLockedNodeEndChanges(GetHandle(), hLock); 02815 } 02816 02825 inline const ErrorStateCapability GetErrorStateCap() const 02826 { 02827 return ErrorStateCapability(GetHandle()); 02828 } 02829 02838 inline ErrorStateCapability GetErrorStateCap() 02839 { 02840 return ErrorStateCapability(GetHandle()); 02841 } 02842 02854 inline GeneralIntCapability GetGeneralIntCap(const XnChar* strCapability) 02855 { 02856 return GeneralIntCapability(GetHandle(), strCapability); 02857 } 02858 }; 02859 02869 class DeviceIdentificationCapability : public Capability 02870 { 02871 public: 02877 DeviceIdentificationCapability(XnNodeHandle hNode) : Capability(hNode) {} 02878 DeviceIdentificationCapability(const NodeWrapper& node) : Capability(node) {} 02879 02889 inline XnStatus GetDeviceName(XnChar* strBuffer, XnUInt32 nBufferSize) 02890 { 02891 return xnGetDeviceName(GetHandle(), strBuffer, &nBufferSize); 02892 } 02893 02903 inline XnStatus GetVendorSpecificData(XnChar* strBuffer, XnUInt32 nBufferSize) 02904 { 02905 return xnGetVendorSpecificData(GetHandle(), strBuffer, &nBufferSize); 02906 } 02907 02917 inline XnStatus GetSerialNumber(XnChar* strBuffer, XnUInt32 nBufferSize) 02918 { 02919 return xnGetSerialNumber(GetHandle(), strBuffer, &nBufferSize); 02920 } 02921 }; 02922 02936 class Device : public ProductionNode 02937 { 02938 public: 02939 inline Device(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 02940 inline Device(const NodeWrapper& other) : ProductionNode(other) {} 02941 02950 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 02951 02965 inline DeviceIdentificationCapability GetIdentificationCap() 02966 { 02967 return DeviceIdentificationCapability(GetHandle()); 02968 } 02969 }; 02970 03018 class MirrorCapability : public Capability 03019 { 03020 public: 03021 inline MirrorCapability(XnNodeHandle hNode) : Capability(hNode) {} 03022 MirrorCapability(const NodeWrapper& node) : Capability(node) {} 03023 03030 inline XnStatus SetMirror(XnBool bMirror) 03031 { 03032 return xnSetMirror(GetHandle(), bMirror); 03033 } 03034 03038 inline XnBool IsMirrored() const 03039 { 03040 return xnIsMirrored(GetHandle()); 03041 } 03042 03052 inline XnStatus RegisterToMirrorChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 03053 { 03054 return _RegisterToStateChange(xnRegisterToMirrorChange, GetHandle(), handler, pCookie, hCallback); 03055 } 03056 03064 inline void UnregisterFromMirrorChange(XnCallbackHandle hCallback) 03065 { 03066 _UnregisterFromStateChange(xnUnregisterFromMirrorChange, GetHandle(), hCallback); 03067 } 03068 }; 03069 03102 class AlternativeViewPointCapability : public Capability 03103 { 03104 public: 03105 inline AlternativeViewPointCapability(XnNodeHandle hNode) : Capability(hNode) {} 03106 AlternativeViewPointCapability(const NodeWrapper& node) : Capability(node) {} 03107 03122 inline XnBool IsViewPointSupported(ProductionNode& otherNode) const 03123 { 03124 return xnIsViewPointSupported(GetHandle(), otherNode.GetHandle()); 03125 } 03126 03134 inline XnStatus SetViewPoint(ProductionNode& otherNode) 03135 { 03136 return xnSetViewPoint(GetHandle(), otherNode.GetHandle()); 03137 } 03138 03142 inline XnStatus ResetViewPoint() 03143 { 03144 return xnResetViewPoint(GetHandle()); 03145 } 03146 03154 inline XnBool IsViewPointAs(ProductionNode& otherNode) const 03155 { 03156 return xnIsViewPointAs(GetHandle(), otherNode.GetHandle()); 03157 } 03158 03168 inline XnStatus RegisterToViewPointChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 03169 { 03170 return _RegisterToStateChange(xnRegisterToViewPointChange, GetHandle(), handler, pCookie, hCallback); 03171 } 03172 03180 inline void UnregisterFromViewPointChange(XnCallbackHandle hCallback) 03181 { 03182 _UnregisterFromStateChange(xnUnregisterFromViewPointChange, GetHandle(), hCallback); 03183 } 03184 03196 XnStatus GetPixelCoordinatesInViewPoint(ProductionNode& other, XnUInt32 x, XnUInt32 y, XnUInt32& altX, XnUInt32& altY) 03197 { 03198 return xnGetPixelCoordinatesInViewPoint(GetHandle(), other.GetHandle(), x, y, &altX, &altY); 03199 } 03200 }; 03201 03223 class FrameSyncCapability : public Capability 03224 { 03225 public: 03226 inline FrameSyncCapability(XnNodeHandle hNode) : Capability(hNode) {} 03227 FrameSyncCapability(const NodeWrapper& node) : Capability(node) {} 03228 03237 inline XnBool CanFrameSyncWith(Generator& other) const; 03238 03245 inline XnStatus FrameSyncWith(Generator& other); 03246 03251 inline XnStatus StopFrameSyncWith(Generator& other); 03252 03259 inline XnBool IsFrameSyncedWith(Generator& other) const; 03260 03270 inline XnStatus RegisterToFrameSyncChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 03271 { 03272 return _RegisterToStateChange(xnRegisterToFrameSyncChange, GetHandle(), handler, pCookie, hCallback); 03273 } 03274 03282 inline void UnregisterFromFrameSyncChange(XnCallbackHandle hCallback) 03283 { 03284 _UnregisterFromStateChange(xnUnregisterFromFrameSyncChange, GetHandle(), hCallback); 03285 } 03286 }; 03287 03340 class Generator : public ProductionNode 03341 { 03342 public: 03348 inline Generator(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 03349 inline Generator(const NodeWrapper& other) : ProductionNode(other) {} 03350 03370 inline XnStatus StartGenerating() 03371 { 03372 return xnStartGenerating(GetHandle()); 03373 } 03374 03378 inline XnBool IsGenerating() const 03379 { 03380 return xnIsGenerating(GetHandle()); 03381 } 03382 03391 inline XnStatus StopGenerating() 03392 { 03393 return xnStopGenerating(GetHandle()); 03394 } 03395 03409 inline XnStatus RegisterToGenerationRunningChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback) 03410 { 03411 return _RegisterToStateChange(xnRegisterToGenerationRunningChange, GetHandle(), handler, pCookie, hCallback); 03412 } 03413 03421 inline void UnregisterFromGenerationRunningChange(XnCallbackHandle hCallback) 03422 { 03423 _UnregisterFromStateChange(xnUnregisterFromGenerationRunningChange, GetHandle(), hCallback); 03424 } 03425 03439 inline XnStatus RegisterToNewDataAvailable(StateChangedHandler handler, void* pCookie, XnCallbackHandle &hCallback) 03440 { 03441 return _RegisterToStateChange(xnRegisterToNewDataAvailable, GetHandle(), handler, pCookie, hCallback); 03442 } 03443 03451 inline void UnregisterFromNewDataAvailable(XnCallbackHandle hCallback) 03452 { 03453 _UnregisterFromStateChange(xnUnregisterFromNewDataAvailable, GetHandle(), hCallback); 03454 } 03455 03464 inline XnBool IsNewDataAvailable(XnUInt64* pnTimestamp = NULL) const 03465 { 03466 return xnIsNewDataAvailable(GetHandle(), pnTimestamp); 03467 } 03468 03487 inline XnStatus WaitAndUpdateData() 03488 { 03489 return xnWaitAndUpdateData(GetHandle()); 03490 } 03491 03496 inline XnBool IsDataNew() const 03497 { 03498 return xnIsDataNew(GetHandle()); 03499 } 03500 03518 inline const void* GetData() 03519 { 03520 return xnGetData(GetHandle()); 03521 } 03522 03536 inline XnUInt32 GetDataSize() const 03537 { 03538 return xnGetDataSize(GetHandle()); 03539 } 03540 03554 inline XnUInt64 GetTimestamp() const 03555 { 03556 return xnGetTimestamp(GetHandle()); 03557 } 03558 03571 inline XnUInt32 GetFrameID() const 03572 { 03573 return xnGetFrameID(GetHandle()); 03574 } 03575 03584 inline const MirrorCapability GetMirrorCap() const 03585 { 03586 return MirrorCapability(GetHandle()); 03587 } 03588 03597 inline MirrorCapability GetMirrorCap() 03598 { 03599 return MirrorCapability(GetHandle()); 03600 } 03601 03612 inline const AlternativeViewPointCapability GetAlternativeViewPointCap() const 03613 { 03614 return AlternativeViewPointCapability(GetHandle()); 03615 } 03616 03627 inline AlternativeViewPointCapability GetAlternativeViewPointCap() 03628 { 03629 return AlternativeViewPointCapability(GetHandle()); 03630 } 03631 03641 inline const FrameSyncCapability GetFrameSyncCap() const 03642 { 03643 return FrameSyncCapability(GetHandle()); 03644 } 03645 03655 inline FrameSyncCapability GetFrameSyncCap() 03656 { 03657 return FrameSyncCapability(GetHandle()); 03658 } 03659 }; 03660 03705 class Recorder : public ProductionNode 03706 { 03707 public: 03713 inline Recorder(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 03714 inline Recorder(const NodeWrapper& other) : ProductionNode(other) {} 03715 03723 inline XnStatus Create(Context& context, const XnChar* strFormatName = NULL); 03724 03733 inline XnStatus SetDestination(XnRecordMedium destType, const XnChar* strDest) 03734 { 03735 return xnSetRecorderDestination(GetHandle(), destType, strDest); 03736 } 03737 03747 inline XnStatus GetDestination(XnRecordMedium& destType, XnChar* strDest, XnUInt32 nBufSize) 03748 { 03749 return xnGetRecorderDestination(GetHandle(), &destType, strDest, nBufSize); 03750 } 03751 03761 inline XnStatus AddNodeToRecording(ProductionNode& Node, XnCodecID compression = XN_CODEC_NULL) 03762 { 03763 return xnAddNodeToRecording(GetHandle(), Node.GetHandle(), compression); 03764 } 03765 03772 inline XnStatus RemoveNodeFromRecording(ProductionNode& Node) 03773 { 03774 return xnRemoveNodeFromRecording(GetHandle(), Node.GetHandle()); 03775 } 03776 03789 inline XnStatus Record() 03790 { 03791 return xnRecord(GetHandle()); 03792 } 03793 }; 03794 03822 class Player : public ProductionNode 03823 { 03824 public: 03830 inline Player(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 03831 inline Player(const NodeWrapper& other) : ProductionNode(other) {} 03832 03841 inline XnStatus Create(Context& context, const XnChar* strFormatName); 03842 03843 03858 inline XnStatus SetRepeat(XnBool bRepeat) 03859 { 03860 return xnSetPlayerRepeat(GetHandle(), bRepeat); 03861 } 03862 03867 inline XnStatus SetSource(XnRecordMedium sourceType, const XnChar* strSource) 03868 { 03869 return xnSetPlayerSource(GetHandle(), sourceType, strSource); 03870 } 03871 03880 inline XnStatus GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) const 03881 { 03882 return xnGetPlayerSource(GetHandle(), &sourceType, strSource, nBufSize); 03883 } 03884 03889 inline XnStatus ReadNext() 03890 { 03891 return xnPlayerReadNext(GetHandle()); 03892 } 03893 03918 inline XnStatus SeekToTimeStamp(XnInt64 nTimeOffset, XnPlayerSeekOrigin origin) 03919 { 03920 return xnSeekPlayerToTimeStamp(GetHandle(), nTimeOffset, origin); 03921 } 03922 03947 inline XnStatus SeekToFrame(const XnChar* strNodeName, XnInt32 nFrameOffset, XnPlayerSeekOrigin origin) 03948 { 03949 return xnSeekPlayerToFrame(GetHandle(), strNodeName, nFrameOffset, origin); 03950 } 03951 03957 inline XnStatus TellTimestamp(XnUInt64& nTimestamp) const 03958 { 03959 return xnTellPlayerTimestamp(GetHandle(), &nTimestamp); 03960 } 03961 03974 inline XnStatus TellFrame(const XnChar* strNodeName, XnUInt32& nFrame) const 03975 { 03976 return xnTellPlayerFrame(GetHandle(), strNodeName, &nFrame); 03977 } 03978 03986 inline XnStatus GetNumFrames(const XnChar* strNodeName, XnUInt32& nFrames) const 03987 { 03988 return xnGetPlayerNumFrames(GetHandle(), strNodeName, &nFrames); 03989 } 03990 03995 inline const XnChar* GetSupportedFormat() const 03996 { 03997 return xnGetPlayerSupportedFormat(GetHandle()); 03998 } 03999 04004 inline XnStatus EnumerateNodes(NodeInfoList& list) const 04005 { 04006 XnNodeInfoList* pList; 04007 XnStatus nRetVal = xnEnumeratePlayerNodes(GetHandle(), &pList); 04008 XN_IS_STATUS_OK(nRetVal); 04009 04010 list.ReplaceUnderlyingObject(pList); 04011 04012 return (XN_STATUS_OK); 04013 } 04014 04023 inline XnBool IsEOF() const 04024 { 04025 return xnIsPlayerAtEOF(GetHandle()); 04026 } 04027 04037 inline XnStatus RegisterToEndOfFileReached(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04038 { 04039 return _RegisterToStateChange(xnRegisterToEndOfFileReached, GetHandle(), handler, pCookie, hCallback); 04040 } 04041 04049 inline void UnregisterFromEndOfFileReached(XnCallbackHandle hCallback) 04050 { 04051 _UnregisterFromStateChange(xnUnregisterFromEndOfFileReached, GetHandle(), hCallback); 04052 } 04053 04072 inline XnStatus SetPlaybackSpeed(XnDouble dSpeed) 04073 { 04074 return xnSetPlaybackSpeed(GetHandle(), dSpeed); 04075 } 04076 04081 inline XnDouble GetPlaybackSpeed() const 04082 { 04083 return xnGetPlaybackSpeed(GetHandle()); 04084 } 04085 }; 04086 04114 class CroppingCapability : public Capability 04115 { 04116 public: 04122 inline CroppingCapability(XnNodeHandle hNode) : Capability(hNode) {} 04123 CroppingCapability(const NodeWrapper& node) : Capability(node) {} 04124 04134 inline XnStatus SetCropping(const XnCropping& Cropping) 04135 { 04136 return xnSetCropping(GetHandle(), &Cropping); 04137 } 04138 04149 inline XnStatus GetCropping(XnCropping& Cropping) const 04150 { 04151 return xnGetCropping(GetHandle(), &Cropping); 04152 } 04153 04163 inline XnStatus RegisterToCroppingChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04164 { 04165 return _RegisterToStateChange(xnRegisterToCroppingChange, GetHandle(), handler, pCookie, hCallback); 04166 } 04167 04175 inline void UnregisterFromCroppingChange(XnCallbackHandle hCallback) 04176 { 04177 _UnregisterFromStateChange(xnUnregisterFromCroppingChange, GetHandle(), hCallback); 04178 } 04179 }; 04180 04189 class AntiFlickerCapability : public Capability 04190 { 04191 public: 04197 inline AntiFlickerCapability(XnNodeHandle hNode) : Capability(hNode) {} 04198 AntiFlickerCapability(const NodeWrapper& node) : Capability(node) {} 04199 04204 inline XnStatus SetPowerLineFrequency(XnPowerLineFrequency nFrequency) 04205 { 04206 return xnSetPowerLineFrequency(GetHandle(), nFrequency); 04207 } 04208 04213 inline XnPowerLineFrequency GetPowerLineFrequency() 04214 { 04215 return xnGetPowerLineFrequency(GetHandle()); 04216 } 04217 04227 inline XnStatus RegisterToPowerLineFrequencyChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04228 { 04229 return _RegisterToStateChange(xnRegisterToPowerLineFrequencyChange, GetHandle(), handler, pCookie, hCallback); 04230 } 04231 04239 inline void UnregisterFromPowerLineFrequencyChange(XnCallbackHandle hCallback) 04240 { 04241 _UnregisterFromStateChange(xnUnregisterFromPowerLineFrequencyChange, GetHandle(), hCallback); 04242 } 04243 }; 04244 04268 class MapGenerator : public Generator 04269 { 04270 public: 04276 inline MapGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 04277 inline MapGenerator(const NodeWrapper& other) : Generator(other) {} 04278 04286 inline XnUInt32 GetSupportedMapOutputModesCount() const 04287 { 04288 return xnGetSupportedMapOutputModesCount(GetHandle()); 04289 } 04290 04301 inline XnStatus GetSupportedMapOutputModes(XnMapOutputMode* aModes, XnUInt32& nCount) const 04302 { 04303 return xnGetSupportedMapOutputModes(GetHandle(), aModes, &nCount); 04304 } 04305 04319 inline XnStatus SetMapOutputMode(const XnMapOutputMode& OutputMode) 04320 { 04321 return xnSetMapOutputMode(GetHandle(), &OutputMode); 04322 } 04323 04341 inline XnStatus GetMapOutputMode(XnMapOutputMode &OutputMode) const 04342 { 04343 return xnGetMapOutputMode(GetHandle(), &OutputMode); 04344 } 04345 04354 inline XnUInt32 GetBytesPerPixel() const 04355 { 04356 return xnGetBytesPerPixel(GetHandle()); 04357 } 04358 04368 inline XnStatus RegisterToMapOutputModeChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04369 { 04370 return _RegisterToStateChange(xnRegisterToMapOutputModeChange, GetHandle(), handler, pCookie, hCallback); 04371 } 04372 04380 inline void UnregisterFromMapOutputModeChange(XnCallbackHandle hCallback) 04381 { 04382 _UnregisterFromStateChange(xnUnregisterFromMapOutputModeChange, GetHandle(), hCallback); 04383 } 04384 04393 inline const CroppingCapability GetCroppingCap() const 04394 { 04395 return CroppingCapability(GetHandle()); 04396 } 04397 04406 inline CroppingCapability GetCroppingCap() 04407 { 04408 return CroppingCapability(GetHandle()); 04409 } 04410 04416 inline GeneralIntCapability GetBrightnessCap() 04417 { 04418 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BRIGHTNESS); 04419 } 04420 04426 inline GeneralIntCapability GetContrastCap() 04427 { 04428 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_CONTRAST); 04429 } 04430 04436 inline GeneralIntCapability GetHueCap() 04437 { 04438 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_HUE); 04439 } 04440 04446 inline GeneralIntCapability GetSaturationCap() 04447 { 04448 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SATURATION); 04449 } 04450 04456 inline GeneralIntCapability GetSharpnessCap() 04457 { 04458 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_SHARPNESS); 04459 } 04460 04466 inline GeneralIntCapability GetGammaCap() 04467 { 04468 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAMMA); 04469 } 04470 04476 inline GeneralIntCapability GetWhiteBalanceCap() 04477 { 04478 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_COLOR_TEMPERATURE); 04479 } 04480 04486 inline GeneralIntCapability GetBacklightCompensationCap() 04487 { 04488 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_BACKLIGHT_COMPENSATION); 04489 } 04490 04496 inline GeneralIntCapability GetGainCap() 04497 { 04498 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_GAIN); 04499 } 04500 04506 inline GeneralIntCapability GetPanCap() 04507 { 04508 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_PAN); 04509 } 04510 04516 inline GeneralIntCapability GetTiltCap() 04517 { 04518 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_TILT); 04519 } 04520 04526 inline GeneralIntCapability GetRollCap() 04527 { 04528 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ROLL); 04529 } 04530 04536 inline GeneralIntCapability GetZoomCap() 04537 { 04538 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_ZOOM); 04539 } 04540 04546 inline GeneralIntCapability GetExposureCap() 04547 { 04548 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_EXPOSURE); 04549 } 04550 04556 inline GeneralIntCapability GetAutoExposureCap() 04557 { 04558 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_AUTO_EXPOSURE); 04559 } 04560 04561 04567 inline GeneralIntCapability GetIrisCap() 04568 { 04569 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_IRIS); 04570 } 04571 04577 inline GeneralIntCapability GetFocusCap() 04578 { 04579 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_FOCUS); 04580 } 04581 04587 inline GeneralIntCapability GetLowLightCompensationCap() 04588 { 04589 return GeneralIntCapability(GetHandle(), XN_CAPABILITY_LOW_LIGHT_COMPENSATION); 04590 } 04591 04597 inline AntiFlickerCapability GetAntiFlickerCap() 04598 { 04599 return AntiFlickerCapability(GetHandle()); 04600 } 04601 }; 04602 04611 class UserPositionCapability : public Capability 04612 { 04613 public: 04619 inline UserPositionCapability(XnNodeHandle hNode = NULL) : Capability(hNode) {} 04620 UserPositionCapability(const NodeWrapper& node) : Capability(node) {} 04621 04626 inline XnUInt32 GetSupportedUserPositionsCount() const 04627 { 04628 return xnGetSupportedUserPositionsCount(GetHandle()); 04629 } 04630 04635 inline XnStatus SetUserPosition(XnUInt32 nIndex, const XnBoundingBox3D& Position) 04636 { 04637 return xnSetUserPosition(GetHandle(), nIndex, &Position); 04638 } 04639 04644 inline XnStatus GetUserPosition(XnUInt32 nIndex, XnBoundingBox3D& Position) const 04645 { 04646 return xnGetUserPosition(GetHandle(), nIndex, &Position); 04647 } 04648 04658 inline XnStatus RegisterToUserPositionChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04659 { 04660 return _RegisterToStateChange(xnRegisterToUserPositionChange, GetHandle(), handler, pCookie, hCallback); 04661 } 04662 04670 inline void UnregisterFromUserPositionChange(XnCallbackHandle hCallback) 04671 { 04672 _UnregisterFromStateChange(xnUnregisterFromUserPositionChange, GetHandle(), hCallback); 04673 } 04674 }; 04675 04720 class DepthGenerator : public MapGenerator 04721 { 04722 public: 04728 inline DepthGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {} 04729 inline DepthGenerator(const NodeWrapper& other) : MapGenerator(other) {} 04730 04738 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 04739 04756 inline void GetMetaData(DepthMetaData& metaData) const 04757 { 04758 xnGetDepthMetaData(GetHandle(), metaData.GetUnderlying()); 04759 } 04760 04765 inline const XnDepthPixel* GetDepthMap() const 04766 { 04767 return xnGetDepthMap(GetHandle()); 04768 } 04769 04779 inline XnDepthPixel GetDeviceMaxDepth() const 04780 { 04781 return xnGetDeviceMaxDepth(GetHandle()); 04782 } 04783 04802 inline XnStatus GetFieldOfView(XnFieldOfView& FOV) const 04803 { 04804 return xnGetDepthFieldOfView(GetHandle(), &FOV); 04805 } 04806 04816 inline XnStatus RegisterToFieldOfViewChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 04817 { 04818 return _RegisterToStateChange(xnRegisterToDepthFieldOfViewChange, GetHandle(), handler, pCookie, hCallback); 04819 } 04820 04828 inline void UnregisterFromFieldOfViewChange(XnCallbackHandle hCallback) 04829 { 04830 _UnregisterFromStateChange(xnUnregisterFromDepthFieldOfViewChange, GetHandle(), hCallback); 04831 } 04832 04842 inline XnStatus ConvertProjectiveToRealWorld(XnUInt32 nCount, const XnPoint3D aProjective[], XnPoint3D aRealWorld[]) const 04843 { 04844 return xnConvertProjectiveToRealWorld(GetHandle(), nCount, aProjective, aRealWorld); 04845 } 04846 04856 inline XnStatus ConvertRealWorldToProjective(XnUInt32 nCount, const XnPoint3D aRealWorld[], XnPoint3D aProjective[]) const 04857 { 04858 return xnConvertRealWorldToProjective(GetHandle(), nCount, aRealWorld, aProjective); 04859 } 04860 04866 inline const UserPositionCapability GetUserPositionCap() const 04867 { 04868 return UserPositionCapability(GetHandle()); 04869 } 04870 04876 inline UserPositionCapability GetUserPositionCap() 04877 { 04878 return UserPositionCapability(GetHandle()); 04879 } 04880 }; 04881 04886 class MockDepthGenerator : public DepthGenerator 04887 { 04888 public: 04894 inline MockDepthGenerator(XnNodeHandle hNode = NULL) : DepthGenerator(hNode) {} 04895 inline MockDepthGenerator(const NodeWrapper& other) : DepthGenerator(other) {} 04896 04903 XnStatus Create(Context& context, const XnChar* strName = NULL); 04904 04912 XnStatus CreateBasedOn(DepthGenerator& other, const XnChar* strName = NULL); 04913 04918 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnDepthPixel* pDepthMap) 04919 { 04920 return xnMockDepthSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pDepthMap); 04921 } 04922 04931 inline XnStatus SetData(const DepthMetaData& depthMD, XnUInt32 nFrameID, XnUInt64 nTimestamp) 04932 { 04933 return SetData(nFrameID, nTimestamp, depthMD.DataSize(), depthMD.Data()); 04934 } 04935 04941 inline XnStatus SetData(const DepthMetaData& depthMD) 04942 { 04943 return SetData(depthMD, depthMD.FrameID(), depthMD.Timestamp()); 04944 } 04945 }; 04946 04965 class ImageGenerator : public MapGenerator 04966 { 04967 public: 04973 inline ImageGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {} 04974 inline ImageGenerator(const NodeWrapper& other) : MapGenerator(other) {} 04975 04981 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 04982 04999 inline void GetMetaData(ImageMetaData& metaData) const 05000 { 05001 xnGetImageMetaData(GetHandle(), metaData.GetUnderlying()); 05002 } 05003 05008 inline const XnRGB24Pixel* GetRGB24ImageMap() const 05009 { 05010 return xnGetRGB24ImageMap(GetHandle()); 05011 } 05012 05017 inline const XnYUV422DoublePixel* GetYUV422ImageMap() const 05018 { 05019 return xnGetYUV422ImageMap(GetHandle()); 05020 } 05021 05026 inline const XnGrayscale8Pixel* GetGrayscale8ImageMap() const 05027 { 05028 return xnGetGrayscale8ImageMap(GetHandle()); 05029 } 05030 05035 inline const XnGrayscale16Pixel* GetGrayscale16ImageMap() const 05036 { 05037 return xnGetGrayscale16ImageMap(GetHandle()); 05038 } 05039 05044 inline const XnUInt8* GetImageMap() const 05045 { 05046 return xnGetImageMap(GetHandle()); 05047 } 05048 05059 inline XnBool IsPixelFormatSupported(XnPixelFormat Format) const 05060 { 05061 return xnIsPixelFormatSupported(GetHandle(), Format); 05062 } 05063 05081 inline XnStatus SetPixelFormat(XnPixelFormat Format) 05082 { 05083 return xnSetPixelFormat(GetHandle(), Format); 05084 } 05085 05096 inline XnPixelFormat GetPixelFormat() const 05097 { 05098 return xnGetPixelFormat(GetHandle()); 05099 } 05100 05110 inline XnStatus RegisterToPixelFormatChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 05111 { 05112 return _RegisterToStateChange(xnRegisterToPixelFormatChange, GetHandle(), handler, pCookie, hCallback); 05113 } 05114 05122 inline void UnregisterFromPixelFormatChange(XnCallbackHandle hCallback) 05123 { 05124 _UnregisterFromStateChange(xnUnregisterFromPixelFormatChange, GetHandle(), hCallback); 05125 } 05126 }; 05127 05132 class MockImageGenerator : public ImageGenerator 05133 { 05134 public: 05140 inline MockImageGenerator(XnNodeHandle hNode = NULL) : ImageGenerator(hNode) {} 05141 inline MockImageGenerator(const NodeWrapper& other) : ImageGenerator(other) {} 05142 05149 XnStatus Create(Context& context, const XnChar* strName = NULL); 05150 05158 XnStatus CreateBasedOn(ImageGenerator& other, const XnChar* strName = NULL); 05159 05164 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pImageMap) 05165 { 05166 return xnMockImageSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pImageMap); 05167 } 05168 05177 inline XnStatus SetData(const ImageMetaData& imageMD, XnUInt32 nFrameID, XnUInt64 nTimestamp) 05178 { 05179 return SetData(nFrameID, nTimestamp, imageMD.DataSize(), imageMD.Data()); 05180 } 05181 05187 inline XnStatus SetData(const ImageMetaData& imageMD) 05188 { 05189 return SetData(imageMD, imageMD.FrameID(), imageMD.Timestamp()); 05190 } 05191 }; 05192 05201 class IRGenerator : public MapGenerator 05202 { 05203 public: 05209 inline IRGenerator(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {} 05210 inline IRGenerator(const NodeWrapper& other) : MapGenerator(other) {} 05211 05218 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 05219 05236 inline void GetMetaData(IRMetaData& metaData) const 05237 { 05238 xnGetIRMetaData(GetHandle(), metaData.GetUnderlying()); 05239 } 05240 05244 inline const XnIRPixel* GetIRMap() const 05245 { 05246 return xnGetIRMap(GetHandle()); 05247 } 05248 }; 05249 05254 class MockIRGenerator : public IRGenerator 05255 { 05256 public: 05262 inline MockIRGenerator(XnNodeHandle hNode = NULL) : IRGenerator(hNode) {} 05263 inline MockIRGenerator(const NodeWrapper& other) : IRGenerator(other) {} 05264 05271 XnStatus Create(Context& context, const XnChar* strName = NULL); 05278 XnStatus CreateBasedOn(IRGenerator& other, const XnChar* strName = NULL); 05279 05284 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnIRPixel* pIRMap) 05285 { 05286 return xnMockIRSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pIRMap); 05287 } 05288 05297 inline XnStatus SetData(const IRMetaData& irMD, XnUInt32 nFrameID, XnUInt64 nTimestamp) 05298 { 05299 return SetData(nFrameID, nTimestamp, irMD.DataSize(), irMD.Data()); 05300 } 05301 05307 inline XnStatus SetData(const IRMetaData& irMD) 05308 { 05309 return SetData(irMD, irMD.FrameID(), irMD.Timestamp()); 05310 } 05311 }; 05312 05380 class GestureGenerator : public Generator 05381 { 05382 public: 05388 inline GestureGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 05389 inline GestureGenerator(const NodeWrapper& other) : Generator(other) {} 05390 05404 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 05405 05419 inline XnStatus AddGesture(const XnChar* strGesture, XnBoundingBox3D* pArea) 05420 { 05421 return xnAddGesture(GetHandle(), strGesture, pArea); 05422 } 05423 05431 inline XnStatus RemoveGesture(const XnChar* strGesture) 05432 { 05433 return xnRemoveGesture(GetHandle(), strGesture); 05434 } 05435 05444 inline XnStatus GetAllActiveGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const 05445 { 05446 return xnGetAllActiveGestures(GetHandle(), astrGestures, nNameLength, &nGestures); 05447 } 05448 05453 inline XnUInt16 GetNumberOfAvailableGestures() const 05454 { 05455 return xnGetNumberOfAvailableGestures(GetHandle()); 05456 } 05457 05466 inline XnStatus EnumerateAllGestures(XnChar** astrGestures, XnUInt32 nNameLength, XnUInt16& nGestures) const 05467 { 05468 return xnEnumerateAllGestures(GetHandle(), astrGestures, nNameLength, &nGestures); 05469 } 05470 05476 inline XnBool IsGestureAvailable(const XnChar* strGesture) const 05477 { 05478 return xnIsGestureAvailable(GetHandle(), strGesture); 05479 } 05480 05485 inline XnBool IsGestureProgressSupported(const XnChar* strGesture) const 05486 { 05487 return xnIsGestureProgressSupported(GetHandle(), strGesture); 05488 } 05489 05511 typedef void (XN_CALLBACK_TYPE* GestureRecognized)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie); 05512 05539 typedef void (XN_CALLBACK_TYPE* GestureProgress)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie); 05540 05552 XnStatus RegisterGestureCallbacks(GestureRecognized RecognizedCB, GestureProgress ProgressCB, void* pCookie, XnCallbackHandle& hCallback) 05553 { 05554 XnStatus nRetVal = XN_STATUS_OK; 05555 05556 GestureCookie* pGestureCookie; 05557 XN_VALIDATE_ALLOC(pGestureCookie, GestureCookie); 05558 pGestureCookie->recognizedHandler = RecognizedCB; 05559 pGestureCookie->progressHandler = ProgressCB; 05560 pGestureCookie->pUserCookie = pCookie; 05561 05562 nRetVal = xnRegisterGestureCallbacks(GetHandle(), GestureRecognizedCallback, GestureProgressCallback, pGestureCookie, &pGestureCookie->hCallback); 05563 if (nRetVal != XN_STATUS_OK) 05564 { 05565 xnOSFree(pGestureCookie); 05566 return (nRetVal); 05567 } 05568 05569 hCallback = pGestureCookie; 05570 05571 return (XN_STATUS_OK); 05572 } 05573 05581 inline void UnregisterGestureCallbacks(XnCallbackHandle hCallback) 05582 { 05583 GestureCookie* pGestureCookie = (GestureCookie*)hCallback; 05584 xnUnregisterGestureCallbacks(GetHandle(), pGestureCookie->hCallback); 05585 xnOSFree(pGestureCookie); 05586 } 05587 05597 inline XnStatus RegisterToGestureChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 05598 { 05599 return _RegisterToStateChange(xnRegisterToGestureChange, GetHandle(), handler, pCookie, hCallback); 05600 } 05601 05609 inline void UnregisterFromGestureChange(XnCallbackHandle hCallback) 05610 { 05611 _UnregisterFromStateChange(xnUnregisterFromGestureChange, GetHandle(), hCallback); 05612 } 05613 05641 typedef void (XN_CALLBACK_TYPE* GestureIntermediateStageCompleted)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie); 05642 05652 XnStatus RegisterToGestureIntermediateStageCompleted(GestureIntermediateStageCompleted handler, void* pCookie, XnCallbackHandle& hCallback) 05653 { 05654 XnStatus nRetVal = XN_STATUS_OK; 05655 05656 GestureIntermediateStageCompletedCookie* pGestureCookie; 05657 XN_VALIDATE_ALLOC(pGestureCookie, GestureIntermediateStageCompletedCookie); 05658 pGestureCookie->handler = handler; 05659 pGestureCookie->pUserCookie = pCookie; 05660 05661 nRetVal = xnRegisterToGestureIntermediateStageCompleted(GetHandle(), GestureIntermediateStageCompletedCallback, pGestureCookie, &pGestureCookie->hCallback); 05662 if (nRetVal != XN_STATUS_OK) 05663 { 05664 xnOSFree(pGestureCookie); 05665 return (nRetVal); 05666 } 05667 05668 hCallback = pGestureCookie; 05669 05670 return (XN_STATUS_OK); 05671 } 05672 05680 inline void UnregisterFromGestureIntermediateStageCompleted(XnCallbackHandle hCallback) 05681 { 05682 GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)hCallback; 05683 xnUnregisterFromGestureIntermediateStageCompleted(GetHandle(), pGestureCookie->hCallback); 05684 xnOSFree(pGestureCookie); 05685 } 05686 05705 typedef void (XN_CALLBACK_TYPE* GestureReadyForNextIntermediateStage)(GestureGenerator& generator, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie); 05706 05716 XnStatus RegisterToGestureReadyForNextIntermediateStage(GestureReadyForNextIntermediateStage handler, void* pCookie, XnCallbackHandle& hCallback) 05717 { 05718 XnStatus nRetVal = XN_STATUS_OK; 05719 05720 GestureReadyForNextIntermediateStageCookie* pGestureCookie; 05721 XN_VALIDATE_ALLOC(pGestureCookie, GestureReadyForNextIntermediateStageCookie); 05722 pGestureCookie->handler = handler; 05723 pGestureCookie->pUserCookie = pCookie; 05724 05725 nRetVal = xnRegisterToGestureReadyForNextIntermediateStage(GetHandle(), GestureReadyForNextIntermediateStageCallback, pGestureCookie, &pGestureCookie->hCallback); 05726 if (nRetVal != XN_STATUS_OK) 05727 { 05728 xnOSFree(pGestureCookie); 05729 return (nRetVal); 05730 } 05731 05732 hCallback = pGestureCookie; 05733 05734 return (XN_STATUS_OK); 05735 } 05736 05744 inline void UnregisterFromGestureReadyForNextIntermediateStageCallbacks(XnCallbackHandle hCallback) 05745 { 05746 GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)hCallback; 05747 xnUnregisterFromGestureReadyForNextIntermediateStage(GetHandle(), pGestureCookie->hCallback); 05748 xnOSFree(pGestureCookie); 05749 } 05750 05752 inline XnStatus XN_API_DEPRECATED("Use GetAllActiveGestures() instead") GetActiveGestures(XnChar*& astrGestures, XnUInt16& nGestures) const 05753 { 05754 return xnGetActiveGestures(GetHandle(), &astrGestures, &nGestures); 05755 } 05756 inline XnStatus XN_API_DEPRECATED("Use EnumerateAllGestures() instead") EnumerateGestures(XnChar*& astrGestures, XnUInt16& nGestures) const 05757 { 05758 return xnEnumerateGestures(GetHandle(), &astrGestures, &nGestures); 05759 } 05762 private: 05763 typedef struct GestureCookie 05764 { 05765 GestureRecognized recognizedHandler; 05766 GestureProgress progressHandler; 05767 void* pUserCookie; 05768 XnCallbackHandle hCallback; 05769 } GestureCookie; 05770 05771 static void XN_CALLBACK_TYPE GestureRecognizedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pIDPosition, const XnPoint3D* pEndPosition, void* pCookie) 05772 { 05773 GestureCookie* pGestureCookie = (GestureCookie*)pCookie; 05774 GestureGenerator gen(hNode); 05775 if (pGestureCookie->recognizedHandler != NULL) 05776 { 05777 pGestureCookie->recognizedHandler(gen, strGesture, pIDPosition, pEndPosition, pGestureCookie->pUserCookie); 05778 } 05779 } 05780 05781 static void XN_CALLBACK_TYPE GestureProgressCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, XnFloat fProgress, void* pCookie) 05782 { 05783 GestureCookie* pGestureCookie = (GestureCookie*)pCookie; 05784 GestureGenerator gen(hNode); 05785 if (pGestureCookie->progressHandler != NULL) 05786 { 05787 pGestureCookie->progressHandler(gen, strGesture, pPosition, fProgress, pGestureCookie->pUserCookie); 05788 } 05789 } 05790 05791 typedef struct GestureIntermediateStageCompletedCookie 05792 { 05793 GestureIntermediateStageCompleted handler; 05794 void* pUserCookie; 05795 XnCallbackHandle hCallback; 05796 } GestureIntermediateStageCompletedCookie; 05797 05798 static void XN_CALLBACK_TYPE GestureIntermediateStageCompletedCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie) 05799 { 05800 GestureIntermediateStageCompletedCookie* pGestureCookie = (GestureIntermediateStageCompletedCookie*)pCookie; 05801 GestureGenerator gen(hNode); 05802 if (pGestureCookie->handler != NULL) 05803 { 05804 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie); 05805 } 05806 } 05807 05808 typedef struct GestureReadyForNextIntermediateStageCookie 05809 { 05810 GestureReadyForNextIntermediateStage handler; 05811 void* pUserCookie; 05812 XnCallbackHandle hCallback; 05813 } GestureReadyForNextIntermediateStageCookie; 05814 05815 static void XN_CALLBACK_TYPE GestureReadyForNextIntermediateStageCallback(XnNodeHandle hNode, const XnChar* strGesture, const XnPoint3D* pPosition, void* pCookie) 05816 { 05817 GestureReadyForNextIntermediateStageCookie* pGestureCookie = (GestureReadyForNextIntermediateStageCookie*)pCookie; 05818 GestureGenerator gen(hNode); 05819 if (pGestureCookie->handler != NULL) 05820 { 05821 pGestureCookie->handler(gen, strGesture, pPosition, pGestureCookie->pUserCookie); 05822 } 05823 } 05824 }; 05825 05844 class SceneAnalyzer : public MapGenerator 05845 { 05846 public: 05852 inline SceneAnalyzer(XnNodeHandle hNode = NULL) : MapGenerator(hNode) {} 05853 inline SceneAnalyzer(const NodeWrapper& other) : MapGenerator(other) {} 05854 05862 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 05863 05864 05884 inline void GetMetaData(SceneMetaData& metaData) const 05885 { 05886 xnGetSceneMetaData(GetHandle(), metaData.GetUnderlying()); 05887 } 05888 05893 inline const XnLabel* GetLabelMap() const 05894 { 05895 return xnGetLabelMap(GetHandle()); 05896 } 05897 05903 inline XnStatus GetFloor(XnPlane3D& Plane) const 05904 { 05905 return xnGetFloor(GetHandle(), &Plane); 05906 } 05907 }; 05908 05916 class HandTouchingFOVEdgeCapability : public Capability 05917 { 05918 public: 05924 inline HandTouchingFOVEdgeCapability(XnNodeHandle hNode) : Capability(hNode) {} 05925 HandTouchingFOVEdgeCapability(const NodeWrapper& node) : Capability(node) {} 05926 05937 typedef void (XN_CALLBACK_TYPE* HandTouchingFOVEdge)(HandTouchingFOVEdgeCapability& touchingfov, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie); 05938 05948 inline XnStatus RegisterToHandTouchingFOVEdge(HandTouchingFOVEdge handler, void* pCookie, XnCallbackHandle& hCallback) 05949 { 05950 XnStatus nRetVal = XN_STATUS_OK; 05951 05952 HandTouchingFOVEdgeCookie* pHandCookie; 05953 XN_VALIDATE_ALLOC(pHandCookie, HandTouchingFOVEdgeCookie); 05954 pHandCookie->handler = handler; 05955 pHandCookie->pUserCookie = pCookie; 05956 05957 nRetVal = xnRegisterToHandTouchingFOVEdge(GetHandle(), HandTouchingFOVEdgeCB, pHandCookie, &pHandCookie->hCallback); 05958 if (nRetVal != XN_STATUS_OK) 05959 { 05960 xnOSFree(pHandCookie); 05961 return (nRetVal); 05962 } 05963 05964 hCallback = pHandCookie; 05965 05966 return (XN_STATUS_OK); 05967 } 05968 05976 inline void UnregisterFromHandTouchingFOVEdge(XnCallbackHandle hCallback) 05977 { 05978 HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)hCallback; 05979 xnUnregisterFromHandTouchingFOVEdge(GetHandle(), pHandCookie->hCallback); 05980 xnOSFree(pHandCookie); 05981 } 05982 private: 05983 typedef struct HandTouchingFOVEdgeCookie 05984 { 05985 HandTouchingFOVEdge handler; 05986 void* pUserCookie; 05987 XnCallbackHandle hCallback; 05988 } HandTouchingFOVEdgeCookie; 05989 05990 static void XN_CALLBACK_TYPE HandTouchingFOVEdgeCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, XnDirection eDir, void* pCookie) 05991 { 05992 HandTouchingFOVEdgeCookie* pHandCookie = (HandTouchingFOVEdgeCookie*)pCookie; 05993 HandTouchingFOVEdgeCapability cap(hNode); 05994 if (pHandCookie->handler != NULL) 05995 { 05996 pHandCookie->handler(cap, user, pPosition, fTime, eDir, pHandCookie->pUserCookie); 05997 } 05998 } 05999 06000 }; 06001 06089 class HandsGenerator : public Generator 06090 { 06091 public: 06097 inline HandsGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 06098 inline HandsGenerator(const NodeWrapper& other) : Generator(other) {} 06099 06107 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 06108 06124 typedef void (XN_CALLBACK_TYPE* HandCreate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie); 06125 06142 typedef void (XN_CALLBACK_TYPE* HandUpdate)(HandsGenerator& generator, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie); 06143 06157 typedef void (XN_CALLBACK_TYPE* HandDestroy)(HandsGenerator& generator, XnUserID user, XnFloat fTime, void* pCookie); 06158 06171 inline XnStatus RegisterHandCallbacks(HandCreate CreateCB, HandUpdate UpdateCB, HandDestroy DestroyCB, void* pCookie, XnCallbackHandle& hCallback) 06172 { 06173 XnStatus nRetVal = XN_STATUS_OK; 06174 06175 HandCookie* pHandCookie; 06176 XN_VALIDATE_ALLOC(pHandCookie, HandCookie); 06177 pHandCookie->createHandler = CreateCB; 06178 pHandCookie->updateHandler = UpdateCB; 06179 pHandCookie->destroyHandler = DestroyCB; 06180 pHandCookie->pUserCookie = pCookie; 06181 06182 nRetVal = xnRegisterHandCallbacks(GetHandle(), HandCreateCB, HandUpdateCB, HandDestroyCB, pHandCookie, &pHandCookie->hCallback); 06183 if (nRetVal != XN_STATUS_OK) 06184 { 06185 xnOSFree(pHandCookie); 06186 return (nRetVal); 06187 } 06188 06189 hCallback = pHandCookie; 06190 06191 return (XN_STATUS_OK); 06192 } 06193 06201 inline void UnregisterHandCallbacks(XnCallbackHandle hCallback) 06202 { 06203 HandCookie* pHandCookie = (HandCookie*)hCallback; 06204 xnUnregisterHandCallbacks(GetHandle(), pHandCookie->hCallback); 06205 xnOSFree(pHandCookie); 06206 } 06207 06221 inline XnStatus StopTracking(XnUserID user) 06222 { 06223 return xnStopTracking(GetHandle(), user); 06224 } 06225 06234 inline XnStatus StopTrackingAll() 06235 { 06236 return xnStopTrackingAll(GetHandle()); 06237 } 06238 06255 inline XnStatus StartTracking(const XnPoint3D& ptPosition) 06256 { 06257 return xnStartTracking(GetHandle(), &ptPosition); 06258 } 06259 06276 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor) 06277 { 06278 return xnSetTrackingSmoothing(GetHandle(), fSmoothingFactor); 06279 } 06280 06288 inline const HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() const 06289 { 06290 return HandTouchingFOVEdgeCapability(GetHandle()); 06291 } 06292 06300 inline HandTouchingFOVEdgeCapability GetHandTouchingFOVEdgeCap() 06301 { 06302 return HandTouchingFOVEdgeCapability(GetHandle()); 06303 } 06304 06305 private: 06306 typedef struct HandCookie 06307 { 06308 HandCreate createHandler; 06309 HandUpdate updateHandler; 06310 HandDestroy destroyHandler; 06311 void* pUserCookie; 06312 XnCallbackHandle hCallback; 06313 } HandCookie; 06314 06315 static void XN_CALLBACK_TYPE HandCreateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie) 06316 { 06317 HandCookie* pHandCookie = (HandCookie*)pCookie; 06318 HandsGenerator gen(hNode); 06319 if (pHandCookie->createHandler != NULL) 06320 { 06321 pHandCookie->createHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie); 06322 } 06323 } 06324 static void XN_CALLBACK_TYPE HandUpdateCB(XnNodeHandle hNode, XnUserID user, const XnPoint3D* pPosition, XnFloat fTime, void* pCookie) 06325 { 06326 HandCookie* pHandCookie = (HandCookie*)pCookie; 06327 HandsGenerator gen(hNode); 06328 if (pHandCookie->updateHandler != NULL) 06329 { 06330 pHandCookie->updateHandler(gen, user, pPosition, fTime, pHandCookie->pUserCookie); 06331 } 06332 } 06333 static void XN_CALLBACK_TYPE HandDestroyCB(XnNodeHandle hNode, XnUserID user, XnFloat fTime, void* pCookie) 06334 { 06335 HandCookie* pHandCookie = (HandCookie*)pCookie; 06336 HandsGenerator gen(hNode); 06337 if (pHandCookie->destroyHandler != NULL) 06338 { 06339 pHandCookie->destroyHandler(gen, user, fTime, pHandCookie->pUserCookie); 06340 } 06341 } 06342 }; 06343 06400 class SkeletonCapability : public Capability 06401 { 06402 public: 06408 inline SkeletonCapability(XnNodeHandle hNode) : Capability(hNode) {} 06409 SkeletonCapability(const NodeWrapper& node) : Capability(node) {} 06410 06416 inline XnBool IsJointAvailable(XnSkeletonJoint eJoint) const 06417 { 06418 return xnIsJointAvailable(GetHandle(), eJoint); 06419 } 06420 06426 inline XnBool IsProfileAvailable(XnSkeletonProfile eProfile) const 06427 { 06428 return xnIsProfileAvailable(GetHandle(), eProfile); 06429 } 06430 06461 inline XnStatus SetSkeletonProfile(XnSkeletonProfile eProfile) 06462 { 06463 return xnSetSkeletonProfile(GetHandle(), eProfile); 06464 } 06465 06489 inline XnStatus SetJointActive(XnSkeletonJoint eJoint, XnBool bState) 06490 { 06491 return xnSetJointActive(GetHandle(), eJoint, bState); 06492 } 06493 06499 inline XnBool IsJointActive(XnSkeletonJoint eJoint) const 06500 { 06501 return xnIsJointActive(GetHandle(), eJoint); 06502 } 06503 06513 inline XnStatus RegisterToJointConfigurationChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 06514 { 06515 return _RegisterToStateChange(xnRegisterToJointConfigurationChange, GetHandle(), handler, pCookie, hCallback); 06516 } 06517 06525 inline void UnregisterFromJointConfigurationChange(XnCallbackHandle hCallback) 06526 { 06527 _UnregisterFromStateChange(xnUnregisterFromJointConfigurationChange, GetHandle(), hCallback); 06528 } 06529 06534 inline XnStatus EnumerateActiveJoints(XnSkeletonJoint* pJoints, XnUInt16& nJoints) const 06535 { 06536 return xnEnumerateActiveJoints(GetHandle(), pJoints, &nJoints); 06537 } 06538 06547 inline XnStatus GetSkeletonJoint(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointTransformation& Joint) const 06548 { 06549 return xnGetSkeletonJoint(GetHandle(), user, eJoint, &Joint); 06550 } 06551 06573 inline XnStatus GetSkeletonJointPosition(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointPosition& Joint) const 06574 { 06575 return xnGetSkeletonJointPosition(GetHandle(), user, eJoint, &Joint); 06576 } 06577 06585 inline XnStatus GetSkeletonJointOrientation(XnUserID user, XnSkeletonJoint eJoint, XnSkeletonJointOrientation& Joint) const 06586 { 06587 return xnGetSkeletonJointOrientation(GetHandle(), user, eJoint, &Joint); 06588 } 06589 06600 inline XnBool IsTracking(XnUserID user) const 06601 { 06602 return xnIsSkeletonTracking(GetHandle(), user); 06603 } 06604 06615 inline XnBool IsCalibrated(XnUserID user) const 06616 { 06617 06618 return xnIsSkeletonCalibrated(GetHandle(), user); 06619 } 06620 06631 inline XnBool IsCalibrating(XnUserID user) const 06632 { 06633 return xnIsSkeletonCalibrating(GetHandle(), user); 06634 } 06635 06660 inline XnStatus RequestCalibration(XnUserID user, XnBool bForce) 06661 { 06662 return xnRequestSkeletonCalibration(GetHandle(), user, bForce); 06663 } 06664 06674 inline XnStatus AbortCalibration(XnUserID user) 06675 { 06676 return xnAbortSkeletonCalibration(GetHandle(), user); 06677 } 06678 06697 inline XnStatus SaveCalibrationDataToFile(XnUserID user, const XnChar* strFileName) 06698 { 06699 return xnSaveSkeletonCalibrationDataToFile(GetHandle(), user, strFileName); 06700 } 06701 06708 inline XnStatus LoadCalibrationDataFromFile(XnUserID user, const XnChar* strFileName) 06709 { 06710 return xnLoadSkeletonCalibrationDataFromFile(GetHandle(), user, strFileName); 06711 } 06712 06724 inline XnStatus SaveCalibrationData(XnUserID user, XnUInt32 nSlot) 06725 { 06726 return xnSaveSkeletonCalibrationData(GetHandle(), user, nSlot); 06727 } 06728 06735 inline XnStatus LoadCalibrationData(XnUserID user, XnUInt32 nSlot) 06736 { 06737 return xnLoadSkeletonCalibrationData(GetHandle(), user, nSlot); 06738 } 06739 06745 inline XnStatus ClearCalibrationData(XnUInt32 nSlot) 06746 { 06747 return xnClearSkeletonCalibrationData(GetHandle(), nSlot); 06748 } 06749 06755 inline XnBool IsCalibrationData(XnUInt32 nSlot) const 06756 { 06757 return xnIsSkeletonCalibrationData(GetHandle(), nSlot); 06758 } 06759 06774 inline XnStatus StartTracking(XnUserID user) 06775 { 06776 return xnStartSkeletonTracking(GetHandle(), user); 06777 } 06778 06783 inline XnStatus StopTracking(XnUserID user) 06784 { 06785 return xnStopSkeletonTracking(GetHandle(), user); 06786 } 06787 06796 inline XnStatus Reset(XnUserID user) 06797 { 06798 return xnResetSkeleton(GetHandle(), user); 06799 } 06800 06809 inline XnBool NeedPoseForCalibration() const 06810 { 06811 return xnNeedPoseForSkeletonCalibration(GetHandle()); 06812 } 06813 06826 inline XnStatus GetCalibrationPose(XnChar* strPose) const 06827 { 06828 return xnGetSkeletonCalibrationPose(GetHandle(), strPose); 06829 } 06830 06843 inline XnStatus SetSmoothing(XnFloat fSmoothingFactor) 06844 { 06845 return xnSetSkeletonSmoothing(GetHandle(), fSmoothingFactor); 06846 } 06847 06869 typedef void (XN_CALLBACK_TYPE* CalibrationStart)(SkeletonCapability& skeleton, XnUserID user, void* pCookie); 06870 06888 typedef void (XN_CALLBACK_TYPE* CalibrationEnd)(SkeletonCapability& skeleton, XnUserID user, XnBool bSuccess, void* pCookie); 06889 06901 inline XnStatus RegisterToCalibrationStart(CalibrationStart handler, void* pCookie, XnCallbackHandle& hCallback) 06902 { 06903 XnStatus nRetVal = XN_STATUS_OK; 06904 CalibrationStartCookie* pCalibrationCookie; 06905 XN_VALIDATE_ALLOC(pCalibrationCookie, CalibrationStartCookie); 06906 pCalibrationCookie->handler = handler; 06907 pCalibrationCookie->pUserCookie = pCookie; 06908 nRetVal = xnRegisterToCalibrationStart(GetHandle(), CalibrationStartCallback, pCalibrationCookie, &pCalibrationCookie->hCallback); 06909 if (nRetVal != XN_STATUS_OK) 06910 { 06911 xnOSFree(pCalibrationCookie); 06912 return nRetVal; 06913 } 06914 hCallback = pCalibrationCookie; 06915 return XN_STATUS_OK; 06916 } 06917 06928 inline XnStatus UnregisterFromCalibrationStart(XnCallbackHandle hCallback) 06929 { 06930 CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)hCallback; 06931 xnUnregisterFromCalibrationStart(GetHandle(), pCalibrationCookie->hCallback); 06932 xnOSFree(pCalibrationCookie); 06933 return XN_STATUS_OK; 06934 } 06935 06957 typedef void (XN_CALLBACK_TYPE* CalibrationInProgress)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie); 06958 06968 inline XnStatus RegisterToCalibrationInProgress(CalibrationInProgress handler, void* pCookie, XnCallbackHandle& hCallback) 06969 { 06970 XnStatus nRetVal = XN_STATUS_OK; 06971 06972 CalibrationInProgressCookie* pSkeletonCookie; 06973 XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationInProgressCookie); 06974 pSkeletonCookie->handler = handler; 06975 pSkeletonCookie->pUserCookie = pCookie; 06976 06977 nRetVal = xnRegisterToCalibrationInProgress(GetHandle(), CalibrationInProgressCallback, pSkeletonCookie, &pSkeletonCookie->hCallback); 06978 if (nRetVal != XN_STATUS_OK) 06979 { 06980 xnOSFree(pSkeletonCookie); 06981 return (nRetVal); 06982 } 06983 06984 hCallback = pSkeletonCookie; 06985 06986 return (XN_STATUS_OK); 06987 } 06988 06996 inline void UnregisterFromCalibrationInProgress(XnCallbackHandle hCallback) 06997 { 06998 CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)hCallback; 06999 xnUnregisterFromCalibrationInProgress(GetHandle(), pSkeletonCookie->hCallback); 07000 xnOSFree(pSkeletonCookie); 07001 } 07002 07020 typedef void (XN_CALLBACK_TYPE* CalibrationComplete)(SkeletonCapability& skeleton, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie); 07021 07031 inline XnStatus RegisterToCalibrationComplete(CalibrationComplete handler, void* pCookie, XnCallbackHandle& hCallback) 07032 { 07033 XnStatus nRetVal = XN_STATUS_OK; 07034 07035 CalibrationCompleteCookie* pSkeletonCookie; 07036 XN_VALIDATE_ALLOC(pSkeletonCookie, CalibrationCompleteCookie); 07037 pSkeletonCookie->handler = handler; 07038 pSkeletonCookie->pUserCookie = pCookie; 07039 07040 nRetVal = xnRegisterToCalibrationComplete(GetHandle(), CalibrationCompleteCallback, pSkeletonCookie, &pSkeletonCookie->hCallback); 07041 if (nRetVal != XN_STATUS_OK) 07042 { 07043 xnOSFree(pSkeletonCookie); 07044 return (nRetVal); 07045 } 07046 07047 hCallback = pSkeletonCookie; 07048 07049 return (XN_STATUS_OK); 07050 } 07051 07059 inline void UnregisterFromCalibrationComplete(XnCallbackHandle hCallback) 07060 { 07061 CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)hCallback; 07062 xnUnregisterFromCalibrationComplete(GetHandle(), pSkeletonCookie->hCallback); 07063 xnOSFree(pSkeletonCookie); 07064 } 07065 07067 XN_API_DEPRECATED("Use the overload with one argument - the bState parameter is useless") 07068 inline XnBool IsJointActive(XnSkeletonJoint eJoint, XnBool /*bState*/) const 07069 { 07070 return xnIsJointActive(GetHandle(), eJoint); 07071 } 07072 07073 inline XnStatus XN_API_DEPRECATED("Please use RegisterToCalibrationStart/Complete") RegisterCalibrationCallbacks(CalibrationStart CalibrationStartCB, CalibrationEnd CalibrationEndCB, void* pCookie, XnCallbackHandle& hCallback) 07074 { 07075 XnStatus nRetVal = XN_STATUS_OK; 07076 07077 SkeletonCookie* pSkeletonCookie; 07078 XN_VALIDATE_ALLOC(pSkeletonCookie, SkeletonCookie); 07079 pSkeletonCookie->startHandler = CalibrationStartCB; 07080 pSkeletonCookie->endHandler = CalibrationEndCB; 07081 pSkeletonCookie->pUserCookie = pCookie; 07082 07083 #pragma warning (push) 07084 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 07085 nRetVal = xnRegisterCalibrationCallbacks(GetHandle(), CalibrationStartBundleCallback, CalibrationEndBundleCallback, pSkeletonCookie, &pSkeletonCookie->hCallback); 07086 #pragma warning (pop) 07087 if (nRetVal != XN_STATUS_OK) 07088 { 07089 xnOSFree(pSkeletonCookie); 07090 return (nRetVal); 07091 } 07092 07093 hCallback = pSkeletonCookie; 07094 07095 return (XN_STATUS_OK); 07096 } 07097 07098 inline void XN_API_DEPRECATED("Please use UnregisterFromCalibrationStart/Complete") UnregisterCalibrationCallbacks(XnCallbackHandle hCallback) 07099 { 07100 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)hCallback; 07101 #pragma warning (push) 07102 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 07103 xnUnregisterCalibrationCallbacks(GetHandle(), pSkeletonCookie->hCallback); 07104 #pragma warning (pop) 07105 xnOSFree(pSkeletonCookie); 07106 } 07109 private: 07110 typedef struct SkeletonCookie 07111 { 07112 CalibrationStart startHandler; 07113 CalibrationEnd endHandler; 07114 void* pUserCookie; 07115 XnCallbackHandle hCallback; 07116 } SkeletonCookie; 07117 07118 static void XN_CALLBACK_TYPE CalibrationStartBundleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie) 07119 { 07120 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie; 07121 SkeletonCapability cap(hNode); 07122 if (pSkeletonCookie->startHandler != NULL) 07123 { 07124 pSkeletonCookie->startHandler(cap, user, pSkeletonCookie->pUserCookie); 07125 } 07126 } 07127 07128 static void XN_CALLBACK_TYPE CalibrationEndBundleCallback(XnNodeHandle hNode, XnUserID user, XnBool bSuccess, void* pCookie) 07129 { 07130 SkeletonCookie* pSkeletonCookie = (SkeletonCookie*)pCookie; 07131 SkeletonCapability cap(hNode); 07132 if (pSkeletonCookie->endHandler != NULL) 07133 { 07134 pSkeletonCookie->endHandler(cap, user, bSuccess, pSkeletonCookie->pUserCookie); 07135 } 07136 } 07137 07138 typedef struct CalibrationStartCookie 07139 { 07140 CalibrationStart handler; 07141 void* pUserCookie; 07142 XnCallbackHandle hCallback; 07143 } CalibrationStartCookie; 07144 07145 static void XN_CALLBACK_TYPE CalibrationStartCallback(XnNodeHandle hNode, XnUserID user, void* pCookie) 07146 { 07147 CalibrationStartCookie* pCalibrationCookie = (CalibrationStartCookie*)pCookie; 07148 SkeletonCapability cap(hNode); 07149 if (pCalibrationCookie->handler != NULL) 07150 { 07151 pCalibrationCookie->handler(cap, user, pCalibrationCookie->pUserCookie); 07152 } 07153 } 07154 07155 typedef struct CalibrationInProgressCookie 07156 { 07157 CalibrationInProgress handler; 07158 void* pUserCookie; 07159 XnCallbackHandle hCallback; 07160 } CalibrationInProgressCookie; 07161 07162 static void XN_CALLBACK_TYPE CalibrationInProgressCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie) 07163 { 07164 CalibrationInProgressCookie* pSkeletonCookie = (CalibrationInProgressCookie*)pCookie; 07165 SkeletonCapability cap(hNode); 07166 if (pSkeletonCookie->handler != NULL) 07167 { 07168 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie); 07169 } 07170 } 07171 07172 typedef struct CalibrationCompleteCookie 07173 { 07174 CalibrationComplete handler; 07175 void* pUserCookie; 07176 XnCallbackHandle hCallback; 07177 } CalibrationCompleteCookie; 07178 07179 static void XN_CALLBACK_TYPE CalibrationCompleteCallback(XnNodeHandle hNode, XnUserID user, XnCalibrationStatus calibrationError, void* pCookie) 07180 { 07181 CalibrationCompleteCookie* pSkeletonCookie = (CalibrationCompleteCookie*)pCookie; 07182 SkeletonCapability cap(hNode); 07183 if (pSkeletonCookie->handler != NULL) 07184 { 07185 pSkeletonCookie->handler(cap, user, calibrationError, pSkeletonCookie->pUserCookie); 07186 } 07187 } 07188 }; 07189 07211 class PoseDetectionCapability : public Capability 07212 { 07213 public: 07219 inline PoseDetectionCapability(XnNodeHandle hNode) : Capability(hNode) {} 07220 PoseDetectionCapability(const NodeWrapper& node) : Capability(node) {} 07221 07235 typedef void (XN_CALLBACK_TYPE* PoseDetection)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, void* pCookie); 07236 07246 inline XnUInt32 GetNumberOfPoses() const 07247 { 07248 return xnGetNumberOfPoses(GetHandle()); 07249 } 07250 07263 inline XnStatus GetAllAvailablePoses(XnChar** pstrPoses, XnUInt32 nNameLength, XnUInt32& nPoses) const 07264 { 07265 return xnGetAllAvailablePoses(GetHandle(), pstrPoses, nNameLength, &nPoses); 07266 } 07267 07268 inline XnBool IsPoseSupported(const XnChar* strPose) 07269 { 07270 return xnIsPoseSupported(GetHandle(), strPose); 07271 } 07272 07273 inline XnStatus GetPoseStatus(XnUserID userID, const XnChar* poseName, XnUInt64& poseTime, XnPoseDetectionStatus& eStatus, XnPoseDetectionState& eState) 07274 { 07275 return xnGetPoseStatus(GetHandle(), userID, poseName, &poseTime, &eStatus, &eState); 07276 } 07277 07293 inline XnStatus StartPoseDetection(const XnChar* strPose, XnUserID user) 07294 { 07295 return xnStartPoseDetection(GetHandle(), strPose, user); 07296 } 07297 07309 inline XnStatus StopPoseDetection(XnUserID user) 07310 { 07311 return xnStopPoseDetection(GetHandle(), user); 07312 } 07313 07317 inline XnStatus StopSinglePoseDetection(XnUserID user, const XnChar* strPose) 07318 { 07319 return xnStopSinglePoseDetection(GetHandle(), user, strPose); 07320 } 07321 07331 inline XnStatus RegisterToPoseDetected(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback) 07332 { 07333 XnStatus nRetVal = XN_STATUS_OK; 07334 PoseDetectionCookie* pPoseCookie; 07335 XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie); 07336 pPoseCookie->handler = handler; 07337 pPoseCookie->pPoseCookie = pCookie; 07338 07339 nRetVal = xnRegisterToPoseDetected(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback); 07340 if (nRetVal != XN_STATUS_OK) 07341 { 07342 xnOSFree(pPoseCookie); 07343 return nRetVal; 07344 } 07345 hCallback = pPoseCookie; 07346 return XN_STATUS_OK; 07347 } 07348 07358 inline XnStatus RegisterToOutOfPose(PoseDetection handler, void* pCookie, XnCallbackHandle& hCallback) 07359 { 07360 XnStatus nRetVal = XN_STATUS_OK; 07361 PoseDetectionCookie* pPoseCookie; 07362 XN_VALIDATE_ALLOC(pPoseCookie, PoseDetectionCookie); 07363 pPoseCookie->handler = handler; 07364 pPoseCookie->pPoseCookie = pCookie; 07365 07366 nRetVal = xnRegisterToOutOfPose(GetHandle(), PoseDetectionCallback, pPoseCookie, &pPoseCookie->hCallback); 07367 if (nRetVal != XN_STATUS_OK) 07368 { 07369 xnOSFree(pPoseCookie); 07370 return nRetVal; 07371 } 07372 hCallback = pPoseCookie; 07373 return XN_STATUS_OK; 07374 } 07382 inline void UnregisterFromPoseDetected(XnCallbackHandle hCallback) 07383 { 07384 PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback; 07385 xnUnregisterFromPoseDetected(GetHandle(), pPoseCookie->hCallback); 07386 xnOSFree(pPoseCookie); 07387 } 07395 inline void UnregisterFromOutOfPose(XnCallbackHandle hCallback) 07396 { 07397 PoseDetectionCookie* pPoseCookie = (PoseDetectionCookie*)hCallback; 07398 xnUnregisterFromOutOfPose(GetHandle(), pPoseCookie->hCallback); 07399 xnOSFree(pPoseCookie); 07400 } 07401 07424 typedef void (XN_CALLBACK_TYPE* PoseInProgress)(PoseDetectionCapability& pose, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseError, void* pCookie); 07425 07442 inline XnStatus RegisterToPoseInProgress(PoseInProgress handler, void* pCookie, XnCallbackHandle& hCallback) 07443 { 07444 XnStatus nRetVal = XN_STATUS_OK; 07445 07446 PoseInProgressCookie* pPoseCookie; 07447 XN_VALIDATE_ALLOC(pPoseCookie, PoseInProgressCookie); 07448 pPoseCookie->handler = handler; 07449 pPoseCookie->pPoseCookie = pCookie; 07450 07451 nRetVal = xnRegisterToPoseDetectionInProgress(GetHandle(), PoseDetectionInProgressCallback, pPoseCookie, &pPoseCookie->hCallback); 07452 if (nRetVal != XN_STATUS_OK) 07453 { 07454 xnOSFree(pPoseCookie); 07455 return (nRetVal); 07456 } 07457 07458 hCallback = pPoseCookie; 07459 07460 return (XN_STATUS_OK); 07461 } 07462 07470 inline void UnregisterFromPoseInProgress(XnCallbackHandle hCallback) 07471 { 07472 PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)hCallback; 07473 xnUnregisterFromPoseDetectionInProgress(GetHandle(), pPoseCookie->hCallback); 07474 xnOSFree(pPoseCookie); 07475 } 07476 07478 inline XnStatus XN_API_DEPRECATED("Use GetAllAvailablePoses() instead") GetAvailablePoses(XnChar** pstrPoses, XnUInt32& nPoses) const 07479 { 07480 return xnGetAvailablePoses(GetHandle(), pstrPoses, &nPoses); 07481 } 07482 07483 inline XnStatus XN_API_DEPRECATED("Please use RegisterToPoseDetected/RegisterToOutOfPose instead") RegisterToPoseCallbacks(PoseDetection PoseStartCB, PoseDetection PoseEndCB, void* pCookie, XnCallbackHandle& hCallback) 07484 { 07485 XnStatus nRetVal = XN_STATUS_OK; 07486 07487 PoseCookie* pPoseCookie; 07488 XN_VALIDATE_ALLOC(pPoseCookie, PoseCookie); 07489 pPoseCookie->startHandler = PoseStartCB; 07490 pPoseCookie->endHandler = PoseEndCB; 07491 pPoseCookie->pPoseCookie = pCookie; 07492 07493 #pragma warning (push) 07494 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 07495 nRetVal = xnRegisterToPoseCallbacks(GetHandle(), PoseDetectionStartBundleCallback, PoseDetectionStartEndBundleCallback, pPoseCookie, &pPoseCookie->hCallback); 07496 #pragma warning (pop) 07497 if (nRetVal != XN_STATUS_OK) 07498 { 07499 xnOSFree(pPoseCookie); 07500 return (nRetVal); 07501 } 07502 07503 hCallback = pPoseCookie; 07504 07505 return (XN_STATUS_OK); 07506 } 07507 07508 inline void XN_API_DEPRECATED("Please use UnregisterFromPoseDetected/UnregisterFromOutOfPose instead") UnregisterFromPoseCallbacks(XnCallbackHandle hCallback) 07509 { 07510 PoseCookie* pPoseCookie = (PoseCookie*)hCallback; 07511 #pragma warning (push) 07512 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 07513 xnUnregisterFromPoseCallbacks(GetHandle(), pPoseCookie->hCallback); 07514 #pragma warning (pop) 07515 xnOSFree(pPoseCookie); 07516 } 07519 private: 07520 typedef struct PoseCookie 07521 { 07522 PoseDetection startHandler; 07523 PoseDetection endHandler; 07524 void* pPoseCookie; 07525 XnCallbackHandle hCallback; 07526 } PoseCookie; 07527 07528 static void XN_CALLBACK_TYPE PoseDetectionStartBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie) 07529 { 07530 PoseCookie* pPoseCookie = (PoseCookie*)pCookie; 07531 PoseDetectionCapability cap(hNode); 07532 if (pPoseCookie->startHandler != NULL) 07533 { 07534 pPoseCookie->startHandler(cap, strPose, user, pPoseCookie->pPoseCookie); 07535 } 07536 } 07537 07538 static void XN_CALLBACK_TYPE PoseDetectionStartEndBundleCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie) 07539 { 07540 PoseCookie* pPoseCookie = (PoseCookie*)pCookie; 07541 PoseDetectionCapability cap(hNode); 07542 if (pPoseCookie->endHandler != NULL) 07543 { 07544 pPoseCookie->endHandler(cap, strPose, user, pPoseCookie->pPoseCookie); 07545 } 07546 } 07547 typedef struct PoseDetectionCookie 07548 { 07549 PoseDetection handler; 07550 void* pPoseCookie; 07551 XnCallbackHandle hCallback; 07552 } PoseDetectionCookie; 07553 static void XN_CALLBACK_TYPE PoseDetectionCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, void* pCookie) 07554 { 07555 PoseDetectionCookie* pPoseDetectionCookie = (PoseDetectionCookie*)pCookie; 07556 PoseDetectionCapability cap(hNode); 07557 if (pPoseDetectionCookie->handler != NULL) 07558 { 07559 pPoseDetectionCookie->handler(cap, strPose, user, pPoseDetectionCookie->pPoseCookie); 07560 } 07561 } 07562 07563 typedef struct PoseInProgressCookie 07564 { 07565 PoseInProgress handler; 07566 void* pPoseCookie; 07567 XnCallbackHandle hCallback; 07568 } PoseInProgressCookie; 07569 07570 static void XN_CALLBACK_TYPE PoseDetectionInProgressCallback(XnNodeHandle hNode, const XnChar* strPose, XnUserID user, XnPoseDetectionStatus poseErrors, void* pCookie) 07571 { 07572 PoseInProgressCookie* pPoseCookie = (PoseInProgressCookie*)pCookie; 07573 PoseDetectionCapability cap(hNode); 07574 if (pPoseCookie->handler != NULL) 07575 { 07576 pPoseCookie->handler(cap, strPose, user, poseErrors, pPoseCookie->pPoseCookie); 07577 } 07578 } 07579 }; 07580 07692 class UserGenerator : public Generator 07693 { 07694 public: 07700 inline UserGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 07701 inline UserGenerator(const NodeWrapper& other) : Generator(other) {} 07702 07710 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 07711 07724 typedef void (XN_CALLBACK_TYPE* UserHandler)(UserGenerator& generator, XnUserID user, void* pCookie); 07725 07733 inline XnUInt16 GetNumberOfUsers() const 07734 { 07735 return xnGetNumberOfUsers(GetHandle()); 07736 } 07737 07760 inline XnStatus GetUsers(XnUserID aUsers[], XnUInt16& nUsers) const 07761 { 07762 return xnGetUsers(GetHandle(), aUsers, &nUsers); 07763 } 07764 07784 inline XnStatus GetCoM(XnUserID user, XnPoint3D& com) const 07785 { 07786 return xnGetUserCoM(GetHandle(), user, &com); 07787 } 07788 07804 inline XnStatus GetUserPixels(XnUserID user, SceneMetaData& smd) const 07805 { 07806 return xnGetUserPixels(GetHandle(), user, smd.GetUnderlying()); 07807 } 07808 07819 inline XnStatus RegisterUserCallbacks(UserHandler NewUserCB, UserHandler LostUserCB, void* pCookie, XnCallbackHandle& hCallback) 07820 { 07821 XnStatus nRetVal = XN_STATUS_OK; 07822 07823 UserCookie* pUserCookie; 07824 XN_VALIDATE_ALLOC(pUserCookie, UserCookie); 07825 pUserCookie->newHandler = NewUserCB; 07826 pUserCookie->lostHandler = LostUserCB; 07827 pUserCookie->pUserCookie = pCookie; 07828 07829 nRetVal = xnRegisterUserCallbacks(GetHandle(), NewUserCallback, LostUserCallback, pUserCookie, &pUserCookie->hCallback); 07830 if (nRetVal != XN_STATUS_OK) 07831 { 07832 xnOSFree(pUserCookie); 07833 return (nRetVal); 07834 } 07835 07836 hCallback = pUserCookie; 07837 07838 return (XN_STATUS_OK); 07839 } 07840 07848 inline void UnregisterUserCallbacks(XnCallbackHandle hCallback) 07849 { 07850 UserCookie* pUserCookie = (UserCookie*)hCallback; 07851 xnUnregisterUserCallbacks(GetHandle(), pUserCookie->hCallback); 07852 xnOSFree(pUserCookie); 07853 } 07854 07866 inline const SkeletonCapability GetSkeletonCap() const 07867 { 07868 return SkeletonCapability(GetHandle()); 07869 } 07870 07882 inline SkeletonCapability GetSkeletonCap() 07883 { 07884 return SkeletonCapability(GetHandle()); 07885 } 07886 07897 inline const PoseDetectionCapability GetPoseDetectionCap() const 07898 { 07899 return PoseDetectionCapability(GetHandle()); 07900 } 07901 07912 inline PoseDetectionCapability GetPoseDetectionCap() 07913 { 07914 return PoseDetectionCapability(GetHandle()); 07915 } 07916 07926 inline XnStatus RegisterToUserExit(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback) 07927 { 07928 XnStatus nRetVal = XN_STATUS_OK; 07929 07930 UserSingleCookie* pUserCookie; 07931 XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie); 07932 pUserCookie->handler = handler; 07933 pUserCookie->pUserCookie = pCookie; 07934 07935 nRetVal = xnRegisterToUserExit(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback); 07936 if (nRetVal != XN_STATUS_OK) 07937 { 07938 xnOSFree(pUserCookie); 07939 return (nRetVal); 07940 } 07941 07942 hCallback = pUserCookie; 07943 07944 return (XN_STATUS_OK); 07945 } 07946 07954 inline void UnregisterFromUserExit(XnCallbackHandle hCallback) 07955 { 07956 UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback; 07957 xnUnregisterFromUserExit(GetHandle(), pUserCookie->hCallback); 07958 xnOSFree(pUserCookie); 07959 } 07960 07970 inline XnStatus RegisterToUserReEnter(UserHandler handler, void* pCookie, XnCallbackHandle& hCallback) 07971 { 07972 XnStatus nRetVal = XN_STATUS_OK; 07973 07974 UserSingleCookie* pUserCookie; 07975 XN_VALIDATE_ALLOC(pUserCookie, UserSingleCookie); 07976 pUserCookie->handler = handler; 07977 pUserCookie->pUserCookie = pCookie; 07978 07979 nRetVal = xnRegisterToUserReEnter(GetHandle(), UserSingleCallback, pUserCookie, &pUserCookie->hCallback); 07980 if (nRetVal != XN_STATUS_OK) 07981 { 07982 xnOSFree(pUserCookie); 07983 return (nRetVal); 07984 } 07985 07986 hCallback = pUserCookie; 07987 07988 return (XN_STATUS_OK); 07989 } 07990 07998 inline void UnregisterFromUserReEnter(XnCallbackHandle hCallback) 07999 { 08000 UserSingleCookie* pUserCookie = (UserSingleCookie*)hCallback; 08001 xnUnregisterFromUserReEnter(GetHandle(), pUserCookie->hCallback); 08002 xnOSFree(pUserCookie); 08003 } 08004 08005 private: 08006 typedef struct UserCookie 08007 { 08008 UserHandler newHandler; 08009 UserHandler lostHandler; 08010 void* pUserCookie; 08011 XnCallbackHandle hCallback; 08012 } UserCookie; 08013 08014 static void XN_CALLBACK_TYPE NewUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie) 08015 { 08016 UserCookie* pUserCookie = (UserCookie*)pCookie; 08017 UserGenerator gen(hNode); 08018 if (pUserCookie->newHandler != NULL) 08019 { 08020 pUserCookie->newHandler(gen, user, pUserCookie->pUserCookie); 08021 } 08022 } 08023 08024 static void XN_CALLBACK_TYPE LostUserCallback(XnNodeHandle hNode, XnUserID user, void* pCookie) 08025 { 08026 UserCookie* pUserCookie = (UserCookie*)pCookie; 08027 UserGenerator gen(hNode); 08028 if (pUserCookie->lostHandler != NULL) 08029 { 08030 pUserCookie->lostHandler(gen, user, pUserCookie->pUserCookie); 08031 } 08032 } 08033 08034 typedef struct UserSingleCookie 08035 { 08036 UserHandler handler; 08037 void* pUserCookie; 08038 XnCallbackHandle hCallback; 08039 } UserSingleCookie; 08040 08041 static void XN_CALLBACK_TYPE UserSingleCallback(XnNodeHandle hNode, XnUserID user, void* pCookie) 08042 { 08043 UserSingleCookie* pUserCookie = (UserSingleCookie*)pCookie; 08044 UserGenerator gen(hNode); 08045 if (pUserCookie->handler != NULL) 08046 { 08047 pUserCookie->handler(gen, user, pUserCookie->pUserCookie); 08048 } 08049 } 08050 }; 08051 08065 class AudioGenerator : public Generator 08066 { 08067 public: 08073 inline AudioGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 08074 inline AudioGenerator(const NodeWrapper& other) : Generator(other) {} 08075 08083 inline XnStatus Create(Context& context, Query* pQuery = NULL, EnumerationErrors* pErrors = NULL); 08084 08101 inline void GetMetaData(AudioMetaData& metaData) const 08102 { 08103 xnGetAudioMetaData(GetHandle(), metaData.GetUnderlying()); 08104 } 08105 08110 inline const XnUChar* GetAudioBuffer() const 08111 { 08112 return xnGetAudioBuffer(GetHandle()); 08113 } 08114 08118 inline XnUInt32 GetSupportedWaveOutputModesCount() const 08119 { 08120 return xnGetSupportedWaveOutputModesCount(GetHandle()); 08121 } 08122 08129 inline XnStatus GetSupportedWaveOutputModes(XnWaveOutputMode* aSupportedModes, XnUInt32& nCount) const 08130 { 08131 return xnGetSupportedWaveOutputModes(GetHandle(), aSupportedModes, &nCount); 08132 } 08133 08145 inline XnStatus SetWaveOutputMode(const XnWaveOutputMode& OutputMode) 08146 { 08147 return xnSetWaveOutputMode(GetHandle(), &OutputMode); 08148 } 08149 08161 inline XnStatus GetWaveOutputMode(XnWaveOutputMode& OutputMode) const 08162 { 08163 return xnGetWaveOutputMode(GetHandle(), &OutputMode); 08164 } 08165 08175 inline XnStatus RegisterToWaveOutputModeChanges(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 08176 { 08177 return _RegisterToStateChange(xnRegisterToWaveOutputModeChanges, GetHandle(), handler, pCookie, hCallback); 08178 } 08179 08187 inline void UnregisterFromWaveOutputModeChanges(XnCallbackHandle hCallback) 08188 { 08189 _UnregisterFromStateChange(xnUnregisterFromWaveOutputModeChanges, GetHandle(), hCallback); 08190 } 08191 }; 08192 08197 class MockAudioGenerator : public AudioGenerator 08198 { 08199 public: 08205 inline MockAudioGenerator(XnNodeHandle hNode = NULL) : AudioGenerator(hNode) {} 08206 inline MockAudioGenerator(const NodeWrapper& other) : AudioGenerator(other) {} 08207 08214 XnStatus Create(Context& context, const XnChar* strName = NULL); 08215 08223 XnStatus CreateBasedOn(AudioGenerator& other, const XnChar* strName = NULL); 08224 08229 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const XnUInt8* pAudioBuffer) 08230 { 08231 return xnMockAudioSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pAudioBuffer); 08232 } 08233 08242 inline XnStatus SetData(const AudioMetaData& audioMD, XnUInt32 nFrameID, XnUInt64 nTimestamp) 08243 { 08244 return SetData(nFrameID, nTimestamp, audioMD.DataSize(), audioMD.Data()); 08245 } 08246 08252 inline XnStatus SetData(const AudioMetaData& audioMD) 08253 { 08254 return SetData(audioMD, audioMD.FrameID(), audioMD.Timestamp()); 08255 } 08256 }; 08257 08261 class MockRawGenerator : public Generator 08262 { 08263 public: 08264 MockRawGenerator(XnNodeHandle hNode = NULL) : Generator(hNode) {} 08265 MockRawGenerator(const NodeWrapper& other) : Generator(other) {} 08266 08267 inline XnStatus Create(Context& context, const XnChar* strName = NULL); 08268 08269 inline XnStatus SetData(XnUInt32 nFrameID, XnUInt64 nTimestamp, XnUInt32 nDataSize, const void* pData) 08270 { 08271 return xnMockRawSetData(GetHandle(), nFrameID, nTimestamp, nDataSize, pData); 08272 } 08273 08274 }; 08275 08280 class Codec : public ProductionNode 08281 { 08282 public: 08288 inline Codec(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 08289 inline Codec(const NodeWrapper& other) : ProductionNode(other) {} 08290 08295 inline XnStatus Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode); 08296 08301 inline XnCodecID GetCodecID() const 08302 { 08303 return xnGetCodecID(GetHandle()); 08304 } 08305 08310 inline XnStatus EncodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const 08311 { 08312 return xnEncodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten); 08313 } 08314 08319 inline XnStatus DecodeData(const void* pSrc, XnUInt32 nSrcSize, void* pDst, XnUInt32 nDstSize, XnUInt* pnBytesWritten) const 08320 { 08321 return xnDecodeData(GetHandle(), pSrc, nSrcSize, pDst, nDstSize, pnBytesWritten); 08322 } 08323 }; 08324 08358 class ScriptNode : public ProductionNode 08359 { 08360 public: 08366 inline ScriptNode(XnNodeHandle hNode = NULL) : ProductionNode(hNode) {} 08367 inline ScriptNode(const NodeWrapper& other) : ProductionNode(other) {} 08368 08369 inline XnStatus Create(Context& context, const XnChar* strFormat); 08370 08371 inline const XnChar* GetSupportedFormat() 08372 { 08373 return xnScriptNodeGetSupportedFormat(GetHandle()); 08374 } 08375 08381 inline XnStatus LoadScriptFromFile(const XnChar* strFileName) 08382 { 08383 return xnLoadScriptFromFile(GetHandle(), strFileName); 08384 } 08385 08391 inline XnStatus LoadScriptFromString(const XnChar* strScript) 08392 { 08393 return xnLoadScriptFromString(GetHandle(), strScript); 08394 } 08395 08407 inline XnStatus Run(EnumerationErrors* pErrors); 08408 }; 08409 08410 //--------------------------------------------------------------------------- 08411 // EnumerationErrors 08412 //--------------------------------------------------------------------------- 08433 class EnumerationErrors 08434 { 08435 public: 08439 inline EnumerationErrors() : m_bAllocated(TRUE) { xnEnumerationErrorsAllocate(&m_pErrors); } 08440 08448 inline EnumerationErrors(XnEnumerationErrors* pErrors, XnBool bOwn = FALSE) : m_pErrors(pErrors), m_bAllocated(bOwn) {} 08449 08453 ~EnumerationErrors() { Free(); } 08454 08458 class Iterator 08459 { 08460 public: 08461 friend class EnumerationErrors; 08462 08468 XnBool operator==(const Iterator& other) const 08469 { 08470 return m_it == other.m_it; 08471 } 08472 08478 XnBool operator!=(const Iterator& other) const 08479 { 08480 return m_it != other.m_it; 08481 } 08482 08487 inline Iterator& operator++() 08488 { 08489 m_it = xnEnumerationErrorsGetNext(m_it); 08490 return *this; 08491 } 08492 08497 inline Iterator operator++(int) 08498 { 08499 return Iterator(xnEnumerationErrorsGetNext(m_it)); 08500 } 08501 08510 inline const XnProductionNodeDescription& Description() { return *xnEnumerationErrorsGetCurrentDescription(m_it); } 08511 08516 inline XnStatus Error() { return xnEnumerationErrorsGetCurrentError(m_it); } 08517 08518 private: 08519 inline Iterator(XnEnumerationErrorsIterator it) : m_it(it) {} 08520 08521 XnEnumerationErrorsIterator m_it; 08522 }; 08523 08532 inline Iterator Begin() const { return Iterator(xnEnumerationErrorsGetFirst(m_pErrors)); } 08533 08542 inline Iterator End() const { return Iterator(NULL); } 08543 08552 inline XnStatus ToString(XnChar* csBuffer, XnUInt32 nSize) 08553 { 08554 return xnEnumerationErrorsToString(m_pErrors, csBuffer, nSize); 08555 } 08556 08561 inline void Free() 08562 { 08563 if (m_bAllocated) 08564 { 08565 xnEnumerationErrorsFree(m_pErrors); 08566 m_pErrors = NULL; 08567 m_bAllocated = FALSE; 08568 } 08569 } 08570 08574 inline XnEnumerationErrors* GetUnderlying() { return m_pErrors; } 08575 08576 private: 08577 XnEnumerationErrors* m_pErrors; 08578 XnBool m_bAllocated; 08579 }; 08580 08581 //--------------------------------------------------------------------------- 08582 // Context 08583 //--------------------------------------------------------------------------- 08584 08620 class Context 08621 { 08622 public: 08637 typedef void (XN_CALLBACK_TYPE* NodeCreationHandler)(Context& context, ProductionNode& createdNode, void* pCookie); 08638 08653 typedef void (XN_CALLBACK_TYPE* NodeDestructionHandler)(Context& context, const XnChar* strDestroyedNodeName, void* pCookie); 08654 08658 inline Context() : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) {} 08659 08665 inline Context(XnContext* pContext) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) 08666 { 08667 SetHandle(pContext); 08668 } 08669 08676 inline Context(const Context& other) : m_pContext(NULL), m_bUsingDeprecatedAPI(FALSE), m_bAllocated(FALSE), m_hShuttingDownCallback(NULL) 08677 { 08678 SetHandle(other.m_pContext); 08679 } 08680 08684 ~Context() 08685 { 08686 SetHandle(NULL); 08687 } 08688 08689 inline Context& operator=(const Context& other) 08690 { 08691 SetHandle(other.m_pContext); 08692 return *this; 08693 } 08694 08698 inline XnContext* GetUnderlyingObject() const { return m_pContext; } 08699 08705 inline XnBool operator==(const Context& other) 08706 { 08707 return (GetUnderlyingObject() == other.GetUnderlyingObject()); 08708 } 08709 08715 inline XnBool operator!=(const Context& other) 08716 { 08717 return (GetUnderlyingObject() != other.GetUnderlyingObject()); 08718 } 08719 08734 inline XnStatus Init() 08735 { 08736 XnContext* pContext = NULL; 08737 XnStatus nRetVal = xnInit(&pContext); 08738 XN_IS_STATUS_OK(nRetVal); 08739 08740 TakeOwnership(pContext); 08741 m_bAllocated = TRUE; 08742 08743 return (XN_STATUS_OK); 08744 } 08745 08761 inline XnStatus RunXmlScript(const XnChar* strScript, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL) 08762 { 08763 XnStatus nRetVal = XN_STATUS_OK; 08764 08765 XnNodeHandle hScriptNode; 08766 nRetVal = xnContextRunXmlScriptEx(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode); 08767 XN_IS_STATUS_OK(nRetVal); 08768 08769 scriptNode.TakeOwnership(hScriptNode); 08770 08771 return (XN_STATUS_OK); 08772 } 08773 08789 inline XnStatus RunXmlScriptFromFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL) 08790 { 08791 XnStatus nRetVal = XN_STATUS_OK; 08792 08793 XnNodeHandle hScriptNode; 08794 nRetVal = xnContextRunXmlScriptFromFileEx(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode); 08795 XN_IS_STATUS_OK(nRetVal); 08796 08797 scriptNode.TakeOwnership(hScriptNode); 08798 08799 return (XN_STATUS_OK); 08800 } 08801 08817 inline XnStatus InitFromXmlFile(const XnChar* strFileName, ScriptNode& scriptNode, EnumerationErrors* pErrors = NULL) 08818 { 08819 XnContext* pContext = NULL; 08820 08821 XnNodeHandle hScriptNode; 08822 XnStatus nRetVal = xnInitFromXmlFileEx(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying(), &hScriptNode); 08823 XN_IS_STATUS_OK(nRetVal); 08824 08825 scriptNode.TakeOwnership(hScriptNode); 08826 TakeOwnership(pContext); 08827 m_bAllocated = TRUE; 08828 08829 return (XN_STATUS_OK); 08830 } 08831 08848 inline XnStatus OpenFileRecording(const XnChar* strFileName, ProductionNode& playerNode) 08849 { 08850 XnStatus nRetVal = XN_STATUS_OK; 08851 08852 XnNodeHandle hPlayer; 08853 nRetVal = xnContextOpenFileRecordingEx(m_pContext, strFileName, &hPlayer); 08854 XN_IS_STATUS_OK(nRetVal); 08855 08856 playerNode.TakeOwnership(hPlayer); 08857 08858 return (XN_STATUS_OK); 08859 } 08860 08865 inline XnStatus CreateMockNode(XnProductionNodeType type, const XnChar* strName, ProductionNode& mockNode) 08866 { 08867 XnStatus nRetVal = XN_STATUS_OK; 08868 08869 XnNodeHandle hMockNode; 08870 nRetVal = xnCreateMockNode(m_pContext, type, strName, &hMockNode); 08871 XN_IS_STATUS_OK(nRetVal); 08872 08873 mockNode.TakeOwnership(hMockNode); 08874 08875 return (XN_STATUS_OK); 08876 } 08877 08882 inline XnStatus CreateMockNodeBasedOn(ProductionNode& originalNode, const XnChar* strName, ProductionNode& mockNode) 08883 { 08884 XnStatus nRetVal = XN_STATUS_OK; 08885 08886 XnNodeHandle hMockNode; 08887 nRetVal = xnCreateMockNodeBasedOn(m_pContext, originalNode, strName, &hMockNode); 08888 XN_IS_STATUS_OK(nRetVal); 08889 08890 mockNode.TakeOwnership(hMockNode); 08891 08892 return (XN_STATUS_OK); 08893 } 08894 08899 inline XnStatus CreateCodec(XnCodecID codecID, ProductionNode& initializerNode, Codec& codec) 08900 { 08901 XnStatus nRetVal = XN_STATUS_OK; 08902 08903 XnNodeHandle hCodec; 08904 nRetVal = xnCreateCodec(m_pContext, codecID, initializerNode.GetHandle(), &hCodec); 08905 XN_IS_STATUS_OK(nRetVal); 08906 08907 codec.TakeOwnership(hCodec); 08908 08909 return (XN_STATUS_OK); 08910 } 08911 08916 inline XnStatus AddRef() 08917 { 08918 return xnContextAddRef(m_pContext); 08919 } 08920 08925 inline void Release() 08926 { 08927 SetHandle(NULL); 08928 } 08929 08930 08935 inline XnStatus AddLicense(const XnLicense& License) 08936 { 08937 return xnAddLicense(m_pContext, &License); 08938 } 08939 08944 inline XnStatus EnumerateLicenses(XnLicense*& aLicenses, XnUInt32& nCount) const 08945 { 08946 return xnEnumerateLicenses(m_pContext, &aLicenses, &nCount); 08947 } 08948 08953 inline static void FreeLicensesList(XnLicense aLicenses[]) 08954 { 08955 xnFreeLicensesList(aLicenses); 08956 } 08957 08978 XnStatus EnumerateProductionTrees(XnProductionNodeType Type, const Query* pQuery, NodeInfoList& TreesList, EnumerationErrors* pErrors = NULL) const 08979 { 08980 XnStatus nRetVal = XN_STATUS_OK; 08981 08982 const XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL; 08983 08984 XnNodeInfoList* pList = NULL; 08985 nRetVal = xnEnumerateProductionTrees(m_pContext, Type, pInternalQuery, &pList, pErrors == NULL ? NULL : pErrors->GetUnderlying()); 08986 XN_IS_STATUS_OK(nRetVal); 08987 08988 TreesList.ReplaceUnderlyingObject(pList); 08989 08990 return (XN_STATUS_OK); 08991 } 08992 09025 XnStatus CreateAnyProductionTree(XnProductionNodeType type, Query* pQuery, ProductionNode& node, EnumerationErrors* pErrors = NULL) 09026 { 09027 XnStatus nRetVal = XN_STATUS_OK; 09028 09029 XnNodeQuery* pInternalQuery = (pQuery != NULL) ? pQuery->GetUnderlyingObject() : NULL; 09030 09031 XnNodeHandle hNode; 09032 nRetVal = xnCreateAnyProductionTree(m_pContext, type, pInternalQuery, &hNode, pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09033 XN_IS_STATUS_OK(nRetVal); 09034 09035 node.TakeOwnership(hNode); 09036 09037 return (XN_STATUS_OK); 09038 } 09039 09056 XnStatus CreateProductionTree(NodeInfo& Tree, ProductionNode& node) 09057 { 09058 XnStatus nRetVal = XN_STATUS_OK; 09059 09060 XnNodeHandle hNode; 09061 nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode); 09062 XN_IS_STATUS_OK(nRetVal); 09063 09064 node.TakeOwnership(hNode); 09065 09066 return (XN_STATUS_OK); 09067 } 09068 09077 XnStatus EnumerateExistingNodes(NodeInfoList& list) const 09078 { 09079 XnNodeInfoList* pList; 09080 XnStatus nRetVal = xnEnumerateExistingNodes(m_pContext, &pList); 09081 XN_IS_STATUS_OK(nRetVal); 09082 09083 list.ReplaceUnderlyingObject(pList); 09084 09085 return (XN_STATUS_OK); 09086 } 09087 09106 XnStatus EnumerateExistingNodes(NodeInfoList& list, XnProductionNodeType type) const 09107 { 09108 XnNodeInfoList* pList; 09109 XnStatus nRetVal = xnEnumerateExistingNodesByType(m_pContext, type, &pList); 09110 XN_IS_STATUS_OK(nRetVal); 09111 09112 list.ReplaceUnderlyingObject(pList); 09113 09114 return (XN_STATUS_OK); 09115 } 09116 09135 XnStatus FindExistingNode(XnProductionNodeType type, ProductionNode& node) const 09136 { 09137 XnStatus nRetVal = XN_STATUS_OK; 09138 09139 XnNodeHandle hNode; 09140 nRetVal = xnFindExistingRefNodeByType(m_pContext, type, &hNode); 09141 XN_IS_STATUS_OK(nRetVal); 09142 09143 node.TakeOwnership(hNode); 09144 09145 return (XN_STATUS_OK); 09146 } 09147 09152 XnStatus GetProductionNodeByName(const XnChar* strInstanceName, ProductionNode& node) const 09153 { 09154 XnStatus nRetVal = XN_STATUS_OK; 09155 09156 XnNodeHandle hNode; 09157 nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode); 09158 XN_IS_STATUS_OK(nRetVal); 09159 09160 node.TakeOwnership(hNode); 09161 09162 return (XN_STATUS_OK); 09163 } 09164 09169 XnStatus GetProductionNodeInfoByName(const XnChar* strInstanceName, NodeInfo& nodeInfo) const 09170 { 09171 XnStatus nRetVal = XN_STATUS_OK; 09172 09173 XnNodeHandle hNode; 09174 nRetVal = xnGetRefNodeHandleByName(m_pContext, strInstanceName, &hNode); 09175 XN_IS_STATUS_OK(nRetVal); 09176 09177 xnProductionNodeRelease(hNode); 09178 09179 nodeInfo = NodeInfo(xnGetNodeInfo(hNode)); 09180 09181 return (XN_STATUS_OK); 09182 } 09183 09188 inline XnStatus StartGeneratingAll() 09189 { 09190 return xnStartGeneratingAll(m_pContext); 09191 } 09192 09196 inline XnStatus StopGeneratingAll() 09197 { 09198 return xnStopGeneratingAll(m_pContext); 09199 } 09200 09210 inline XnStatus SetGlobalMirror(XnBool bMirror) 09211 { 09212 return xnSetGlobalMirror(m_pContext, bMirror); 09213 } 09214 09219 inline XnBool GetGlobalMirror() 09220 { 09221 return xnGetGlobalMirror(m_pContext); 09222 } 09223 09228 inline XnStatus GetGlobalErrorState() 09229 { 09230 return xnGetGlobalErrorState(m_pContext); 09231 } 09232 09242 inline XnStatus RegisterToErrorStateChange(XnErrorStateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 09243 { 09244 return xnRegisterToGlobalErrorStateChange(m_pContext, handler, pCookie, &hCallback); 09245 } 09246 09254 inline void UnregisterFromErrorStateChange(XnCallbackHandle hCallback) 09255 { 09256 xnUnregisterFromGlobalErrorStateChange(m_pContext, hCallback); 09257 } 09258 09268 inline XnStatus RegisterToNodeCreation(NodeCreationHandler handler, void* pCookie, XnCallbackHandle& hCallback) 09269 { 09270 XnStatus nRetVal = XN_STATUS_OK; 09271 09272 NodeCreationCookie* pCreationCookie; 09273 XN_VALIDATE_ALLOC(pCreationCookie, NodeCreationCookie); 09274 pCreationCookie->pFunc = handler; 09275 pCreationCookie->pCookie = pCookie; 09276 09277 nRetVal = xnRegisterToNodeCreation(m_pContext, NodeCreationCallback, pCreationCookie, &pCreationCookie->hUnderlyingCallback); 09278 XN_IS_STATUS_OK(nRetVal); 09279 09280 hCallback = pCreationCookie; 09281 09282 return XN_STATUS_OK; 09283 } 09284 09292 inline void UnregisterFromNodeCreation(XnCallbackHandle hCallback) 09293 { 09294 NodeCreationCookie* pCreationCookie = (NodeCreationCookie*)hCallback; 09295 xnUnregisterFromNodeCreation(m_pContext, pCreationCookie->hUnderlyingCallback); 09296 xnOSFree(pCreationCookie); 09297 } 09298 09308 inline XnStatus RegisterToNodeDestruction(NodeDestructionHandler handler, void* pCookie, XnCallbackHandle& hCallback) 09309 { 09310 XnStatus nRetVal = XN_STATUS_OK; 09311 09312 NodeDestructionCookie* pDestructionCookie; 09313 XN_VALIDATE_ALLOC(pDestructionCookie, NodeDestructionCookie); 09314 pDestructionCookie->pFunc = handler; 09315 pDestructionCookie->pCookie = pCookie; 09316 09317 nRetVal = xnRegisterToNodeDestruction(m_pContext, NodeDestructionCallback, pDestructionCookie, &pDestructionCookie->hUnderlyingCallback); 09318 XN_IS_STATUS_OK(nRetVal); 09319 09320 hCallback = pDestructionCookie; 09321 09322 return XN_STATUS_OK; 09323 } 09324 09332 inline void UnregisterFromNodeDestruction(XnCallbackHandle hCallback) 09333 { 09334 NodeDestructionCookie* pDestructionCookie = (NodeDestructionCookie*)hCallback; 09335 xnUnregisterFromNodeDestruction(m_pContext, pDestructionCookie->hUnderlyingCallback); 09336 xnOSFree(pDestructionCookie); 09337 } 09338 09372 inline XnStatus WaitAndUpdateAll() 09373 { 09374 return xnWaitAndUpdateAll(m_pContext); 09375 } 09376 09411 inline XnStatus WaitAnyUpdateAll() 09412 { 09413 return xnWaitAnyUpdateAll(m_pContext); 09414 } 09415 09446 inline XnStatus WaitOneUpdateAll(ProductionNode& node) 09447 { 09448 return xnWaitOneUpdateAll(m_pContext, node.GetHandle()); 09449 } 09450 09472 inline XnStatus WaitNoneUpdateAll() 09473 { 09474 return xnWaitNoneUpdateAll(m_pContext); 09475 } 09476 09481 inline XnStatus AutoEnumerateOverSingleInput(NodeInfoList& List, XnProductionNodeDescription& description, const XnChar* strCreationInfo, XnProductionNodeType InputType, EnumerationErrors* pErrors, Query* pQuery = NULL) const 09482 { 09483 return xnAutoEnumerateOverSingleInput(m_pContext, List.GetUnderlyingObject(), &description, strCreationInfo, InputType, pErrors == NULL ? NULL : pErrors->GetUnderlying(), pQuery == NULL ? NULL : pQuery->GetUnderlyingObject()); 09484 } 09485 09489 inline void SetHandle(XnContext* pContext) 09490 { 09491 if (m_pContext == pContext) 09492 { 09493 return; 09494 } 09495 09496 if (m_pContext != NULL) 09497 { 09498 if (m_bUsingDeprecatedAPI && m_bAllocated) 09499 { 09500 // Backwards compatibility: call shutdown instead of release, to make old programs get the 09501 // exact same behavior they used to have. 09502 xnForceShutdown(m_pContext); 09503 } 09504 else 09505 { 09506 xnContextUnregisterFromShutdown(m_pContext, m_hShuttingDownCallback); 09507 xnContextRelease(m_pContext); 09508 } 09509 } 09510 09511 if (pContext != NULL) 09512 { 09513 XnStatus nRetVal = xnContextAddRef(pContext); 09514 XN_ASSERT(nRetVal == XN_STATUS_OK); 09515 XN_REFERENCE_VARIABLE(nRetVal); 09516 09517 nRetVal = xnContextRegisterForShutdown(pContext, ContextShuttingDownCallback, this, &m_hShuttingDownCallback); 09518 XN_ASSERT(nRetVal == XN_STATUS_OK); 09519 } 09520 09521 m_pContext = pContext; 09522 } 09523 09524 inline void TakeOwnership(XnContext* pContext) 09525 { 09526 SetHandle(pContext); 09527 09528 if (pContext != NULL) 09529 { 09530 xnContextRelease(pContext); 09531 } 09532 } 09533 09535 inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScript(const XnChar* strScript, EnumerationErrors* pErrors = NULL) 09536 { 09537 m_bUsingDeprecatedAPI = TRUE; 09538 #pragma warning (push) 09539 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 09540 return xnContextRunXmlScript(m_pContext, strScript, pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09541 #pragma warning (pop) 09542 } 09543 09544 inline XnStatus XN_API_DEPRECATED("Use other overload!") RunXmlScriptFromFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL) 09545 { 09546 m_bUsingDeprecatedAPI = TRUE; 09547 #pragma warning (push) 09548 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 09549 return xnContextRunXmlScriptFromFile(m_pContext, strFileName, pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09550 #pragma warning (pop) 09551 } 09552 09553 inline XnStatus XN_API_DEPRECATED("Use other overload!") InitFromXmlFile(const XnChar* strFileName, EnumerationErrors* pErrors = NULL) 09554 { 09555 XnContext* pContext = NULL; 09556 m_bUsingDeprecatedAPI = TRUE; 09557 09558 #pragma warning (push) 09559 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 09560 XnStatus nRetVal = xnInitFromXmlFile(strFileName, &pContext, pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09561 #pragma warning (pop) 09562 XN_IS_STATUS_OK(nRetVal); 09563 09564 TakeOwnership(pContext); 09565 m_bAllocated = TRUE; 09566 09567 return (XN_STATUS_OK); 09568 } 09569 09570 inline XnStatus XN_API_DEPRECATED("Use other overload!") OpenFileRecording(const XnChar* strFileName) 09571 { 09572 m_bUsingDeprecatedAPI = TRUE; 09573 #pragma warning (push) 09574 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 09575 return xnContextOpenFileRecording(m_pContext, strFileName); 09576 #pragma warning (pop) 09577 } 09578 09579 inline void XN_API_DEPRECATED("You may use Release() instead, or count on dtor") Shutdown() 09580 { 09581 if (m_pContext != NULL) 09582 { 09583 #pragma warning (push) 09584 #pragma warning (disable: XN_DEPRECATED_WARNING_IDS) 09585 xnShutdown(m_pContext); 09586 #pragma warning (pop) 09587 m_pContext = NULL; 09588 } 09589 } 09590 09591 XnStatus XN_API_DEPRECATED("Please use other overload") CreateProductionTree(NodeInfo& Tree) 09592 { 09593 XnStatus nRetVal = XN_STATUS_OK; 09594 09595 XnNodeHandle hNode; 09596 nRetVal = xnCreateProductionTree(m_pContext, Tree, &hNode); 09597 XN_IS_STATUS_OK(nRetVal); 09598 09599 Tree.m_bOwnerOfNode = TRUE; 09600 09601 return (XN_STATUS_OK); 09602 } 09605 private: 09606 typedef struct NodeCreationCookie 09607 { 09608 NodeCreationHandler pFunc; 09609 void* pCookie; 09610 XnCallbackHandle hUnderlyingCallback; 09611 } NodeCreationCookie; 09612 09613 typedef struct NodeDestructionCookie 09614 { 09615 NodeDestructionHandler pFunc; 09616 void* pCookie; 09617 XnCallbackHandle hUnderlyingCallback; 09618 } NodeDestructionCookie; 09619 09620 static void XN_CALLBACK_TYPE NodeCreationCallback(XnContext* pContext, XnNodeHandle hCreatedNode, void* pCookie) 09621 { 09622 NodeCreationCookie* pNodeCreationCookie = (NodeCreationCookie*)pCookie; 09623 Context context(pContext); 09624 ProductionNode createdNode(hCreatedNode); 09625 pNodeCreationCookie->pFunc(context, createdNode, pNodeCreationCookie->pCookie); 09626 } 09627 09628 static void XN_CALLBACK_TYPE NodeDestructionCallback(XnContext* pContext, const XnChar* strDestroyedNodeName, void* pCookie) 09629 { 09630 NodeDestructionCookie* pNodeCreationCookie = (NodeDestructionCookie*)pCookie; 09631 Context context(pContext); 09632 pNodeCreationCookie->pFunc(context, strDestroyedNodeName, pNodeCreationCookie->pCookie); 09633 } 09634 09635 static void XN_CALLBACK_TYPE ContextShuttingDownCallback(XnContext* /*pContext*/, void* pCookie) 09636 { 09637 Context* pThis = (Context*)pCookie; 09638 pThis->m_pContext = NULL; 09639 } 09640 09641 XnContext* m_pContext; 09642 XnBool m_bUsingDeprecatedAPI; 09643 XnBool m_bAllocated; 09644 XnCallbackHandle m_hShuttingDownCallback; 09645 }; 09646 09651 class Resolution 09652 { 09653 public: 09659 inline Resolution(XnResolution res) : m_Res(res) 09660 { 09661 m_nXRes = xnResolutionGetXRes(res); 09662 m_nYRes = xnResolutionGetYRes(res); 09663 m_strName = xnResolutionGetName(res); 09664 } 09665 09672 inline Resolution(XnUInt32 xRes, XnUInt32 yRes) : m_nXRes(xRes), m_nYRes(yRes) 09673 { 09674 m_Res = xnResolutionGetFromXYRes(xRes, yRes); 09675 m_strName = xnResolutionGetName(m_Res); 09676 } 09677 09683 inline Resolution(const XnChar* strName) 09684 { 09685 m_Res = xnResolutionGetFromName(strName); 09686 m_nXRes = xnResolutionGetXRes(m_Res); 09687 m_nYRes = xnResolutionGetYRes(m_Res); 09688 m_strName = xnResolutionGetName(m_Res); 09689 } 09690 09694 inline XnResolution GetResolution() const { return m_Res; } 09698 inline XnUInt32 GetXResolution() const { return m_nXRes; } 09702 inline XnUInt32 GetYResolution() const { return m_nYRes; } 09706 inline const XnChar* GetName() const { return m_strName; } 09707 09708 private: 09709 XnResolution m_Res; 09710 XnUInt32 m_nXRes; 09711 XnUInt32 m_nYRes; 09712 const XnChar* m_strName; 09713 }; 09714 09715 //--------------------------------------------------------------------------- 09716 // Functions Implementation 09717 //--------------------------------------------------------------------------- 09718 inline XnStatus NodeInfoList::FilterList(Context& context, Query& query) 09719 { 09720 return xnNodeQueryFilterList(context.GetUnderlyingObject(), query.GetUnderlyingObject(), m_pList); 09721 } 09722 09723 inline void ProductionNode::GetContext(Context& context) const 09724 { 09725 context.TakeOwnership(xnGetRefContextFromNodeHandle(GetHandle())); 09726 } 09727 09728 inline Context ProductionNode::GetContext() const 09729 { 09730 XnContext* pContext = xnGetRefContextFromNodeHandle(GetHandle()); 09731 Context result(pContext); 09732 xnContextRelease(pContext); 09733 return result; 09734 } 09735 09736 inline NodeInfoList& NodeInfo::GetNeededNodes() const 09737 { 09738 if (m_pNeededNodes == NULL) 09739 { 09740 XnNodeInfoList* pList = xnNodeInfoGetNeededNodes(m_pInfo); 09741 m_pNeededNodes = XN_NEW(NodeInfoList, pList); 09742 } 09743 09744 return *m_pNeededNodes; 09745 } 09746 09747 inline void NodeInfo::SetUnderlyingObject(XnNodeInfo* pInfo) 09748 { 09749 if (m_pNeededNodes != NULL) 09750 { 09751 XN_DELETE(m_pNeededNodes); 09752 } 09753 09754 m_bOwnerOfNode = FALSE; 09755 m_pInfo = pInfo; 09756 m_pNeededNodes = NULL; 09757 } 09758 09759 inline XnBool FrameSyncCapability::CanFrameSyncWith(Generator& other) const 09760 { 09761 return xnCanFrameSyncWith(GetHandle(), other.GetHandle()); 09762 } 09763 09764 inline XnStatus FrameSyncCapability::FrameSyncWith(Generator& other) 09765 { 09766 return xnFrameSyncWith(GetHandle(), other.GetHandle()); 09767 } 09768 09769 inline XnStatus FrameSyncCapability::StopFrameSyncWith(Generator& other) 09770 { 09771 return xnStopFrameSyncWith(GetHandle(), other.GetHandle()); 09772 } 09773 09774 inline XnBool FrameSyncCapability::IsFrameSyncedWith(Generator& other) const 09775 { 09776 return xnIsFrameSyncedWith(GetHandle(), other.GetHandle()); 09777 } 09778 09779 inline XnStatus NodeInfo::GetInstance(ProductionNode& node) const 09780 { 09781 if (m_pInfo == NULL) 09782 { 09783 return XN_STATUS_INVALID_OPERATION; 09784 } 09785 09786 XnNodeHandle hNode = xnNodeInfoGetRefHandle(m_pInfo); 09787 node.TakeOwnership(hNode); 09788 09789 if (m_bOwnerOfNode) 09790 { 09791 xnProductionNodeRelease(hNode); 09792 } 09793 09794 return (XN_STATUS_OK); 09795 } 09796 09797 //--------------------------------------------------------------------------- 09798 // Node creation functions 09799 //--------------------------------------------------------------------------- 09800 09801 inline XnStatus Device::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09802 { 09803 XnNodeHandle hNode; 09804 XnStatus nRetVal = xnCreateDevice(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09805 XN_IS_STATUS_OK(nRetVal); 09806 TakeOwnership(hNode); 09807 return (XN_STATUS_OK); 09808 } 09809 09810 inline XnStatus Recorder::Create(Context& context, const XnChar* strFormatName /*= NULL*/) 09811 { 09812 XnNodeHandle hNode; 09813 XnStatus nRetVal = xnCreateRecorder(context.GetUnderlyingObject(), strFormatName, &hNode); 09814 XN_IS_STATUS_OK(nRetVal); 09815 TakeOwnership(hNode); 09816 return (XN_STATUS_OK); 09817 } 09818 09819 inline XnStatus Player::Create(Context& context, const XnChar* strFormatName) 09820 { 09821 XnNodeHandle hNode; 09822 XnStatus nRetVal = xnCreatePlayer(context.GetUnderlyingObject(), strFormatName, &hNode); 09823 XN_IS_STATUS_OK(nRetVal); 09824 TakeOwnership(hNode); 09825 return (XN_STATUS_OK); 09826 } 09827 09828 inline XnStatus DepthGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09829 { 09830 XnNodeHandle hNode; 09831 XnStatus nRetVal = xnCreateDepthGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09832 XN_IS_STATUS_OK(nRetVal); 09833 TakeOwnership(hNode); 09834 return (XN_STATUS_OK); 09835 } 09836 09837 inline XnStatus MockDepthGenerator::Create(Context& context, const XnChar* strName /* = NULL */) 09838 { 09839 XnNodeHandle hNode; 09840 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_DEPTH, strName, &hNode); 09841 XN_IS_STATUS_OK(nRetVal); 09842 TakeOwnership(hNode); 09843 return (XN_STATUS_OK); 09844 } 09845 09846 inline XnStatus MockDepthGenerator::CreateBasedOn(DepthGenerator& other, const XnChar* strName /* = NULL */) 09847 { 09848 Context context; 09849 other.GetContext(context); 09850 XnNodeHandle hNode; 09851 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode); 09852 XN_IS_STATUS_OK(nRetVal); 09853 TakeOwnership(hNode); 09854 return (XN_STATUS_OK); 09855 } 09856 09857 inline XnStatus ImageGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09858 { 09859 XnNodeHandle hNode; 09860 XnStatus nRetVal = xnCreateImageGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09861 XN_IS_STATUS_OK(nRetVal); 09862 TakeOwnership(hNode); 09863 return (XN_STATUS_OK); 09864 } 09865 09866 inline XnStatus MockImageGenerator::Create(Context& context, const XnChar* strName /* = NULL */) 09867 { 09868 XnNodeHandle hNode; 09869 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IMAGE, strName, &hNode); 09870 XN_IS_STATUS_OK(nRetVal); 09871 TakeOwnership(hNode); 09872 return (XN_STATUS_OK); 09873 } 09874 09875 inline XnStatus MockImageGenerator::CreateBasedOn(ImageGenerator& other, const XnChar* strName /* = NULL */) 09876 { 09877 Context context; 09878 other.GetContext(context); 09879 XnNodeHandle hNode; 09880 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode); 09881 XN_IS_STATUS_OK(nRetVal); 09882 TakeOwnership(hNode); 09883 return (XN_STATUS_OK); 09884 } 09885 09886 inline XnStatus IRGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09887 { 09888 XnNodeHandle hNode; 09889 XnStatus nRetVal = xnCreateIRGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09890 XN_IS_STATUS_OK(nRetVal); 09891 TakeOwnership(hNode); 09892 return (XN_STATUS_OK); 09893 } 09894 09895 inline XnStatus MockIRGenerator::Create(Context& context, const XnChar* strName /* = NULL */) 09896 { 09897 XnNodeHandle hNode; 09898 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_IR, strName, &hNode); 09899 XN_IS_STATUS_OK(nRetVal); 09900 TakeOwnership(hNode); 09901 return (XN_STATUS_OK); 09902 } 09903 09904 inline XnStatus MockIRGenerator::CreateBasedOn(IRGenerator& other, const XnChar* strName /* = NULL */) 09905 { 09906 Context context; 09907 other.GetContext(context); 09908 XnNodeHandle hNode; 09909 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode); 09910 XN_IS_STATUS_OK(nRetVal); 09911 TakeOwnership(hNode); 09912 return (XN_STATUS_OK); 09913 } 09914 09915 inline XnStatus GestureGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09916 { 09917 XnNodeHandle hNode; 09918 XnStatus nRetVal = xnCreateGestureGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09919 XN_IS_STATUS_OK(nRetVal); 09920 TakeOwnership(hNode); 09921 return (XN_STATUS_OK); 09922 } 09923 09924 inline XnStatus SceneAnalyzer::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09925 { 09926 //You're creating a scene! 09927 XnNodeHandle hNode; 09928 XnStatus nRetVal = xnCreateSceneAnalyzer(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09929 XN_IS_STATUS_OK(nRetVal); 09930 TakeOwnership(hNode); 09931 return (XN_STATUS_OK); 09932 } 09933 09934 inline XnStatus HandsGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09935 { 09936 XnNodeHandle hNode; 09937 XnStatus nRetVal = xnCreateHandsGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09938 XN_IS_STATUS_OK(nRetVal); 09939 TakeOwnership(hNode); 09940 return (XN_STATUS_OK); 09941 } 09942 09943 inline XnStatus UserGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09944 { 09945 XnNodeHandle hNode; 09946 XnStatus nRetVal = xnCreateUserGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09947 XN_IS_STATUS_OK(nRetVal); 09948 TakeOwnership(hNode); 09949 return (XN_STATUS_OK); 09950 } 09951 09952 inline XnStatus AudioGenerator::Create(Context& context, Query* pQuery/*=NULL*/, EnumerationErrors* pErrors/*=NULL*/) 09953 { 09954 XnNodeHandle hNode; 09955 XnStatus nRetVal = xnCreateAudioGenerator(context.GetUnderlyingObject(), &hNode, pQuery == NULL ? NULL : pQuery->GetUnderlyingObject(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 09956 XN_IS_STATUS_OK(nRetVal); 09957 TakeOwnership(hNode); 09958 return (XN_STATUS_OK); 09959 } 09960 09961 inline XnStatus MockAudioGenerator::Create(Context& context, const XnChar* strName /* = NULL */) 09962 { 09963 XnNodeHandle hNode; 09964 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_AUDIO, strName, &hNode); 09965 XN_IS_STATUS_OK(nRetVal); 09966 TakeOwnership(hNode); 09967 return (XN_STATUS_OK); 09968 } 09969 09970 inline XnStatus MockAudioGenerator::CreateBasedOn(AudioGenerator& other, const XnChar* strName /* = NULL */) 09971 { 09972 Context context; 09973 other.GetContext(context); 09974 XnNodeHandle hNode; 09975 XnStatus nRetVal = xnCreateMockNodeBasedOn(context.GetUnderlyingObject(), other.GetHandle(), strName, &hNode); 09976 XN_IS_STATUS_OK(nRetVal); 09977 TakeOwnership(hNode); 09978 return (XN_STATUS_OK); 09979 } 09980 09981 inline XnStatus MockRawGenerator::Create(Context& context, const XnChar* strName /*= NULL*/) 09982 { 09983 XnNodeHandle hNode; 09984 XnStatus nRetVal = xnCreateMockNode(context.GetUnderlyingObject(), XN_NODE_TYPE_GENERATOR, strName, &hNode); 09985 XN_IS_STATUS_OK(nRetVal); 09986 TakeOwnership(hNode); 09987 return (XN_STATUS_OK); 09988 } 09989 09990 inline XnStatus Codec::Create(Context& context, XnCodecID codecID, ProductionNode& initializerNode) 09991 { 09992 XnNodeHandle hNode; 09993 XnStatus nRetVal = xnCreateCodec(context.GetUnderlyingObject(), codecID, initializerNode.GetHandle(), &hNode); 09994 XN_IS_STATUS_OK(nRetVal); 09995 TakeOwnership(hNode); 09996 return (XN_STATUS_OK); 09997 } 09998 09999 inline XnStatus ScriptNode::Run(EnumerationErrors* pErrors) 10000 { 10001 return xnScriptNodeRun(GetHandle(), pErrors == NULL ? NULL : pErrors->GetUnderlying()); 10002 } 10003 10004 inline XnStatus ScriptNode::Create(Context& context, const XnChar* strFormat) 10005 { 10006 XnNodeHandle hNode; 10007 XnStatus nRetVal = xnCreateScriptNode(context.GetUnderlyingObject(), strFormat, &hNode); 10008 XN_IS_STATUS_OK(nRetVal); 10009 TakeOwnership(hNode); 10010 return (XN_STATUS_OK); 10011 } 10012 10013 //--------------------------------------------------------------------------- 10014 // Global Helper Functions 10015 //--------------------------------------------------------------------------- 10016 10017 inline void XN_API_DEPRECATED("Use xn::Version::Current() instead") GetVersion(XnVersion& Version) 10018 { 10019 xnGetVersion(&Version); 10020 } 10021 10022 //--------------------------------------------------------------------------- 10023 // Internal Helper Classes and Functions 10024 //--------------------------------------------------------------------------- 10025 10026 class StateChangedCallbackTranslator 10027 { 10028 public: 10029 StateChangedCallbackTranslator(StateChangedHandler handler, void* pCookie) : m_UserHandler(handler), m_pUserCookie(pCookie), m_hCallback(NULL) {} 10030 10031 XnStatus Register(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode) 10032 { 10033 return xnFunc(hNode, StateChangedCallback, this, &m_hCallback); 10034 } 10035 10036 void Unregister(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode) 10037 { 10038 xnFunc(hNode, m_hCallback); 10039 } 10040 10041 static XnStatus RegisterToUnderlying(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 10042 { 10043 XnStatus nRetVal = XN_STATUS_OK; 10044 10045 StateChangedCallbackTranslator* pTrans; 10046 XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie); 10047 10048 nRetVal = pTrans->Register(xnFunc, hNode); 10049 if (nRetVal != XN_STATUS_OK) 10050 { 10051 XN_DELETE(pTrans); 10052 return (nRetVal); 10053 } 10054 10055 hCallback = pTrans; 10056 10057 return (XN_STATUS_OK); 10058 } 10059 10060 static XnStatus UnregisterFromUnderlying(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback) 10061 { 10062 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback; 10063 pTrans->Unregister(xnFunc, hNode); 10064 XN_DELETE(pTrans); 10065 return XN_STATUS_OK; 10066 } 10067 10068 private: 10069 friend class GeneralIntCapability; 10070 10071 typedef struct StateChangeCookie 10072 { 10073 StateChangedHandler userHandler; 10074 void* pUserCookie; 10075 XnCallbackHandle hCallback; 10076 } StateChangeCookie; 10077 10078 static void XN_CALLBACK_TYPE StateChangedCallback(XnNodeHandle hNode, void* pCookie) 10079 { 10080 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)pCookie; 10081 ProductionNode node(hNode); 10082 pTrans->m_UserHandler(node, pTrans->m_pUserCookie); 10083 } 10084 10085 StateChangedHandler m_UserHandler; 10086 void* m_pUserCookie; 10087 XnCallbackHandle m_hCallback; 10088 }; 10089 10090 static XnStatus _RegisterToStateChange(_XnRegisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 10091 { 10092 return StateChangedCallbackTranslator::RegisterToUnderlying(xnFunc, hNode, handler, pCookie, hCallback); 10093 } 10094 10095 static void _UnregisterFromStateChange(_XnUnregisterStateChangeFuncPtr xnFunc, XnNodeHandle hNode, XnCallbackHandle hCallback) 10096 { 10097 StateChangedCallbackTranslator::UnregisterFromUnderlying(xnFunc, hNode, hCallback); 10098 } 10099 10100 inline XnStatus GeneralIntCapability::RegisterToValueChange(StateChangedHandler handler, void* pCookie, XnCallbackHandle& hCallback) 10101 { 10102 XnStatus nRetVal = XN_STATUS_OK; 10103 10104 StateChangedCallbackTranslator* pTrans; 10105 XN_VALIDATE_NEW(pTrans, StateChangedCallbackTranslator, handler, pCookie); 10106 10107 nRetVal = xnRegisterToGeneralIntValueChange(GetHandle(), m_strCap, pTrans->StateChangedCallback, pTrans, &pTrans->m_hCallback); 10108 if (nRetVal != XN_STATUS_OK) 10109 { 10110 XN_DELETE(pTrans); 10111 return (nRetVal); 10112 } 10113 10114 hCallback = pTrans; 10115 10116 return (XN_STATUS_OK); 10117 } 10118 10119 inline void GeneralIntCapability::UnregisterFromValueChange(XnCallbackHandle hCallback) 10120 { 10121 StateChangedCallbackTranslator* pTrans = (StateChangedCallbackTranslator*)hCallback; 10122 xnUnregisterFromGeneralIntValueChange(GetHandle(), m_strCap, pTrans->m_hCallback); 10123 XN_DELETE(pTrans); 10124 } 10125 }; 10126 10127 #endif // __XN_CPP_WRAPPER_H__
1.7.6.1