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
|
/****************************************************************************
* *
* PrimeSense Sensor 5.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of PrimeSense Sensor. *
* *
* PrimeSense Sensor 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. *
* *
* PrimeSense Sensor 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 PrimeSense Sensor. If not, see <http://www.gnu.org/licenses/>.*
* *
****************************************************************************/
#ifndef __XN_SENSOR_H__
#define __XN_SENSOR_H__
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnDDK/XnDeviceBase.h>
#include "XnDeviceSensorIO.h"
#include "XnParams.h"
#include "XnDeviceSensor.h"
#include "XnSensorFixedParams.h"
#include "XnSensorFirmwareParams.h"
#include <XnDDK/XnDeviceStream.h>
#include "XnSensorFirmware.h"
#include "XnCmosInfo.h"
#include "IXnSensorStream.h"
#include <XnDDK/XnIntPropertySynchronizer.h>
//---------------------------------------------------------------------------
// Defines
//---------------------------------------------------------------------------
#define XN_SENSOR_PROPERTY_INSTANCE_POINTER "InstancePointer"
//---------------------------------------------------------------------------
// XnSensor class
//---------------------------------------------------------------------------
class XnSensor : public XnDeviceBase
{
friend class XnServerSensorInvoker;
public:
XnSensor();
~XnSensor();
static XnStatus GetDefinition(XnDeviceDefinition* pDeviceDefinition);
static XnStatus Enumerate(XnConnectionString* aConnectionStrings, XnUInt32* pnCount);
virtual XnStatus InitImpl(const XnDeviceConfig* pDeviceConfig);
virtual XnStatus Destroy();
virtual XnStatus OpenAllStreams();
virtual XnStatus ReadStream(XnStreamData* pStreamOutput);
virtual XnStatus Read(XnStreamDataSet* pStreamOutputSet);
virtual XnStatus WriteStream(XnStreamData* pStreamOutput);
virtual XnStatus Write(XnStreamDataSet* pStreamOutputSet);
virtual XnStatus Seek(XnUInt64 nTimestamp);
virtual XnStatus SeekFrame(XnUInt32 nFrameID);
virtual XnStatus LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName);
public:
inline const XnSensorFixedParams* GetFixedParams() const { return &m_FixedParams; }
inline XnSensorFirmware* GetFirmware() { return &m_Firmware; }
inline XnSensorFPS* GetFPSCalculator() { return &m_FPS; }
XnStatus SetCmosConfiguration(XnCMOSType nCmos, XnResolutions nRes, XnUInt32 nFPS);
inline XnDevicePrivateData* GetDevicePrivateData() { return &m_DevicePrivateData; }
XnStatus ConfigPropertyFromFile(XnStringProperty* pProperty, const XnChar* csINIFilePath, const XnChar* csSectionName);
XnStatus ConfigPropertyFromFile(XnIntProperty* pProperty, const XnChar* csINIFilePath, const XnChar* csSectionName);
inline XnBool IsMiscSupported() const { return m_SensorIO.IsMiscEndpointSupported(); }
inline XnBool IsLowBandwidth() const { return m_SensorIO.IsLowBandwidth(); }
XnStatus GetSharedBufferPool(const XnChar* strStream, XnSharedMemoryBufferPool** ppBufferPool);
inline XnStatus GetErrorState() { return (XnStatus)m_ErrorState.GetValue(); }
XnStatus SetErrorState(XnStatus errorState);
static XnStatus ResolveGlobalConfigFileName(XnChar* strConfigFile, XnUInt32 nBufSize, const XnChar* strConfigDir);
XnStatus SetGlobalConfigFile(const XnChar* strConfigFile);
XnStatus ConfigureModuleFromGlobalFile(const XnChar* strModule, const XnChar* strSection = NULL);
const XnChar* GetUSBPath() { return m_USBPath.GetValue(); }
XnBool AreOtherUsersAllowed() { return (m_AllowOtherUsers.GetValue() == TRUE); }
protected:
virtual XnStatus CreateStreamImpl(const XnChar* strType, const XnChar* strName, const XnActualPropertiesHash* pInitialSet);
XnStatus CreateDeviceModule(XnDeviceModuleHolder** ppModuleHolder);
XnStatus CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStream);
void DestroyStreamModule(XnDeviceModuleHolder* pStreamHolder);
XnStatus WaitForPrimaryStream(XN_EVENT_HANDLE hNewDataEvent, XnStreamDataSet* pSet);
private:
XnStatus InitSensor(const XnDeviceConfig* pDeviceConfig);
XnStatus ValidateSensorID(XnChar* csSensorID);
XnStatus ReadFromStreamImpl(XnDeviceStream* pStream, XnStreamData* pStreamOutput);
XnStatus SetMirrorForModule(XnDeviceModule* pModule, XnUInt64 nValue);
XnStatus FindSensorStream(const XnChar* StreamName, IXnSensorStream** ppStream);
XnStatus CheckIfReadingAllowed();
XnStatus InitReading();
XnBool HasSynchedFrameArrived(const XnChar* strDepthStream, const XnChar* strImageStream);
XnStatus OnFrameSyncPropertyChanged();
static XnStatus XN_CALLBACK_TYPE GetInstanceCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
//---------------------------------------------------------------------------
// Getters
//---------------------------------------------------------------------------
XnStatus GetFirmwareParam(XnInnerParamData* pParam);
XnStatus GetCmosBlankingUnits(XnCmosBlankingUnits* pBlanking);
XnStatus GetCmosBlankingTime(XnCmosBlankingTime* pBlanking);
XnStatus GetFirmwareMode(XnParamCurrentMode* pnMode);
XnStatus GetLastRawFrame(const XnChar* strStream, XnUChar* pBuffer, XnUInt32 nDataSize);
XnStatus GetFixedParams(XnDynamicSizeBuffer* pBuffer);
//---------------------------------------------------------------------------
// Setters
//---------------------------------------------------------------------------
XnStatus SetInterface(XnSensorUsbInterface nInterface);
XnStatus SetAllowOtherUsers(XnBool bAllowOtherUsers);
XnStatus SetNumberOfBuffers(XnUInt32 nCount);
XnStatus SetReadEndpoint1(XnBool bRead);
XnStatus SetReadEndpoint2(XnBool bRead);
XnStatus SetReadEndpoint3(XnBool bRead);
XnStatus SetReadData(XnBool bRead);
XnStatus SetFirmwareParam(const XnInnerParamData* pParam);
XnStatus SetCmosBlankingUnits(const XnCmosBlankingUnits* pBlanking);
XnStatus SetCmosBlankingTime(const XnCmosBlankingTime* pBlanking);
XnStatus Reset(XnParamResetType nType);
XnStatus SetFirmwareMode(XnParamCurrentMode nMode);
//---------------------------------------------------------------------------
// Callbacks
//---------------------------------------------------------------------------
static XnStatus XN_CALLBACK_TYPE SetInterfaceCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetAllowOtherUsersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetNumberOfBuffersCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetReadEndpoint1Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetReadEndpoint2Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetReadEndpoint3Callback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetReadDataCallback(XnActualIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetFirmwareParamCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetCmosBlankingUnitsCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetCmosBlankingTimeCallback(XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE ResetCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE SetFirmwareModeCallback(XnIntProperty* pSender, XnUInt64 nValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE GetFixedParamsCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE FrameSyncPropertyChangedCallback(const XnProperty* pSender, void* pCookie);
static XnBool XN_CALLBACK_TYPE HasSynchedFrameArrived(void* pCookie);
static XnBool XN_CALLBACK_TYPE USBEventCallback(XnUSBEventType USBEventType, XnChar* cpDevPath, void* pCallbackData);
static XnStatus XN_CALLBACK_TYPE GetFirmwareParamCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE GetCmosBlankingUnitsCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE GetCmosBlankingTimeCallback(const XnGeneralProperty* pSender, const XnGeneralBuffer& gbValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE GetFirmwareModeCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie);
static XnStatus XN_CALLBACK_TYPE GetAudioSupportedCallback(const XnIntProperty* pSender, XnUInt64* pnValue, void* pCookie);
//---------------------------------------------------------------------------
// Members
//---------------------------------------------------------------------------
XnActualIntProperty m_ErrorState;
XnActualIntProperty m_ResetSensorOnStartup;
XnActualIntProperty m_Interface;
XnActualIntProperty m_NumberOfBuffers;
XnActualIntProperty m_ReadFromEP1;
XnActualIntProperty m_ReadFromEP2;
XnActualIntProperty m_ReadFromEP3;
XnActualIntProperty m_ReadData;
XnActualIntProperty m_FrameSync;
XnActualIntProperty m_CloseStreamsOnShutdown;
XnGeneralProperty m_FirmwareParam;
XnGeneralProperty m_CmosBlankingUnits;
XnGeneralProperty m_CmosBlankingTime;
XnIntProperty m_Reset;
XnIntProperty m_FirmwareMode;
XnVersions m_VersionData;
XnActualGeneralProperty m_Version;
XnGeneralProperty m_FixedParam;
XnGeneralProperty m_InstancePointer;
XnActualStringProperty m_ID;
XnActualStringProperty m_USBPath;
XnActualStringProperty m_DeviceName;
XnActualStringProperty m_VendorSpecificData;
XnActualIntProperty m_AllowOtherUsers;
XnIntProperty m_AudioSupported;
XnSensorFirmware m_Firmware;
XnDevicePrivateData m_DevicePrivateData;
XnSensorFixedParams m_FixedParams;
XnSensorFPS m_FPS;
XnCmosInfo m_CmosInfo;
XnSensorIO m_SensorIO;
XnSensorObjects m_Objects;
XnDumpFile* m_FrameSyncDump;
XnBool m_bInitialized;
XnIntPropertySynchronizer m_PropSynchronizer;
XnChar m_strGlobalConfigFile[XN_FILE_MAX_PATH];
};
#endif //__XN_SENSOR_H__
|