1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
/****************************************************************************
* *
* OpenNI 1.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of OpenNI. *
* *
* OpenNI is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* OpenNI is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with OpenNI. If not, see <http://www.gnu.org/licenses/>. *
* *
****************************************************************************/
#ifndef __XN_NODE_WATCHER_H__
#define __XN_NODE_WATCHER_H__
#include <XnCppWrapper.h>
#include <XnTypes.h>
namespace xn
{
class NodeWatcher;
XnStatus CreateNodeWatcher(ProductionNode &node,
XnProductionNodeType type,
void* pCookie,
XnNodeNotifications ¬ifications,
NodeWatcher*& pNodeWatcher);
class NodeWatcher
{
public:
NodeWatcher(const ProductionNode& node,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~NodeWatcher() {}
virtual XnStatus Register() { return XN_STATUS_OK; }
virtual void Unregister() {}
virtual XnStatus NotifyState();
virtual XnStatus Watch() { return XN_STATUS_OK; }
virtual XnUInt64 GetTimestamp() { return 0; }
protected:
virtual XnStatus NotifyStateImpl();
XnStatus NotifyIntPropChanged(const XnChar* strPropName, XnUInt64 nValue);
XnStatus NotifyRealPropChanged(const XnChar* strPropName, XnDouble dValue);
XnStatus NotifyStringPropChanged(const XnChar* strPropName, const XnChar* strValue);
XnStatus NotifyGeneralPropChanged(const XnChar* strPropName, XnUInt32 nBufferSize, const void* pBuffer);
XnNodeNotifications& m_notifications;
void* m_pCookie;
ProductionNode m_node;
private:
XN_DISABLE_COPY_AND_ASSIGN(NodeWatcher);
};
class DeviceWatcher : public NodeWatcher
{
public:
DeviceWatcher(const Device& device,
XnNodeNotifications& notifications,
void* pCookie);
};
class GeneratorWatcher : public NodeWatcher
{
public:
GeneratorWatcher(const Generator &generator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~GeneratorWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus Watch();
virtual XnUInt64 GetTimestamp();
protected:
virtual XnStatus NotifyStateImpl();
virtual const void* GetCurrentData();
private:
Generator m_generator;
static void XN_CALLBACK_TYPE HandleGenerationRunningChange(ProductionNode& node, void* pCookie);
static void XN_CALLBACK_TYPE HandleMirrorChange(ProductionNode& node, void* pCookie);
static void XN_CALLBACK_TYPE HandleFrameSyncChange(ProductionNode& node, void* pCookie);
XnStatus UpdateFrameSync();
XnCallbackHandle m_hGenerationRunningChangeCB;
XnCallbackHandle m_hMirrorChangeCB;
XnCallbackHandle m_hFrameSyncChangeCB;
XnUInt64 m_nLastDataTimeStamp;
XnUInt32 m_nLastDataFrameID;
};
class MapWatcher : public GeneratorWatcher
{
public:
MapWatcher(const MapGenerator &mapGenerator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~MapWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus NotifyStateImpl();
private:
virtual Generator& GetGenerator() { return m_mapGenerator; }
XnStatus NotifySupportedOutputModes();
XnStatus NotifyOutputMode();
XnStatus NotifyCropping();
static void XN_CALLBACK_TYPE HandleMapOutputModeChange(ProductionNode& node, void* pCookie);
static void XN_CALLBACK_TYPE HandleCroppingChange(ProductionNode& node, void* pCookie);
XnCallbackHandle m_hMapOutputModeChangeCB;
XnCallbackHandle m_hCroppingChangeCB;
MapGenerator m_mapGenerator;
};
class ImageWatcher : public MapWatcher
{
public:
ImageWatcher(const ImageGenerator &imageGenerator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~ImageWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus NotifyStateImpl();
private:
XnStatus NotifySupportedPixelFormats();
static void XN_CALLBACK_TYPE HandlePixelFormatChange(ProductionNode& node, void* pCookie);
XnCallbackHandle m_hPixelFormatChangeCB;
ImageGenerator m_imageGenerator;
};
class IRWatcher : public MapWatcher
{
public:
IRWatcher(const IRGenerator &irGenerator,
XnNodeNotifications& notifications,
void* pCookie);
private:
IRGenerator m_irGenerator;
};
class DepthWatcher : public MapWatcher
{
public:
DepthWatcher(const DepthGenerator &depthGenerator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~DepthWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus NotifyStateImpl();
private:
XnStatus NotifyFieldOfView();
XnStatus NotifyUserPositions();
static void XN_CALLBACK_TYPE HandleUserPositionChange(ProductionNode& node, void* pCookie);
static void XN_CALLBACK_TYPE HandleFieldOfViewChange(ProductionNode& node, void* pCookie);
XnCallbackHandle m_hFieldOfViewChangeCB;
XnCallbackHandle m_hUserPositionChangeCB;
DepthGenerator m_depthGenerator;
};
class AudioWatcher : public GeneratorWatcher
{
public:
AudioWatcher(const AudioGenerator &audioGenerator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~AudioWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus NotifyStateImpl();
private:
XnStatus NotifySupportedOutputModes();
XnStatus NotifyOutputMode();
static void XN_CALLBACK_TYPE HandleWaveOutputModeChange(ProductionNode& node, void* pCookie);
XnCallbackHandle m_hOutputModeChangeCB;
AudioGenerator m_audioGenerator;
};
class GestureWatcher : public GeneratorWatcher
{
public:
GestureWatcher(const GestureGenerator &gestureGenerator,
XnNodeNotifications& notifications,
void* pCookie);
virtual ~GestureWatcher();
virtual XnStatus Register();
virtual void Unregister();
virtual XnStatus NotifyStateImpl();
private:
static void XN_CALLBACK_TYPE HandleGestureRecognized(
GestureGenerator& generator,
const XnChar* strGesture,
const XnPoint3D* pIDPosition,
const XnPoint3D* pEndPosition,
void* pCookie);
static void XN_CALLBACK_TYPE HandleGestureProgress(
GestureGenerator& generator,
const XnChar* strGesture,
const XnPoint3D* pPosition,
XnFloat fProgress,
void* pCookie);
XnCallbackHandle m_hGestureCB;
GestureGenerator m_gestureGenerator;
};
}
#endif //__XN_NODE_WATCHER_H__
|