From e7bb1c490aadf04deb8476dd9a0ed714b39680eb Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Wed, 17 Dec 2014 14:04:54 +0100 Subject: [PATCH 1/2] Add RSSDK headers --- modules/control/rssdk/rssdk/pxc3dscan.h | 44 + modules/control/rssdk/rssdk/pxc3dseg.h | 26 + modules/control/rssdk/rssdk/pxcaddref.h | 66 ++ modules/control/rssdk/rssdk/pxcaudio.h | 209 +++++ modules/control/rssdk/rssdk/pxcaudiosource.h | 78 ++ modules/control/rssdk/rssdk/pxcbase.h | 192 ++++ modules/control/rssdk/rssdk/pxccapture.h | 984 +++++++++++++++++++++ modules/control/rssdk/rssdk/pxccapturemanager.h | 217 +++++ modules/control/rssdk/rssdk/pxcdefs.h | 99 +++ modules/control/rssdk/rssdk/pxcemotion.h | 83 ++ modules/control/rssdk/rssdk/pxcfaceconfiguration.h | 325 +++++++ modules/control/rssdk/rssdk/pxcfacedata.h | 464 ++++++++++ modules/control/rssdk/rssdk/pxcfacemodule.h | 25 + modules/control/rssdk/rssdk/pxchandconfiguration.h | 387 ++++++++ modules/control/rssdk/rssdk/pxchanddata.h | 487 ++++++++++ modules/control/rssdk/rssdk/pxchandmodule.h | 41 + modules/control/rssdk/rssdk/pxcimage.h | 230 +++++ modules/control/rssdk/rssdk/pxcmetadata.h | 97 ++ modules/control/rssdk/rssdk/pxcpowerstate.h | 49 + modules/control/rssdk/rssdk/pxcprojection.h | 127 +++ modules/control/rssdk/rssdk/pxcsensemanager.h | 494 +++++++++++ modules/control/rssdk/rssdk/pxcsession.h | 310 +++++++ modules/control/rssdk/rssdk/pxcspeechrecognition.h | 191 ++++ modules/control/rssdk/rssdk/pxcspeechsynthesis.h | 124 +++ modules/control/rssdk/rssdk/pxcstatus.h | 63 ++ modules/control/rssdk/rssdk/pxcsyncpoint.h | 124 +++ .../control/rssdk/rssdk/pxctouchlesscontroller.h | 262 ++++++ modules/control/rssdk/rssdk/pxctracker.h | 135 +++ modules/control/rssdk/rssdk/pxcversion.h | 27 + modules/control/rssdk/rssdk/pxcvideomodule.h | 119 +++ 30 files changed, 6079 insertions(+) create mode 100644 modules/control/rssdk/rssdk/pxc3dscan.h create mode 100644 modules/control/rssdk/rssdk/pxc3dseg.h create mode 100644 modules/control/rssdk/rssdk/pxcaddref.h create mode 100644 modules/control/rssdk/rssdk/pxcaudio.h create mode 100644 modules/control/rssdk/rssdk/pxcaudiosource.h create mode 100644 modules/control/rssdk/rssdk/pxcbase.h create mode 100644 modules/control/rssdk/rssdk/pxccapture.h create mode 100644 modules/control/rssdk/rssdk/pxccapturemanager.h create mode 100644 modules/control/rssdk/rssdk/pxcdefs.h create mode 100644 modules/control/rssdk/rssdk/pxcemotion.h create mode 100644 modules/control/rssdk/rssdk/pxcfaceconfiguration.h create mode 100644 modules/control/rssdk/rssdk/pxcfacedata.h create mode 100644 modules/control/rssdk/rssdk/pxcfacemodule.h create mode 100644 modules/control/rssdk/rssdk/pxchandconfiguration.h create mode 100644 modules/control/rssdk/rssdk/pxchanddata.h create mode 100644 modules/control/rssdk/rssdk/pxchandmodule.h create mode 100644 modules/control/rssdk/rssdk/pxcimage.h create mode 100644 modules/control/rssdk/rssdk/pxcmetadata.h create mode 100644 modules/control/rssdk/rssdk/pxcpowerstate.h create mode 100644 modules/control/rssdk/rssdk/pxcprojection.h create mode 100644 modules/control/rssdk/rssdk/pxcsensemanager.h create mode 100644 modules/control/rssdk/rssdk/pxcsession.h create mode 100644 modules/control/rssdk/rssdk/pxcspeechrecognition.h create mode 100644 modules/control/rssdk/rssdk/pxcspeechsynthesis.h create mode 100644 modules/control/rssdk/rssdk/pxcstatus.h create mode 100644 modules/control/rssdk/rssdk/pxcsyncpoint.h create mode 100644 modules/control/rssdk/rssdk/pxctouchlesscontroller.h create mode 100644 modules/control/rssdk/rssdk/pxctracker.h create mode 100644 modules/control/rssdk/rssdk/pxcversion.h create mode 100644 modules/control/rssdk/rssdk/pxcvideomodule.h diff --git a/modules/control/rssdk/rssdk/pxc3dscan.h b/modules/control/rssdk/rssdk/pxc3dscan.h new file mode 100644 index 0000000..80f09d6 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxc3dscan.h @@ -0,0 +1,44 @@ +/******************************************************************************* +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2014 Intel Corporation. All Rights Reserved. +*******************************************************************************/ +/// @file pxc3dscan.h +/// PXC3DScan video module interface + +#ifndef PXC3DSCAN_H +#define PXC3DSCAN_H +#include "pxccapture.h" + +class PXC3DScan : public PXCBase +{ +public: + /// Query and set the module video profile + struct ProfileInfo { PXCCapture::VideoStream::DataDesc inputs; }; + virtual pxcStatus PXCAPI QueryProfile(pxcU32 pidx, ProfileInfo *pinfo)=0; + pxcStatus __inline QueryProfile(ProfileInfo *pinfo) { return QueryProfile((pxcU32)WORKING_PROFILE,pinfo); } + virtual pxcStatus PXCAPI SetProfile(ProfileInfo *pinfo)=0; + + /// Query and set the module configuration + typedef enum { TARGETING, SCANNING } mode_t; + typedef struct { mode_t mode; } config_t; + virtual pxcStatus PXCAPI QueryConfiguration(config_t* out_config)=0; + virtual pxcStatus PXCAPI SetConfiguration(config_t in_config)=0; + + /// Process a frame of depth (and optionally cooresponding color) data + virtual pxcStatus PXCAPI ProcessImageAsync(PXCImage* in_images[], PXCScheduler::SyncPoint **sp)=0; + + /// Generate a preview image of the scanning volume + virtual pxcStatus PXCAPI AcquirePreview(PXCImage** out_image)=0; + + /// Convert the current scan volume to a printable mesh format, and write it to disk + typedef enum file_format { OBJ, PLY, STL, num_formats } file_format_t; + virtual pxcStatus PXCAPI Reconstruct(file_format_t in_type, const pxcCHAR *in_filename)=0; + + PXC_CUID_OVERWRITE(PXC_UID('S','C','C','1')); +}; +#endif + + diff --git a/modules/control/rssdk/rssdk/pxc3dseg.h b/modules/control/rssdk/rssdk/pxc3dseg.h new file mode 100644 index 0000000..48e30ca --- /dev/null +++ b/modules/control/rssdk/rssdk/pxc3dseg.h @@ -0,0 +1,26 @@ +/******************************************************************************* +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2014 Intel Corporation. All Rights Reserved. +*******************************************************************************/ +/// @file pxc3dseg.h +/// User Segmentation video module interface + +#ifndef PXC3DSEG_H +#define PXC3DSEG_H +#include "pxccapture.h" + +class PXC3DSeg : public PXCBase +{ +public: + /// Allocate and return a copy of the module's most recent segmented image + /// The returned object's Release method can be used to deallocate it + virtual PXCImage* PXCAPI AcquireSegmentedImage(void)=0; + + PXC_CUID_OVERWRITE(PXC_UID('S','G','I','1')); +}; +#endif + + diff --git a/modules/control/rssdk/rssdk/pxcaddref.h b/modules/control/rssdk/rssdk/pxcaddref.h new file mode 100644 index 0000000..9446a7b --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcaddref.h @@ -0,0 +1,66 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#ifndef __PXCADDREF_H__ +#define __PXCADDREF_H__ +#include "pxcbase.h" + +/////////////////////////////////////////////////////////////////////////////////////// + +/** +The interface adds a reference count to the supported object. +*/ +class PXCAddRef { +public: + PXC_CUID_OVERWRITE(PXC_UID('B','A','S','S')); + + /** + @brief Increase the reference counter of the underlying object. + @return The increased reference counter value. + */ + virtual pxcI32 PXCAPI AddRef(void) = 0; +}; + +/////////////////////////////////////////////////////////////////////////////////////// + +/** +This is the base implementation of the PXCAddRef interface. +*/ +template +class PXCAddRefImpl:public T, public PXCAddRef { +public: + + PXCAddRefImpl() + { + m_refCount = 1; + } + + virtual pxcI32 PXCAPI AddRef(void) + { + return InterlockedIncrement((volatile long*)&m_refCount); + } + + virtual void PXCAPI Release(void) + { + if (!InterlockedDecrement((volatile long*)&m_refCount)) + ::delete this; + } + + virtual void* PXCAPI QueryInstance(pxcUID cuid) + { + return (cuid == PXCAddRef::CUID) ? (PXCAddRef*)this : T::QueryInstance(cuid); + } + +protected: + + __declspec(align(32)) pxcI32 m_refCount; + +}; + +#endif diff --git a/modules/control/rssdk/rssdk/pxcaudio.h b/modules/control/rssdk/rssdk/pxcaudio.h new file mode 100644 index 0000000..5cc72fa --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcaudio.h @@ -0,0 +1,209 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcaudio.h + Defines the PXCAudio interface for managing audio buffer access. + */ +#pragma once +#include "pxcaddref.h" +#pragma warning(push) +#pragma warning(disable:4201) /* nameless structs/unions */ + +/** + The PXCAudio interface manages the audio buffer access. + + The interface extends PXCAddRef. Use QueryInstance(), or the helper + function AddRef() to access the PXCAddRef features. + + The interface extends PXCMetadata. Use QueryInstance() to access + the PXCMetadata features. +*/ +class PXCAudio: public PXCBase { +public: + PXC_CUID_OVERWRITE(0x395A39C8); + + /** + @enum AudioFormat + Describes the audio sample format + */ + enum AudioFormat { + AUDIO_FORMAT_PCM = PXC_UID(16,'P','C','M'), /* 16-bit PCM */ + AUDIO_FORMAT_IEEE_FLOAT = PXC_UID(32,'F','L','T'), /* 32-bit float point */ + }; + + /** + @brief Get the audio format string representation + @param[in] format The Audio format enumerator. + @return the string representation of the audio format. + */ + __inline static const pxcCHAR *AudioFormatToString(AudioFormat format) { + switch (format) { + case AUDIO_FORMAT_PCM: return (const pxcCHAR*)L"PCM"; + case AUDIO_FORMAT_IEEE_FLOAT: return (const pxcCHAR*)L"Float"; + } + return (const pxcCHAR*)L"Unknown"; + } + + /** + @brief Return the audio sample size. + @return the sample size in bytes + */ + __inline static pxcI32 AudioFormatToSize(AudioFormat format) { + return (format&0xff)>>3; + } + + /** + @enum ChannelMask + Describes the channels of the audio source. + */ + enum ChannelMask { + CHANNEL_MASK_FRONT_LEFT =0x00000001, /* The source is at front left */ + CHANNEL_MASK_FRONT_RIGHT =0x00000002, /* The source is at front right */ + CHANNEL_MASK_FRONT_CENTER =0x00000004, /* The source is at front center */ + CHANNEL_MASK_LOW_FREQUENCY =0x00000008, /* The source is for low frequency */ + CHANNEL_MASK_BACK_LEFT =0x00000010, /* The source is from back left */ + CHANNEL_MASK_BACK_RIGHT =0x00000020, /* The source is from back right */ + CHANNEL_MASK_SIDE_LEFT =0x00000200, /* The source is from side left */ + CHANNEL_MASK_SIDE_RIGHT =0x00000400, /* The source is from side right */ + }; + + /** + @structure AudioInfo + Describes the audio sample details. + */ + struct AudioInfo { + pxcI32 bufferSize; /* buffer size in number samples */ + AudioFormat format; /* sample format */ + pxcI32 sampleRate; /* samples per second */ + pxcI32 nchannels; /* number of channels */ + ChannelMask channelMask; /* channel mask */ + pxcI32 reserved[3]; + }; + + /** + @structure AudioData + Describes the audio storage details. + */ + struct AudioData { + AudioFormat format; /* sample format */ + pxcI32 dataSize; /* sample data size in number of samples */ + pxcBYTE* dataPtr; /* the sample buffer */ + }; + + /** + @enum Access + Describes the audio sample access mode. + */ + enum Access { + ACCESS_READ = 1, /* read only access */ + ACCESS_WRITE = 2, /* write only access */ + ACCESS_READ_WRITE = ACCESS_READ | ACCESS_WRITE, /* read write access */ + }; + + /** + @enum Option + Describes the audio options. + */ + enum Option { + OPTION_ANY = 0, /* unknown/undefined */ + }; + + /** + @brief Return the audio sample information. + @return the audio sample information in the AudioInfo structure. + */ + virtual AudioInfo PXCAPI QueryInfo(void)=0; + + /** + @brief Return the audio sample time stamp. + @return the time stamp, in 100ns. + */ + virtual pxcI64 PXCAPI QueryTimeStamp(void)=0; + + /** + @brief Return the audio sample option flags. + @return the option flags. + */ + virtual Option PXCAPI QueryOptions(void)=0; + + /** + @brief Set the sample time stamp. + @param[in] ts The time stamp value, in 100ns. + */ + virtual void PXCAPI SetTimeStamp(pxcI64 ts)=0; + + /** + @brief Set the sample options. + @param[in] options The option flags. + */ + virtual void PXCAPI SetOptions(Option options)=0; + + /** + @brief Copy data from another audio sample. + @param[in] src_audio The audio sample to copy data from. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI CopyAudio(PXCAudio *src_audio)=0; + + /** + @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched. + @param[in] access The access mode. + @param[in] format The requested smaple format. + @param[in] options The option flags. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI AcquireAccess(Access access, AudioFormat format, pxcEnum options, AudioData *data)=0; + + /** + @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched. + @param[in] access The access mode. + @param[in] format The requested smaple format. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus AcquireAccess(Access access, AudioFormat format, AudioData *data) { return AcquireAccess(access, format, 0, data); } + + /** + @brief Lock to access the internal storage of a specified format. + @param[in] access The access mode. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus AcquireAccess(Access access, AudioData *data) { return AcquireAccess(access, (AudioFormat)0, 0, data); } + + /** + @brief Unlock the previously acquired buffer. + @param[in] data The sample data storage previously acquired. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ReleaseAccess(AudioData *data)=0; + + /** + @brief Increase a reference count of the sample. + */ + __inline void AddRef(void) { + QueryInstance()->AddRef(); + } +}; + +/** + A helper function for bitwise OR of two flags. +*/ +__inline static PXCAudio::ChannelMask operator | (PXCAudio::ChannelMask a, PXCAudio::ChannelMask b) { + return (PXCAudio::ChannelMask)((int)a|(int)b); +} + +/** + A helper function for bitwise OR of two flags. +*/ +__inline static PXCAudio::Option operator | (PXCAudio::Option a, PXCAudio::Option b) { + return (PXCAudio::Option)((int)a|(int)b); +} +#pragma warning(pop) \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxcaudiosource.h b/modules/control/rssdk/rssdk/pxcaudiosource.h new file mode 100644 index 0000000..0dff4a2 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcaudiosource.h @@ -0,0 +1,78 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxcbase.h" + +/** + The audio source interface manages the audio devices. +*/ +class PXCAudioSource: public PXCBase { +public: + PXC_CUID_OVERWRITE(0xD8419523); + + /** + @struct DeviceInfo + This structure describes the audio device information. + */ + struct DeviceInfo { + pxcCHAR name[256]; /* device name */ + pxcCHAR did[256]; /* device identifier or the device symbolic name */ + pxcI32 reserved[16]; + }; + + /** + @brief Scan the availble audio devices. + */ + virtual void PXCAPI ScanDevices(void)=0; + + /** + @brief Get the number of available audio devices previously scanned. + @return the number of audio devices. + */ + virtual pxcI32 PXCAPI QueryDeviceNum(void)=0; + + /** + @brief Enumerate the audio devices previously scanned. + @param[in] didx The zero-based index to enumerate all devices. + @param[out] dinfo The DeviceInfo structure to return the device information. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No more devices. + */ + virtual pxcStatus PXCAPI QueryDeviceInfo(pxcI32 didx, DeviceInfo *dinfo)=0; + + /** + @brief Get the currnet working device + @param[out] dinfo The working device info + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus QueryDeviceInfo(DeviceInfo *dinfo) { + return QueryDeviceInfo(WORKING_PROFILE, dinfo); + } + + /** + @brief Set the audio device for subsequent module processing. + @param[in] dinfo The audio source + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetDevice(DeviceInfo *dinfo)=0; + + /** + @brief Get the audio device volume + @return the volume from 0 (min) to 1 (max). + */ + virtual pxcF32 PXCAPI QueryVolume(void)=0; + + /** + @brief Set the audio device volume + @param volume The audio volume from 0 (min) to 1 (max). + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetVolume(pxcF32 volume)=0; +}; diff --git a/modules/control/rssdk/rssdk/pxcbase.h b/modules/control/rssdk/rssdk/pxcbase.h new file mode 100644 index 0000000..6e86ee4 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcbase.h @@ -0,0 +1,192 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2013 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcbase.h + Defines PXCBase, the base interface for all SDK interfaces + */ +#pragma once +#include "pxcdefs.h" +#include "pxcstatus.h" + +#define PXCAPI __stdcall + +/////////////////////////////////////////////////////////////////////////////////////// +/** + This interface forms the base of all SDK interface definitions. + The interface overrides the class delete operator to work with the SDK + dispatching mechanism; and exposes a custom (RTTI-free) dynaimc casting + mechanism with the QueryInstance method. The application that implements + any PXCBase derived interface must derive from one of the PXCBaseImpl + class templates. + */ +class PXCBase { +public: + enum { CUID=0 }; + enum { WORKING_PROFILE=0xffffffff }; + + /** + @brief The function checks if the object instance supports a specific interface. + If so, return the instance of the interface. Otherwise, returns NULL. + @param[in] cuid The interface identifier. + @return The interface instance, or NULL. + */ + virtual void* PXCAPI QueryInstance(pxcUID cuid) = 0; + + /** + @brief The function checks if the object instance supports a specific interface. + If so, return the instance of the interface. Otherwise, returns NULL. + @return The interface instance, or NULL. + */ + template T* QueryInstance(void) { return (T*)this->QueryInstance(T::CUID); } + + /** + @brief The function releases the object instance. Certain objects are reference + counted, in which case the function reduces the reference count by 1. + */ + virtual void PXCAPI Release(void) = 0; + + /** + @brief The base constructor. + */ + PXCBase(void) {} + +private: + /* Call Release() to delele object */ + void operator delete(void* pthis); + /* Prohibit using copy & assignment constructors */ + PXCBase(PXCBase const &); + PXCBase& operator = (PXCBase const &); +}; + +#define PXC_CUID_OVERWRITE(X) enum { CUID=X } + +/////////////////////////////////////////////////////////////////////////////////////// +/** + This template class contains a default implementation of the PXCBase + interface. The application that implements any PXCBase derived interface, + such as a callback handler, should derive the implementation from this + template class. See the SDK Interface section (in the sdkcore manual) + for details. The PXCBaseImpl template assumes single inheritance. + The variations, PXCBaseImpl2 and PXCBaseImpl3, implement two or three + inheritances, respectively. +*/ +template +class PXCBaseImpl:public T { +public: + + virtual ~PXCBaseImpl(void) {} + enum { CUID=T::CUID+1 }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T::CUID) return (T*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; + +/** See PXCBaseImpl */ +template +class PXCBaseImpl2:public T1, public T2 { +public: + + virtual ~PXCBaseImpl2(void) {} + enum { CUID = T1::CUID ^ T2::CUID }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T1::CUID) return (T1*)this; + if (cuid==T2::CUID) return (T2*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)(T1*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; + +/** See PXCBaseImpl */ +template +class PXCBaseImpl3:public T1, public T2, public T3 { +public: + + virtual ~PXCBaseImpl3(void) {} + enum { CUID = T1::CUID ^ T2::CUID ^ T3::CUID }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T1::CUID) return (T1*)this; + if (cuid==T2::CUID) return (T2*)this; + if (cuid==T3::CUID) return (T3*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)(T1*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; + +/** See PXCBaseImpl */ +template +class PXCBaseImpl4:public T1, public T2, public T3, public T4 { +public: + + virtual ~PXCBaseImpl4(void) {} + enum { CUID = T1::CUID ^ T2::CUID ^ T3::CUID ^ T4::CUID }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T1::CUID) return (T1*)this; + if (cuid==T2::CUID) return (T2*)this; + if (cuid==T3::CUID) return (T3*)this; + if (cuid==T4::CUID) return (T4*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)(T1*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; + +/** See PXCBaseImpl */ +template +class PXCBaseImpl5:public T1, public T2, public T3, public T4, public T5 { +public: + + virtual ~PXCBaseImpl5(void) {} + enum { CUID = T1::CUID ^ T2::CUID ^ T3::CUID ^ T4::CUID ^ T5::CUID }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T1::CUID) return (T1*)this; + if (cuid==T2::CUID) return (T2*)this; + if (cuid==T3::CUID) return (T3*)this; + if (cuid==T4::CUID) return (T4*)this; + if (cuid==T5::CUID) return (T5*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)(T1*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; + +template +class PXCBaseImpl6:public T1, public T2, public T3, public T4, public T5, public T6 { +public: + + virtual ~PXCBaseImpl6(void) {} + enum { CUID = T1::CUID ^ T2::CUID ^ T3::CUID ^ T4::CUID ^ T5::CUID ^ T6::CUID }; + virtual void* PXCAPI QueryInstance(pxcUID cuid) { + if (cuid==CUID) return this; + if (cuid==T1::CUID) return (T1*)this; + if (cuid==T2::CUID) return (T2*)this; + if (cuid==T3::CUID) return (T3*)this; + if (cuid==T4::CUID) return (T4*)this; + if (cuid==T5::CUID) return (T5*)this; + if (cuid==T6::CUID) return (T6*)this; + if (cuid==PXCBase::CUID) return (PXCBase*)(T1*)this; + return 0; + } + virtual void PXCAPI Release(void) { ::delete this; } + void operator delete(void* pthis) { ::delete(pthis); } +}; diff --git a/modules/control/rssdk/rssdk/pxccapture.h b/modules/control/rssdk/rssdk/pxccapture.h new file mode 100644 index 0000000..384b0d6 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxccapture.h @@ -0,0 +1,984 @@ + /******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxccapture.h + Defines the PXCCapture interface, which allows a program create and interact + with video streams. + */ +#pragma once +#include "pxcimage.h" +#include "pxcsyncpoint.h" +#pragma warning(push) +#pragma warning(disable:4351) /* new behavior of array initialization */ +class PXCCaptureDeviceExt; +class PXCProjection; + +/** + This interface provides member functions to create instances of and query stream capture devices. +*/ +class PXCCapture:public PXCBase { +public: + PXC_CUID_OVERWRITE(0x83F72A50); + PXC_DEFINE_CONST(STREAM_LIMIT,8); + class Device; + + /** + @enum StreamType + Bit-OR'ed values of stream types, physical or virtual streams. + */ + enum StreamType { + STREAM_TYPE_ANY = 0, /* Unknown/undefined type */ + STREAM_TYPE_COLOR = 0x0001, /* the color stream type */ + STREAM_TYPE_DEPTH = 0x0002, /* the depth stream type */ + STREAM_TYPE_IR = 0x0004, /* the infrared stream type */ + STREAM_TYPE_LEFT = 0x0008, /* the stereoscopic left intensity image */ + STREAM_TYPE_RIGHT = 0x0010, /* the stereoscopic right intensity image */ + }; + + /** + @brief Get the stream type string representation + @param[in] type The stream type + @return The corresponding string representation. + **/ + __inline static const pxcCHAR *StreamTypeToString(StreamType type) { + switch (type) { + case STREAM_TYPE_COLOR: return L"Color"; + case STREAM_TYPE_DEPTH: return L"Depth"; + case STREAM_TYPE_IR: return L"IR"; + case STREAM_TYPE_LEFT: return L"Left"; + case STREAM_TYPE_RIGHT: return L"Right"; + } + return L"Unknown"; + } + + /** + @brief Get the stream type from an index number + @param[in] index The stream index + @return The corresponding stream type. + **/ + __inline static StreamType StreamTypeFromIndex(pxcI32 index) { + if (index<0 || index>=STREAM_LIMIT) return STREAM_TYPE_ANY; + return (StreamType)(1<1) type=(StreamType)(type>>1), s++; + return s; + } + + /** + @enum DeviceModel + Describes the device model + */ + enum DeviceModel { + DEVICE_MODEL_GENERIC = 0x00000000, /* a generic device or unknown device */ + DEVICE_MODEL_IVCAM = 0x0020000E, /* the Intel(R) RealSense(TM) 3D Camera */ + }; + + /** + @enum DeviceOrientation + Describes the device orientation + */ + enum DeviceOrientation { + DEVICE_ORIENTATION_ANY = 0x0, /* Unknown orientation */ + DEVICE_ORIENTATION_USER_FACING = 0x1, /* A user facing camera */ + DEVICE_ORIENTATION_WORLD_FACING = 0x2, /* A world facing camera */ + }; + + /** + Describe device details. + */ + struct DeviceInfo { + pxcCHAR name[224]; /* device name */ + pxcCHAR serial[32]; /* serial number */ + pxcCHAR did[256]; /* device identifier or the device symbolic name */ + pxcI32 firmware[4]; /* firmware version: limit to four parts of numbers */ + PXCPointF32 location; /* device location in mm from the left bottom of the display panel. */ + DeviceModel model; /* device model */ + DeviceOrientation orientation; /* device orientation */ + StreamType streams; /* bit-OR'ed value of device stream types. */ + pxcI32 didx; /* device index */ + pxcI32 duid; /* device unique identifier within the SDK session */ + pxcI32 reserved[13]; + + /** + @brief Get the available stream numbers. + @return the number of streams. + */ + __inline pxcI32 QueryStreamNum(void) { + pxcI32 nstreams=0; + for (pxcI32 i=0,j=1;i=0;i--,j>>=1) + if (type&j) return reserved[i]; + return reserved[sizeof(reserved)/sizeof(reserved[0])-1]; + } + + /** + @brief Release the sample elements if not NULL + */ + __inline void ReleaseImages(void) { + if (color) color->Release(), color=0; + if (depth) depth->Release(), depth=0; + if (ir) ir->Release(), ir=0; + if (left) left->Release(), left=0; + if (right) right->Release(), right=0; + for (int i=0;iRelease(), reserved[i]=0; + } + + /** + @brief The constructor zeros the image instance array + */ + __inline Sample(void):color(0),depth(0),ir(0),left(0),right(0),reserved() { + } + }; + + /** + This is the video device interface. + Use the member functions to interface with the video capture device. + */ + class Device : public PXCBase { + friend class PXCCaptureDeviceExt; + public: + + PXC_CUID_OVERWRITE(0x938401C4); + + /** + @enum PowerLineFrequency + Describes the power line compensation filter values. + */ + enum PowerLineFrequency { + POWER_LINE_FREQUENCY_DISABLED = 0, /* Disabled power line frequency */ + POWER_LINE_FREQUENCY_50HZ = 50, /* 50HZ power line frequency */ + POWER_LINE_FREQUENCY_60HZ = 60, /* 60HZ power line frequency */ + }; + + /** + @enum MirrorMode + Describes the mirroring options. + */ + enum MirrorMode { + MIRROR_MODE_DISABLED = 0, /* Disabled. The images are displayed as in a world facing camera. */ + MIRROR_MODE_HORIZONTAL = 1, /* The images are horizontally mirrored as in a user facing camera. */ + }; + + /** + @enum IVCAMAccuracy + Describes the IVCAM accuracy. + */ + enum IVCAMAccuracy { + IVCAM_ACCURACY_FINEST = 1, /* The finest accuracy: 9 patterns */ + IVCAM_ACCURACY_MEDIAN = 2, /* The median accuracy: 8 patterns (default) */ + IVCAM_ACCURACY_COARSE = 3, /* The coarse accuracy: 7 patterns */ + }; + + /** + @enum Property + Describes the device properties. + Use the inline functions to access specific device properties. + */ + enum Property { + /* Color Stream Properties */ + PROPERTY_COLOR_EXPOSURE = 1, /* pxcI32 RW The color stream exposure, in log base 2 seconds. */ + PROPERTY_COLOR_BRIGHTNESS = 2, /* pxcI32 RW The color stream brightness from -10,000 (pure black) to 10,000 (pure white). */ + PROPERTY_COLOR_CONTRAST = 3, /* pxcI32 RW The color stream contrast, from 0 to 10,000. */ + PROPERTY_COLOR_SATURATION = 4, /* pxcI32 RW The color stream saturation, from 0 to 10,000. */ + PROPERTY_COLOR_HUE = 5, /* pxcI32 RW The color stream hue, from -180,000 to 180,000 (representing -180 to 180 degrees.) */ + PROPERTY_COLOR_GAMMA = 6, /* pxcI32 RW The color stream gamma, from 1 to 500. */ + PROPERTY_COLOR_WHITE_BALANCE = 7, /* pxcI32 RW The color stream balance, as a color temperature in degrees Kelvin. */ + PROPERTY_COLOR_SHARPNESS = 8, /* pxcI32 RW The color stream sharpness, from 0 to 100. */ + PROPERTY_COLOR_BACK_LIGHT_COMPENSATION = 9, /* pxcBool RW The color stream back light compensation. */ + PROPERTY_COLOR_GAIN = 10, /* pxcI32 RW The color stream gain adjustment, with negative values darker, positive values brighter, and zero as normal. */ + PROPERTY_COLOR_POWER_LINE_FREQUENCY = 11, /* pxcI32 RW The power line frequency in Hz. */ + PROPERTY_COLOR_FIELD_OF_VIEW = 1000, /* PXCPointF32 R The color-sensor horizontal and vertical field of view parameters, in degrees. */ + PROPERTY_COLOR_SENSOR_RANGE = 1002, /* PXCRangeF32 R The color-sensor, sensing distance parameters, in millimeters. */ + PROPERTY_COLOR_FOCAL_LENGTH = 1006, /* PXCPointF32 R The color-sensor focal length in pixels. The parameters vary with the resolution setting. */ + PROPERTY_COLOR_PRINCIPAL_POINT = 1008, /* PXCPointF32 R The color-sensor principal point in pixels. The parameters vary with the resolution setting. */ + + /* Depth Stream Properties */ + PROPERTY_DEPTH_SATURATION_VALUE = 200, /* pxcU16 R The special depth map value to indicate that the corresponding depth map pixel is saturated. */ + PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE = 201, /* pxcU16 R The special depth map value to indicate that the corresponding depth map pixel is of low-confidence. */ + PROPERTY_DEPTH_CONFIDENCE_THRESHOLD = 202, /* pxcI16 RW The confidence threshold that is used to floor the depth map values. The range is from 1 to 32767. */ + PROPERTY_DEPTH_UNIT = 204, /* pxcI32 R The unit of depth values in micrometer, or mm. */ + PROPERTY_DEPTH_FIELD_OF_VIEW = 2000, /* PXCPointF32 R The depth-sensor horizontal and vertical field of view parameters, in degrees. */ + PROPERTY_DEPTH_SENSOR_RANGE = 2002, /* PXCRangeF32 R The depth-sensor, sensing distance parameters, in millimeters. */ + PROPERTY_DEPTH_FOCAL_LENGTH = 2006, /* PXCPointF32 R The depth-sensor focal length in pixels. The parameters vary with the resolution setting. */ + PROPERTY_DEPTH_PRINCIPAL_POINT = 2008, /* PXCPointF32 R The depth-sensor principal point in pixels. The parameters vary with the resolution setting. */ + + /* Device Properties */ + PROPERTY_DEVICE_ALLOW_PROFILE_CHANGE = 302, /* pxcBool RW If true, allow resolution change and throw PXC_STATUS_STREAM_CONFIG_CHANGED */ + PROPERTY_DEVICE_MIRROR = 304, /* MirrorMode RW The mirroring options. */ + + /* Misc. Properties */ + PROPERTY_PROJECTION_SERIALIZABLE = 3003, /* pxcU32 R The meta data identifier of the Projection instance serialization data. */ + + /* Device Specific Properties */ + PROPERTY_IVCAM_LASER_POWER = 0x10000, /* pxcI32 RW The laser power value from 0 (minimum) to 16 (maximum). */ + PROPERTY_IVCAM_ACCURACY = 0x10001, /* IVCAMAccuracy RW The IVCAM accuracy value. */ + PROPERTY_IVCAM_FILTER_OPTION = 0x10003, /* pxcI32 RW The filter option (smoothing aggressiveness) ranged from 0 (close range) to 7 (far range). */ + PROPERTY_IVCAM_MOTION_RANGE_TRADE_OFF= 0x10004, /* pxcI32 RW This option specifies the motion and range trade off. The value ranged from 0 (short exposure, range, and better motion) to 100 (long exposure, range). */ + + /* Customized properties */ + PROPERTY_CUSTOMIZED=0x04000000, /* CUSTOMIZED properties */ + }; + + /** + @brief Return the device information + @param[in] pointer to the DeviceInfo structure, to be returned. + */ + virtual void PXCAPI QueryDeviceInfo(DeviceInfo *dinfo)=0; + + /** + @brief Return the instance of the PXCProjection interface. Must be called after initialization. + @return the PXCProjection instance. + */ + virtual PXCProjection* PXCAPI CreateProjection(void)=0; + + /** + @structure StreamProfile + Describes the video stream configuration parameters + */ + struct StreamProfile { + PXCImage::ImageInfo imageInfo; /* resolution and color format */ + PXCRangeF32 frameRate; /* frame rate range. Set max when configuring FPS */ + pxcI32 reserved[6]; + }; + + /** + @structure StreamProfileSet + The set of StreamProfile that describes the configuration parameters of all streams. + */ + struct StreamProfileSet { + StreamProfile color; + StreamProfile depth; + StreamProfile ir; + StreamProfile left; + StreamProfile right; + StreamProfile reserved[STREAM_LIMIT-5]; + + /** + @brief Access the configuration parameters by the stream type. + @param[in] type The stream type. + @return The StreamProfile instance. + */ + __inline StreamProfile &operator[](StreamType type) { + if (type==STREAM_TYPE_COLOR) return color; + if (type==STREAM_TYPE_DEPTH) return depth; + if (type==STREAM_TYPE_IR) return ir; + if (type==STREAM_TYPE_LEFT) return left; + if (type==STREAM_TYPE_RIGHT) return right; + for (int i=sizeof(reserved)/sizeof(reserved[0])-1,j=(1<<(STREAM_LIMIT-1));i>=0;i--,j>>=1) + if (type&j) return reserved[i]; + return reserved[sizeof(reserved)/sizeof(reserved[0])-1]; + } + }; + + /** + @brief Return the number of valid stream configurations for the streams of interest. + @param[in] scope The bit-OR'ed value of stream types of interest. + @return the number of valid profile combinations. + */ + virtual pxcI32 PXCAPI QueryStreamProfileSetNum(StreamType scope)=0; + + /** + @brief Return the unique configuration parameters for the selected video streams (types). + @param[in] scope The bit-OR'ed value of stream types of interest. + @param[in] index Zero-based index to retrieve all valid profiles. + @param[out] profiles The stream profile set. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE index out of range. + */ + virtual pxcStatus PXCAPI QueryStreamProfileSet(StreamType scope, pxcI32 index, StreamProfileSet *profiles)=0; + + /** + @brief Return the active stream configuration parameters (during streaming). + @param[out] profiles The stream profile set, to be returned. + @return PXC_STATUS_NO_ERROR successful execution. + */ + __inline pxcStatus QueryStreamProfileSet(StreamProfileSet *profiles) { + return QueryStreamProfileSet(STREAM_TYPE_ANY, WORKING_PROFILE, profiles); + } + + /** + @brief Check if stream profile set is valid. + @param[in] profiles The stream profile set to check + @return true stream profile is valid. + @return false stream profile is invalid. + */ + virtual pxcBool PXCAPI IsStreamProfileSetValid (StreamProfileSet *profiles)=0; + + /** + @brief Set the active profile for the all video streams. The application must configure all streams before streaming. + @param[in] profiles The stream profile set. + @return PXC_STATUS_NO_ERROR successful execution. + */ + virtual pxcStatus PXCAPI SetStreamProfileSet(StreamProfileSet *profiles)=0; + + /** + @brief Read the selected streams asynchronously. The function returns immediately. The application must + synchronize sync point to get the stream samples. The application can read more than a single stream using + the scope parameter, provided that all streams have the same frame rate. Otherwise, the function will return error. + @param[in] scope The bit-OR'ed value of stream types of interest. + @param[in] sample The output sample. + @param[in] sp The pointer to the sync point to be returned. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_DEVICE_LOST the device is disconnected. + @return PXC_STATUS_PARAM_UNSUPPORTED the streams are of different frame rates. + */ + virtual pxcStatus PXCAPI ReadStreamsAsync(StreamType scope, Sample *sample, PXCSyncPoint **sp)=0; + + /** + @brief Read the all configured streams asynchronously. The function returns immediately. The application must + synchronize sync point to get the stream samples. The configured streams must have the same frame rate or + the function will return error. + @param[in] sample The output sample. + @param[in] sp The pointer to the SP to be returned. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_DEVICE_LOST the device is disconnected. + @return PXC_STATUS_PARAM_UNSUPPORTED the streams are of different frame rates. + */ + __inline pxcStatus ReadStreamsAsync(Sample *sample, PXCSyncPoint **sp) { + return ReadStreamsAsync(STREAM_TYPE_ANY, sample, sp); + } + + /** + @brief Read the selected streams synchronously. The function blocks until all stream samples are ready. + The application can read more than a single stream using the scope parameter, provided that all streams + have the same frame rate. Otherwise, the function will return error. + @param[in] scope The bit-OR'ed value of stream types of interest. + @param[in] sample The output sample. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_DEVICE_LOST the device is disconnected. + @return PXC_STATUS_PARAM_UNSUPPORTED the streams are of different frame rates. + */ + __inline pxcStatus PXCAPI ReadStreams(StreamType scope, Sample *sample) { + PXCSyncPoint *sp; + pxcStatus sts=ReadStreamsAsync(scope, sample, &sp); + if (stsSynchronize(); + sp->Release(); + return sts; + } + + protected: + + /** + @reserved + Internal function. Do not use. + */ + virtual pxcStatus PXCAPI QueryProperty(Property /*label*/, pxcF32 * /*value*/)=0; + + /** + @reserved + Internal function. Do not use. + */ + virtual pxcStatus PXCAPI SetPropertyAuto(Property /*pty*/, pxcBool /*ifauto*/)=0; + + /** + @reserved + Internal function. Do not use. + */ + virtual pxcStatus PXCAPI SetProperty(Property /*pty*/, pxcF32 /*value*/)=0; + + public: + + /** + @brief Get the color stream exposure value. + @return The color stream exposure, in log base 2 seconds. + */ + __inline pxcI32 QueryColorExposure(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_EXPOSURE,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream exposure value. + @param[in] value The color stream exposure value, in log base 2 seconds. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorExposure(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_EXPOSURE,(pxcF32)value); + } + + /** + @brief Set the color stream exposure value. + @param[in] auto1 True to enable auto exposure. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorAutoExposure(pxcBool auto1) { + return SetPropertyAuto(PROPERTY_COLOR_EXPOSURE,auto1?1:0); + } + + /** + @brief Get the color stream brightness value. + @return The color stream brightness from -10,000 (pure black) to 10,000 (pure white). + */ + __inline pxcI32 QueryColorBrightness(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_BRIGHTNESS,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream brightness value. + @param[in] value The color stream brightness from -10,000 (pure black) to 10,000 (pure white). + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorBrightness(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_BRIGHTNESS,(pxcF32)value); + } + + /** + @brief Get the color stream contrast value. + @return The color stream contrast, from 0 to 10,000. + */ + __inline pxcI32 QueryColorContrast(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_CONTRAST,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream contrast value. + @param[in] value The color stream contrast, from 0 to 10,000. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorContrast(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_CONTRAST,(pxcF32)value); + } + + /** + @brief Get the color stream saturation value. + @return The color stream saturation, from 0 to 10,000. + */ + __inline pxcI32 QueryColorSaturation(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_SATURATION,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream saturation value. + @param[in] value The color stream saturation, from 0 to 10,000. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorSaturation(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_SATURATION,(pxcF32)value); + } + + /** + @brief Get the color stream hue value. + @return The color stream hue, from -180,000 to 180,000 (representing -180 to 180 degrees.) + */ + __inline pxcI32 QueryColorHue(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_HUE,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream hue value. + @param[in] value The color stream hue, from -180,000 to 180,000 (representing -180 to 180 degrees.) + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorHue(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_HUE,(pxcF32)value); + } + + /** + @brief Get the color stream gamma value. + @return The color stream gamma, from 1 to 500. + */ + __inline pxcI32 QueryColorGamma(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_GAMMA,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream gamma value. + @param[in] value The color stream gamma, from 1 to 500. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorGamma(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_GAMMA,(pxcF32)value); + } + + /** + @brief Get the color stream white balance value. + @return The color stream balance, as a color temperature in degrees Kelvin. + */ + __inline pxcI32 QueryColorWhiteBalance(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_WHITE_BALANCE,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream white balance value. + @param[in] value The color stream balance, as a color temperature in degrees Kelvin. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorWhiteBalance(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_WHITE_BALANCE,(pxcF32)value); + } + + /** + @brief Set the color stream auto white balance mode. + @param[in] auto1 The flag if the auto is enabled or not. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorAutoWhiteBalance(pxcBool auto1) { + return SetPropertyAuto(PROPERTY_COLOR_WHITE_BALANCE,auto1); + } + + /** + @brief Get the color stream sharpness value. + @return The color stream sharpness, from 0 to 100. + */ + __inline pxcI32 QueryColorSharpness(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_SHARPNESS,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream sharpness value. + @param[in] value The color stream sharpness, from 0 to 100. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorSharpness(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_SHARPNESS,(pxcF32)value); + } + + /** + @brief Get the color stream back light compensation status. + @return The color stream back light compensation status. + */ + __inline pxcBool QueryColorBackLightCompensation(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_BACK_LIGHT_COMPENSATION,&value); + return value!=0; + } + + /** + @brief Set the color stream back light compensation status. + @param[in] value The color stream back light compensation status. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorBackLightCompensation(pxcBool value) { + return SetProperty(PROPERTY_COLOR_BACK_LIGHT_COMPENSATION,(pxcF32)(value!=0)); + } + + /** + @brief Get the color stream gain value. + @return The color stream gain adjustment, with negative values darker, positive values brighter, and zero as normal. + */ + __inline pxcI32 QueryColorGain(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_GAIN,&value); + return (pxcI32)value; + } + + /** + @brief Set the color stream gain value. + @param[in] value The color stream gain adjustment, with negative values darker, positive values brighter, and zero as normal. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorGain(pxcI32 value) { + return SetProperty(PROPERTY_COLOR_GAIN,(pxcF32)value); + } + + /** + @brief Get the color stream power line frequency value. + @return The power line frequency in Hz. + */ + __inline PowerLineFrequency QueryColorPowerLineFrequency(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_COLOR_POWER_LINE_FREQUENCY,&value); + return (PowerLineFrequency)(pxcI32)value; + } + + /** + @brief Set the color stream power line frequency value. + @param[in] value The power line frequency in Hz. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetColorPowerLineFrequency(PowerLineFrequency value) { + return SetProperty(PROPERTY_COLOR_POWER_LINE_FREQUENCY,(pxcF32)value); + } + + /** + @brief Get the color stream field of view. + @return The color-sensor horizontal and vertical field of view parameters, in degrees. + */ + __inline PXCPointF32 QueryColorFieldOfView(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_COLOR_FIELD_OF_VIEW,&value.x); + QueryProperty((Property)(PROPERTY_COLOR_FIELD_OF_VIEW+1),&value.y); + return value; + } + + /** + @brief Get the color stream sensor range. + @return The color-sensor, sensing distance parameters, in millimeters. + */ + __inline PXCRangeF32 QueryColorSensorRange(void) { + PXCRangeF32 value={0,0}; + QueryProperty(PROPERTY_COLOR_SENSOR_RANGE,&value.min); + QueryProperty((Property)(PROPERTY_COLOR_SENSOR_RANGE+1),&value.max); + return value; + } + + /** + @brief Get the color stream focal length. + @return The color-sensor focal length in pixels. The parameters vary with the resolution setting. + */ + __inline PXCPointF32 QueryColorFocalLength(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_COLOR_FOCAL_LENGTH,&value.x); + QueryProperty((Property)(PROPERTY_COLOR_FOCAL_LENGTH+1),&value.y); + return value; + } + + /** + @brief Get the color stream principal point. + @return The color-sensor principal point in pixels. The parameters vary with the resolution setting. + */ + __inline PXCPointF32 QueryColorPrincipalPoint(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_COLOR_PRINCIPAL_POINT,&value.x); + QueryProperty((Property)(PROPERTY_COLOR_PRINCIPAL_POINT+1),&value.y); + return value; + } + + /** + @brief Get the depth stream saturation value. + @return The special depth map value to indicate that the corresponding depth map pixel is saturated. + */ + __inline pxcU16 QueryDepthSaturationValue(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEPTH_SATURATION_VALUE,&value); + return (pxcU16)value; + } + + /** + @brief Get the depth stream low confidence value. + @return The special depth map value to indicate that the corresponding depth map pixel is of low-confidence. + */ + __inline pxcU16 QueryDepthLowConfidenceValue(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE,&value); + return (pxcU16)value; + } + + /** + @brief Set the depth stream low confidence value. + @param[in] value The special depth map value to indicate that the corresponding depth map pixel is of low-confidence. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetDepthLowConfidenceValue(pxcU16 value) { + return SetProperty(PROPERTY_DEPTH_LOW_CONFIDENCE_VALUE,(pxcF32)value); + } + + /** + @brief Get the depth stream confidence threshold. + @return The confidence threshold that is used to floor the depth map values. The range is from 1 to 32767. + */ + __inline pxcI16 QueryDepthConfidenceThreshold(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEPTH_CONFIDENCE_THRESHOLD,&value); + return (pxcI16)value; + } + + /** + @brief Set the depth stream confidence threshold. + @param[in] value The confidence threshold that is used to floor the depth map values. The range is from 1 to 32767. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetDepthConfidenceThreshold(pxcI16 value) { + return SetProperty(PROPERTY_DEPTH_CONFIDENCE_THRESHOLD, (pxcF32)value); + } + + /** + @brief Get the depth stream unit value. + @return The unit of depth values in micrometre. + */ + __inline pxcI32 QueryDepthUnit(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEPTH_UNIT,&value); + return (pxcI32)value; + } + + /** + @brief Get the depth stream field of view. + @return The depth-sensor horizontal and vertical field of view parameters, in degrees. + */ + __inline PXCPointF32 QueryDepthFieldOfView(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_DEPTH_FIELD_OF_VIEW,&value.x); + QueryProperty((Property)(PROPERTY_DEPTH_FIELD_OF_VIEW+1),&value.y); + return value; + } + + /** + @brief Get the depth stream sensor range. + @return The depth-sensor, sensing distance parameters, in millimeters. + */ + __inline PXCRangeF32 QueryDepthSensorRange(void) { + PXCRangeF32 value={0,0}; + QueryProperty(PROPERTY_DEPTH_SENSOR_RANGE,&value.min); + QueryProperty((Property)(PROPERTY_DEPTH_SENSOR_RANGE+1),&value.max); + return value; + } + + /** + @brief Get the depth stream focal length. + @return The depth-sensor focal length in pixels. The parameters vary with the resolution setting. + */ + __inline PXCPointF32 QueryDepthFocalLength(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_DEPTH_FOCAL_LENGTH,&value.x); + QueryProperty((Property)(PROPERTY_DEPTH_FOCAL_LENGTH+1),&value.y); + return value; + } + + /** + @brief Get the depth stream principal point. + @return The depth-sensor principal point in pixels. The parameters vary with the resolution setting. + */ + __inline PXCPointF32 QueryDepthPrincipalPoint(void) { + PXCPointF32 value={0,0}; + QueryProperty(PROPERTY_DEPTH_PRINCIPAL_POINT,&value.x); + QueryProperty((Property)(PROPERTY_DEPTH_PRINCIPAL_POINT+1),&value.y); + return value; + } + + /** + @brief Get the device allow profile change status. + @return If true, allow resolution change and throw PXC_STATUS_STREAM_CONFIG_CHANGED. + */ + __inline pxcBool QueryDeviceAllowProfileChange(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEVICE_ALLOW_PROFILE_CHANGE,&value); + return value!=0; + } + + /** + @brief Set the device allow profile change status. + @param[in] value If true, allow resolution change and throw PXC_STATUS_STREAM_CONFIG_CHANGED. + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetDeviceAllowProfileChange(pxcBool value) { + return SetProperty(PROPERTY_DEVICE_ALLOW_PROFILE_CHANGE, (pxcF32)(value!=0)); + } + + /** + @brief Get the mirror mode. + @return The mirror mode + */ + __inline MirrorMode QueryMirrorMode(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_DEVICE_MIRROR,&value); + return (MirrorMode)(pxcI32)value; + } + + /** + @brief Set the mirror mode. + @param[in] value The mirror mode + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetMirrorMode(MirrorMode value) { + return SetProperty(PROPERTY_DEVICE_MIRROR,(pxcF32)value); + } + + /** + @brief Get the IVCAM laser power. + @return The laser power value from 0 (minimum) to 16 (maximum). + */ + __inline pxcI32 QueryIVCAMLaserPower(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_IVCAM_LASER_POWER,&value); + return (pxcI32)value; + } + + /** + @brief Set the IVCAM laser power. + @param[in] value The laser power value from 0 (minimum) to 16 (maximum). + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetIVCAMLaserPower(pxcI32 value) { + return SetProperty(PROPERTY_IVCAM_LASER_POWER,(pxcF32)value); + } + + /** + @brief Get the IVCAM accuracy. + @return The accuracy value + */ + __inline IVCAMAccuracy QueryIVCAMAccuracy(void) { + pxcF32 value=0; + QueryProperty(PROPERTY_IVCAM_ACCURACY,&value); + return (IVCAMAccuracy)(pxcI32)value; + } + + /** + @brief Set the IVCAM accuracy. + @param[in] value The accuracy value + @return PXC_STATUS_NO_ERROR successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE the device property is not supported. + */ + __inline pxcStatus SetIVCAMAccuracy(IVCAMAccuracy value) { + return SetProperty(PROPERTY_IVCAM_ACCURACY,(pxcF32)value); + } + + /** + @brief Get the IVCAM filter option (smoothing aggressiveness) ranged from 0 (close range) to 7 (far range). + @return The filter option value. + */ + __inline pxcI32 QueryIVCAMFilterOption(void) { + pxcF32 value=0; + pxcStatus sts=QueryProperty(PROPERTY_IVCAM_FILTER_OPTION,&value); + if (sts +#include "pxccapture.h" +#include "pxcvideomodule.h" + +/** + The CaptureManager interface provides the following features: + (1) Locate an I/O device that meets all module input needs. + (2) Record any streamming data to a file and playback from the file. +*/ +class PXCCaptureManager: public PXCBase { +public: + PXC_CUID_OVERWRITE(0xD8912345); + + /** + This is the PXCCaptureManager callback interface. + */ + class Handler { + public: + /** + @brief The CaptureManager callbacks this function when creating a device instance. + @param[in] mdesc The I/O module descriptor. + @param[in] device The device instance. + @return The CaptureManager aborts the device match if the status is an error. + */ + virtual pxcStatus PXCAPI OnCreateDevice(PXCSession::ImplDesc* /*mdesc*/, PXCCapture::Device* /*device*/) { + return PXC_STATUS_NO_ERROR; + } + + /** + @brief The CaptureManager callbacks this function when configuring the device streams. + @param[in] device The device instance. + @param[in] types The bit-OR'ed value of all streams. + @return The CaptureManager aborts the device match if the status is an error. + */ + virtual pxcStatus PXCAPI OnSetupStreams(PXCCapture::Device* /*device*/, PXCCapture::StreamType types) { + return PXC_STATUS_NO_ERROR; + } + + /** + @brief The CaptureManager callbacks this function when the current device failed to + meet the algorithm needs. If the function returns any error, the CaptureManager performs + the current device match again, allowing to try multple configurations on the same device. + @param[in] device The device instance. + @return The CaptureManager repeats the match on the same device if the status code is any + error, or go onto the next device if the status code is no error. + */ + virtual pxcStatus PXCAPI OnNextDevice(PXCCapture::Device*) { return PXC_STATUS_NO_ERROR; } + }; + + /** + @brief The functinon adds the specified DeviceInfo to the DeviceInfo filter list. + @param[in] dinfo The DeviceInfo structure to be added to the filter list, or NULL to clean up the filter list. + */ + virtual void PXCAPI FilterByDeviceInfo(PXCCapture::DeviceInfo *dinfo)=0; + + /** + @brief The functinon adds the specified device information to the DeviceInfo filter list. + @param[in] name The optional device friendly name. + @param[in] did The optional device symbolic name. + @param[in] didx The optional device index. + */ + void __inline FilterByDeviceInfo(pxcCHAR *name, pxcCHAR *did, pxcI32 didx) { + PXCCapture::DeviceInfo dinfo; + memset(&dinfo,0,sizeof(dinfo)); + if (name) wcscpy_s(dinfo.name,name); + if (did) wcscpy_s(dinfo.did,did); + dinfo.didx=didx; + FilterByDeviceInfo(&dinfo); + } + + /** + @brief The functinon adds the specified StreamProfile to the StreamProfile filter list. + @param[in] dinfo The stream configuration to be added to the filter list, or NULL to clean up the filter list. + */ + virtual void PXCAPI FilterByStreamProfiles(PXCCapture::Device::StreamProfileSet *profiles)=0; + + /** + @brief The functinon adds the specified StreamProfile to the StreamProfile filter list. + @param[in] type The stream type. + @param[in] width The optional image width. + @param[in] height The optional image height. + @param[in] fps The optional frame rate. + */ + void __inline FilterByStreamProfiles(PXCCapture::StreamType type, pxcI32 width, pxcI32 height, pxcF32 fps) { + PXCCapture::Device::StreamProfileSet profiles={}; + profiles[type].imageInfo.width=width; + profiles[type].imageInfo.height=height; + profiles[type].frameRate.min=profiles[type].frameRate.max=fps; + FilterByStreamProfiles(&profiles); + } + + /** + @brief Add the module input needs to the CaptureManager device search. The application must call + this function for all modules before the LocalStreams function, where the CaptureManager performs + the device match. + @param[in] mid The module identifier. The application can use any unique value to later identify the module. + @param[in] inputs The module input descriptor. + @return PXC_STATUS_NO_ERROR Successful executation. + */ + virtual pxcStatus PXCAPI RequestStreams(pxcUID mid, PXCVideoModule::DataDesc *inputs)=0; + + /** + @brief The function locates an I/O device that meets any module input needs previously specified + by the RequestStreams function. The device and its streams are configured upon a successful return. + @param[in] handler The optional handler instance for callbacks during the device match. + @return PXC_STATUS_NO_ERROR Successful executation. + */ + virtual pxcStatus PXCAPI LocateStreams(Handler *handler)=0; + + /** + @brief The function locates an I/O device that meets any module input needs previously specified + by the RequestStreams function. The device and its streams are configured upon a successful return. + @return PXC_STATUS_NO_ERROR Successful executation. + */ + pxcStatus __inline LocateStreams(void) { + return LocateStreams(0); + } + + /** + @brief Close the streams. + */ + virtual void PXCAPI CloseStreams(void)=0; + + /** + @brief Return the capture instance. + @return the capture instance. + */ + virtual PXCCapture* PXCAPI QueryCapture(void)=0; + + /** + @brief Return the device instance. + @return the device instance. + */ + virtual PXCCapture::Device* PXCAPI QueryDevice(void)=0; + + /** + @brief Return the stream resolution of the specified stream type. + @param[in] type The stream type. + @return the stream resolution. + */ + virtual PXCSizeI32 PXCAPI QueryImageSize(PXCCapture::StreamType type)=0; + + /** + @brief Read the image samples for a specified module. + @param[in] mid The module identifier. + @param[out] sample The captured sample, to be returned. + @param[out] sp The SP, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ReadModuleStreamsAsync(pxcUID mid, PXCCapture::Sample *sample, PXCSyncPoint **sp)=0; + + /** + @brief Setup file recording or playback. + @param[in] file The file name. + @param[in] record If true, the file is opened for recording. Otherwise, the file is opened for playback. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetFileName(const pxcCHAR *file, pxcBool record)=0; + + /** + @brief Set up to record or playback certain stream types. + @param[in] types The bit-OR'ed stream types. + */ + virtual void PXCAPI SetMask(PXCCapture::StreamType types)=0; + + /** + @brief Pause/Resume recording or playing back. + @param[in] pause True for pause and false for resume. + */ + virtual void PXCAPI SetPause(pxcBool pause)=0; + + /** + @brief Set the realtime playback mode. + @param[in] realtime True to playback in real time, or false to playback as fast as possible. + */ + virtual void PXCAPI SetRealtime(pxcBool realtime)=0; + + /** + @brief Reset the playback position by the frame index. + @param[in] frame The frame index. + */ + virtual void PXCAPI SetFrameByIndex(pxcI32 frame)=0; + + /** + @brief Return the current playback position in frame index. + @return The frame index. + */ + virtual pxcI32 PXCAPI QueryFrameIndex(void)=0; + + /** + @brief Reset the playback position by the nearest time stamp. + @param[in] ts The time stamp, in 100ns. + */ + virtual void PXCAPI SetFrameByTimeStamp(pxcI64 ts)=0; + + /** + @brief Return the current playback frame time stamp. + @return The time stamp, in 100ns. + */ + virtual pxcI64 PXCAPI QueryFrameTimeStamp(void)=0; + + /** + @brief Return the frame number in the recorded file. + @return The number of frames. + */ + virtual pxcI32 PXCAPI QueryNumberOfFrames(void)=0; +}; diff --git a/modules/control/rssdk/rssdk/pxcdefs.h b/modules/control/rssdk/rssdk/pxcdefs.h new file mode 100644 index 0000000..c18f605 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcdefs.h @@ -0,0 +1,99 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcdefs.h + Defines various primitive types used throughout the SDK as well as some + common structures. All primitive types start with the prefix ``pxc''. + Integral primitive types follow that with either an `I' or `U' to indicate + signed or unsigned and then an integer indicating the number of bits used + by that type. For instance, pxcI32 aliases a 32-bit integral type. + + Finally, this class also defines some helper macros to construct some of + these types as well as other general tasks. + */ +#pragma once + +//TODO +//#if defined (WIN32) || defined(WIN64) || defined(WINAPI_FAMILY) +//#include +typedef wchar_t pxcCHAR; +//#else +//typedef char pxcCHAR; +//#endif + +/** A signed 16-bit integer */ +typedef short pxcI16; +/** This type is used as a unique identifier */ +typedef int pxcUID; +/** A signed 32-bit integer */ +typedef int pxcI32; +/** An signed 64-bit integer */ +typedef __int64 pxcI64; +/** An unsigned 16-bit integer */ +typedef unsigned short int pxcU16; +/** A byte (an unsigned 8-bit integer) */ +typedef unsigned char pxcBYTE; +/** A common type for enumeration values */ +typedef int pxcEnum; +/** A boolean value, zero indicates false */ +typedef int pxcBool; +/** A single-precision (32-bit) floating point type */ +typedef float pxcF32; +/** A double-precision (64-bit) floating point type */ +typedef double pxcF64; + +/** A rectangle type defined with pxcI32 values */ +struct PXCRectI32 { + pxcI32 x, y, w, h; +}; + +/** A type representing an two dimensional extent defined with pxcI32 values */ +struct PXCSizeI32 { + pxcI32 width, height; +}; + +/** A type representing a two dimensional point defined with pxcF32 values */ +struct PXCPointF32 { + pxcF32 x, y; +}; + +/** A type representing a two dimensional point defined with pxcI32 values */ +struct PXCPointI32 { + pxcI32 x, y; +}; + +/** A type representing a range defined with pxcF32 values */ +struct PXCRangeF32 { + pxcF32 min, max; +}; + +/** A type representing a three-dimensional point defined with pxcF32 values */ +struct PXCPoint3DF32 { + pxcF32 x, y, z; +}; + +/** A type representing a four-dimensional point or vector, for instance quaternion */ +struct PXCPoint4DF32 { + pxcF32 x, y, z, w; +}; + +/** This macro constructs a pxcUID given four byte values. The arguments will + be evaluated exactly once, cast to unsigned int and shifted into one of the + byte positions. Hence, arguments must not hold values larger than a byte. + The result is a pxcUID. */ +#define PXC_UID(X1,X2,X3,X4) ((pxcUID)(((unsigned int)(X4)<<24)+((unsigned int)(X3)<<16)+((unsigned int)(X2)<<8)+(unsigned int)(X1))) + +/** This macro defines a constant symbol of an integral type within the scope + of a class or struct. The type of the constant is that of a symbol in an + anonymous enumeration (with unspecified width), hence an unspecified + integral compile-time constant. */ +#define PXC_DEFINE_CONST(Y,X) enum {Y=X} + +/** This macro defines a UID in the context of a class deriving from PXCBase. */ +#define PXC_DEFINE_UID(Y,X1,X2,X3,X4) enum {Y=PXC_UID(X1,X2,X3,X4)} \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxcemotion.h b/modules/control/rssdk/rssdk/pxcemotion.h new file mode 100644 index 0000000..ec9c2c2 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcemotion.h @@ -0,0 +1,83 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file PXCEmotion.h + Defines the PXCEmotion interface, which programs may use to detect emotions + based on real-time facial expression analysis. + */ +#pragma once +#include "pxcsession.h" +#include "pxccapture.h" +#pragma warning(push) +#pragma warning(disable:4201) /* nameless structs/unions */ + +/** +This class defines a standard interface for emotion detection algorithms. +*/ +class PXCEmotion:public PXCBase { +public: + PXC_CUID_OVERWRITE(PXC_UID('E','M','T','N')); + + enum Emotion { + EMOTION_PRIMARY_ANGER =0x00000001, // primary emotion ANGER + EMOTION_PRIMARY_CONTEMPT =0x00000002, // primary emotion CONTEMPT + EMOTION_PRIMARY_DISGUST =0x00000004, // primary emotion DISGUST + EMOTION_PRIMARY_FEAR =0x00000008, // primary emotion FEAR + EMOTION_PRIMARY_JOY =0x00000010, // primary emotion JOY + EMOTION_PRIMARY_SADNESS =0x00000020, // primary emotion SADNESS + EMOTION_PRIMARY_SURPRISE =0x00000040, // primary emotion SURPRISE + + EMOTION_SENTIMENT_POSITIVE =0x00010000, // Overall sentiment: POSITIVE + EMOTION_SENTIMENT_NEGATIVE =0x00020000, // Overall sentiment: NEGATIVE + EMOTION_SENTIMENT_NEUTRAL =0x00040000, // Overall sentiment: NEUTRAL + }; + + /// The Emotion Data Structure + struct EmotionData { + pxcI64 timeStamp; // Time stamp in 100ns when the emotion data is detected + Emotion emotion; + pxcI32 fid; // Face ID + Emotion eid; // Emotion identifier + pxcF32 intensity; // In range [0,1]. The intensity value is the detection output + // to indicate the presence likelihood of an emotion: + // [0.0, 0.2): expression is likely absent + // [0.2, 0.4): expression is of low intensity + // [0.4, 0.6): expression is of medium intensity + // [0.6, 0.8): expression is of high intensity + // [0.8, 1.0]: expression is of very high intensity + pxcI32 evidence; // The evidence value, between -5 and 5, represents the odds in + // 10-based logaritmic scale of a target expression being present. + // For instance, + // Value 2 indicates that an emotion is 100 (10^2) times more likely + // to be categorized as its presence than not presence; while + // Value -2 indicates that an emotion is 100 times more likely + // to be categorized as its not presence than presence. + PXCRectI32 rectangle; // Detected face rectangle + pxcI32 reserved[8]; + }; + + /// Query the total number of detected faces for a given frame. + virtual pxcI32 PXCAPI QueryNumFaces()=0; + + /// Query the total number of detected emotions for a given frame. + virtual pxcI32 PXCAPI QueryEmotionSize()=0; + + /// Get Emotion data of the specified face and emotion. + /// fid The face ID, zero-based + /// eid The emotion identifier + /// data The EmotionData data structure, to be returned + virtual pxcStatus PXCAPI QueryEmotionData(pxcI32 /*fid*/, Emotion /*eid*/, EmotionData * /*data*/) =0; + + /// Get all Emotion data of a specified face. + /// fid The face ID, zero-based + /// data The array of EmotionData data structures, to be returned + /// Application should allocate the EmotionData array of size 10 for all 10 emotions + virtual pxcStatus QueryAllEmotionData(pxcI32 /*fid*/, EmotionData * /*data*/) =0; +}; +#pragma warning(pop) \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxcfaceconfiguration.h b/modules/control/rssdk/rssdk/pxcfaceconfiguration.h new file mode 100644 index 0000000..214d1df --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcfaceconfiguration.h @@ -0,0 +1,325 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or non-disclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include +#include "pxcfacedata.h" + +class PXCFaceConfiguration : public PXCBase +{ +public: + PXC_CUID_OVERWRITE(PXC_UID('F','C','F','G')); + + enum TrackingStrategyType + { + STRATEGY_APPEARANCE_TIME, + STRATEGY_CLOSEST_TO_FARTHEST, + STRATEGY_FARTHEST_TO_CLOSEST, + STRATEGY_LEFT_TO_RIGHT, + STRATEGY_RIGHT_TO_LEFT + }; + + enum SmoothingLevelType + { + SMOOTHING_DISABLED, + SMOOTHING_MEDIUM, + SMOOTHING_HIGH + }; + + struct DetectionConfiguration + { + pxcBool isEnabled; + pxcI32 maxTrackedFaces; + SmoothingLevelType smoothingLevel; + pxcI32 reserved[10]; + }; + + struct LandmarksConfiguration + { + pxcBool isEnabled; + pxcI32 maxTrackedFaces; + SmoothingLevelType smoothingLevel; + pxcI32 numLandmarks; + pxcI32 reserved[10]; + }; + + struct PoseConfiguration + { + pxcBool isEnabled; + pxcI32 maxTrackedFaces; + SmoothingLevelType smoothingLevel; + pxcI32 reserved[10]; + }; + + class ExpressionsConfiguration + { + public: + struct ExpressionsProperties + { + pxcBool isEnabled; + pxcI32 maxTrackedFaces; + pxcI32 reserved[10]; + }; + ExpressionsProperties properties; + + /* + @brief Enables expression module. + */ + __inline void Enable() + { + properties.isEnabled = true; + } + /* + @brief Disables expression module. + */ + __inline void Disable() + { + properties.isEnabled = false; + } + /* + @brief Is expression module enabled. + @return true - enabled, false - disabled. + */ + __inline pxcBool IsEnabled() + { + return properties.isEnabled; + } + /* + @brief Enables all available expressions. + */ + virtual void PXCAPI EnableAllExpressions() = 0; + /* + @brief Disables all available expressions. + */ + virtual void PXCAPI DisableAllExpressions() = 0; + /* + @brief Enables specific expression. + @param[in] expression - single face expression. + @return PXC_STATUS_NO_ERROR - success. + PXC_STATUS_PARAM_UNSUPPORTED - expression is unsupported. + */ + virtual pxcStatus PXCAPI EnableExpression(PXCFaceData::ExpressionsData::FaceExpression expression) = 0; + /* + @brief Disables specific expression. + @param[in] expression - single face expression. + */ + virtual void PXCAPI DisableExpression(PXCFaceData::ExpressionsData::FaceExpression expression) = 0; + /* + @brief Checks if expression is currently enabled in configuration. + @param[in] expression - single face expression + @return true - enabled, false - disabled. + */ + virtual pxcBool PXCAPI IsExpressionEnabled(PXCFaceData::ExpressionsData::FaceExpression expression) = 0; + }; + + class RecognitionConfiguration + { + public: + enum RecognitionRegistrationMode + { + REGISTRATION_MODE_CONTINUOUS, //registers users automatically + REGISTRATION_MODE_ON_DEMAND, //registers users on demand only + }; + + PXC_DEFINE_CONST(STORAGE_NAME_SIZE, 50); + + struct RecognitionStorageDesc + { + //pxcCHAR storageName[STORAGE_NAME_SIZE]; + pxcBool isPersistent; //determines whether the database is saved on exit. Currently this value is ignored + pxcI32 maxUsers; //maximum number of people to keep in DB + pxcI32 reserved[10]; + }; + RecognitionStorageDesc storageDesc; + + struct RecognitionProperties + { + pxcBool isEnabled; + pxcI32 accuracyThreshold; + RecognitionRegistrationMode registrationMode; + pxcI32 reserved[10]; + }; + RecognitionProperties properties; + + __inline void Enable() + { + properties.isEnabled = true; + } + __inline void Disable() + { + properties.isEnabled = false; + } + __inline void SetAccuracyThreshold(pxcI32 threshold) + { + properties.accuracyThreshold = threshold; + } + __inline pxcI32 GetAccuracryThreshold() + { + return properties.accuracyThreshold; + } + __inline void SetRegistrationMode(RecognitionRegistrationMode mode) + { + properties.registrationMode = mode; + } + __inline RecognitionRegistrationMode GetRegistrationMode() + { + return properties.registrationMode; + } + /** + @brief Sets the active Recognition database. + @param[in] storageName - The name of the database to be loaded by the Recognition module. + @param[in] storage - A pointer to the Recognition database, or NULL for an existing database. + @return PXC_STATUS_HANDLE_INVALID - if the module wasn't initialized properly. + PXC_STATUS_DATA_UNAVAILABLE - if the registration failed. + PXC_STATUS_NO_ERROR - if registration was successful. + */ + virtual pxcStatus PXCAPI UseStorage(pxcCHAR* storageName) = 0; + + /** + @brief Retrieves the Recognition storage descriptor for the active storage. + @param[in] outStorage - The storage descriptor into which the active storage information will be copied. + */ + virtual pxcStatus PXCAPI QueryActiveStorage(RecognitionStorageDesc* outStorage) = 0; + + /** + @brief Create a new Recognition database. + @param[in] storageName The name of the new database. + @return Pointer to the new database. + */ + virtual pxcStatus PXCAPI CreateStorage(pxcCHAR* storageName, RecognitionStorageDesc* storageDesc) = 0; + + /** + @brief Sets a storage descriptor to an existing Recognition storage. + @param[in] storageName - The name of the storage to set the descriptor for. + @param[in] storageDesc - Holds the new descriptor for the selected storage. + @return TBD + */ + virtual pxcStatus PXCAPI SetStorageDesc(pxcCHAR* storageName, RecognitionStorageDesc* storageDesc) = 0; + + /** + @brief Deletes an existing Recognition storage. + @param[in] storageName The name of the storage to be deleted. + */ + virtual pxcStatus PXCAPI DeleteStorage(pxcCHAR* storageName) = 0; + + /** + @brief Sets an existing database as the Recognition database used by the Face Recognition module. + @param[in] buffer The byte stream representing the Recognition database to be used. + */ + virtual void PXCAPI SetDatabaseBuffer(pxcBYTE* buffer, pxcI32 size) = 0; + + protected: + virtual ~RecognitionConfiguration() {} + }; + + enum TrackingModeType + { + FACE_MODE_COLOR, + FACE_MODE_COLOR_PLUS_DEPTH + }; + + DetectionConfiguration detection; + LandmarksConfiguration landmarks; + PoseConfiguration pose; + virtual ExpressionsConfiguration* PXCAPI QueryExpressions() = 0; + TrackingStrategyType strategy; + + virtual RecognitionConfiguration* QueryRecognition() = 0; + + virtual pxcStatus PXCAPI SetTrackingMode(TrackingModeType trackingMode) = 0; + virtual TrackingModeType PXCAPI GetTrackingMode() = 0; + + /* -------------------------------------------------- ALERTS ------------------------------------------------- */ + /* + @class AlertHandler + Interface for a callback for all categories of events + */ + class AlertHandler + { + public: + /* + @brief The OnFiredAlert method is called when a registered alert event is fired. + @param[in] alertData contains all the information for the fired event. + @see AlertData + */ + virtual void PXCAPI OnFiredAlert(const PXCFaceData::AlertData *alertData) = 0; + }; + + /* + @brief Enable alert, so that events are fired when the alert is identified. + @param[in] alertEvent the label of the alert to enabled. + @return PXC_STATUS_NO_ERROR if the alert was enabled successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter. + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual pxcStatus PXCAPI EnableAlert(PXCFaceData::AlertData::AlertType alertEvent) = 0; + + /* + @brief Enable all alert messaging events. + @return PXC_STATUS_NO_ERROR if enabling all alerts was successful; otherwise, return one of the following errors: + PXC_STATUS_PROCESS_FAILED - Module failure during processing. + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual void PXCAPI EnableAllAlerts(void) = 0; + + /* + @brief Check if an alert is enabled. + @param[in] alertEvent the ID of the event. + @return true if the alert is enabled; otherwise, return false + */ + virtual pxcBool PXCAPI IsAlertEnabled(PXCFaceData::AlertData::AlertType alertEvent) const = 0; + + /* + @brief Disable alert messaging for a specific event. + @param[in] alertEvent the ID of the event to be disabled. + @return PXC_STATUS_NO_ERROR if disabling the alert was successful; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter. + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual pxcStatus PXCAPI DisableAlert(PXCFaceData::AlertData::AlertType alertEvent) = 0; + + /* + @brief Disable all alerts messaging for all events. + @return PXC_STATUS_NO_ERROR if disabling all alerts was successful; otherwise, return one of the following errors: + PXC_STATUS_PROCESS_FAILED - Module failure during processing. + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual void PXCAPI DisableAllAlerts(void) = 0; + + /* + @brief Register an event handler object for the alerts. The event handler's OnFiredAlert method will be called each time an alert is identified. + @param[in] alertHandler a pointer to the event handler. + @see AlertHandler::OnFiredAlert + @return PXC_STATUS_NO_ERROR if the registering an event handler was successful; otherwise, return the following error: + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual pxcStatus PXCAPI SubscribeAlert(AlertHandler *alertHandler) = 0; + + /* + @brief Unsubscribe an event handler object for the alerts. + @param[in] alertHandler a pointer to the event handler that should be removed. + @return PXC_STATUS_NO_ERROR if the unregistering the event handler was successful, an error otherwise. + */ + virtual pxcStatus PXCAPI UnsubscribeAlert(AlertHandler *alertHandler) = 0; + + /* + * Commits configuration changes on module. + */ + virtual pxcStatus PXCAPI ApplyChanges() = 0; + + /* + * Restores configuration to global default values + */ + virtual void PXCAPI RestoreDefaults() = 0; + + /** + * @brief Updates data to latest available configuration. + */ + virtual pxcStatus PXCAPI Update() = 0; +}; \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxcfacedata.h b/modules/control/rssdk/rssdk/pxcfacedata.h new file mode 100644 index 0000000..f225fc5 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcfacedata.h @@ -0,0 +1,464 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or non-disclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxcfacemodule.h" + +class PXCFaceData : public PXCBase +{ +public: + PXC_CUID_OVERWRITE(PXC_UID('F','D','A','T')); + + enum LandmarkType + { + LANDMARK_NOT_NAMED = 0, + + LANDMARK_EYE_RIGHT_CENTER, + LANDMARK_EYE_LEFT_CENTER, + + LANDMARK_EYELID_RIGHT_TOP, + LANDMARK_EYELID_RIGHT_BOTTOM, + LANDMARK_EYELID_RIGHT_RIGHT, + LANDMARK_EYELID_RIGHT_LEFT, + + LANDMARK_EYELID_LEFT_TOP, + LANDMARK_EYELID_LEFT_BOTTOM, + LANDMARK_EYELID_LEFT_RIGHT, + LANDMARK_EYELID_LEFT_LEFT, + + LANDMARK_EYEBROW_RIGHT_CENTER, + LANDMARK_EYEBROW_RIGHT_RIGHT, + LANDMARK_EYEBROW_RIGHT_LEFT, + + LANDMARK_EYEBROW_LEFT_CENTER, + LANDMARK_EYEBROW_LEFT_RIGHT, + LANDMARK_EYEBROW_LEFT_LEFT, + + LANDMARK_NOSE_TIP, + LANDMARK_NOSE_TOP, + LANDMARK_NOSE_BOTTOM, + LANDMARK_NOSE_RIGHT, + LANDMARK_NOSE_LEFT, + + LANDMARK_LIP_RIGHT, + LANDMARK_LIP_LEFT, + + LANDMARK_UPPER_LIP_CENTER, + LANDMARK_UPPER_LIP_RIGHT, + LANDMARK_UPPER_LIP_LEFT, + + LANDMARK_LOWER_LIP_CENTER, + LANDMARK_LOWER_LIP_RIGHT, + LANDMARK_LOWER_LIP_LEFT, + + LANDMARK_FACE_BORDER_TOP_RIGHT, + LANDMARK_FACE_BORDER_TOP_LEFT, + + LANDMARK_CHIN + }; + + enum LandmarksGroupType + { + LANDMARK_GROUP_LEFT_EYE = 0x0001, + LANDMARK_GROUP_RIGHT_EYE = 0x0002, + LANDMARK_GROUP_RIGHT_EYEBROW = 0x0004, + LANDMARK_GROUP_LEFT_EYEBROW = 0x0008, + LANDMARK_GROUP_NOSE = 0x00010, + LANDMARK_GROUP_MOUTH = 0x0020, + LANDMARK_GROUP_JAW = 0x0040 + }; + + struct LandmarkPointSource + { + pxcI32 index; + LandmarkType alias; + pxcI32 reserved[10]; + }; + + struct LandmarkPoint + { + LandmarkPointSource source; + pxcI32 confidenceImage; + pxcI32 confidenceWorld; + PXCPoint3DF32 world; + PXCPointF32 image; + pxcI32 reserved[10]; + }; + + struct HeadPosition + { + PXCPoint3DF32 headCenter; + pxcI32 reserved[10]; + }; + + struct PoseEulerAngles + { + pxcF32 yaw; + pxcF32 pitch; + pxcF32 roll; + pxcI32 reserved[10]; + }; + + struct PoseQuaternion + { + pxcF32 x,y,z,w; + pxcI32 reserved[10]; + }; + + class DetectionData + { + public: + /* + * Assigns average depth of detected face to outFaceAverageDepth, returns true if data and outFaceAverageDepth exists, false otherwise. + */ + virtual pxcBool PXCAPI QueryFaceAverageDepth(pxcF32* outFaceAverageDepth) const = 0; + + /* + * Assigns 2D bounding rectangle of detected face to outBoundingRect, returns true if data and outBoundingRect exists, false otherwise. + */ + virtual pxcBool PXCAPI QueryBoundingRect(PXCRectI32* outBoundingRect) const = 0; + protected: + virtual ~DetectionData() {} + }; + + class LandmarksData + { + public: + /* + * Returns the number of tracked landmarks. + */ + virtual pxcI32 PXCAPI QueryNumPoints() const = 0; + + /* + * Assigns all the points to outNumPoints array. + * App is expected to allocate outPoints array. + * Returns true if data and parameters exists, false otherwise. + */ + virtual pxcBool PXCAPI QueryPoints(LandmarkPoint* outPoints) const = 0; + + /* + * Assigns point matched to index to outPoint. + * Returns true if data and outPoint exists and index is correct, false otherwise. + */ + virtual pxcBool PXCAPI QueryPoint(pxcI32 index, LandmarkPoint* outPoint) const = 0; + + /* + * Returns the number of tracked landmarks in groupFlags. + */ + virtual pxcI32 PXCAPI QueryNumPointsByGroup(LandmarksGroupType groupFlags) const = 0; + + /* + * Assigns points matched to groupFlags to outPoints. + * User is expected to allocate outPoints to size bigger than the group size - point contains the original source (index + name). + * Returns true if data and parameters exist, false otherwise. + */ + virtual pxcBool PXCAPI QueryPointsByGroup(LandmarksGroupType groupFlags, LandmarkPoint* outPoints) const = 0; + + /* + * Mapping function -> retrieves index corresponding to landmark's name. + */ + virtual pxcI32 PXCAPI QueryPointIndex(LandmarkType name) const = 0; + protected: + virtual ~LandmarksData() {} + }; + + class PoseData + { + public: + /* + * Assigns pose Euler angles to outPoseEulerAngles. + * Returns true if data and parameters exist, false otherwise. + */ + virtual pxcBool PXCAPI QueryPoseAngles(PoseEulerAngles* outPoseEulerAngles) const = 0; + + /* + * Assigns pose rotation as quaternion to outPoseQuaternion. + * Returns true if data and parameters exist, false otherwise. + */ + virtual pxcBool PXCAPI QueryPoseQuaternion(PoseQuaternion* outPoseQuaternion) const =0; + + /* + * Assigns Head Position to outHeadPosition. + * Returns true if data and parameters exist, false otherwise. + */ + virtual pxcBool PXCAPI QueryHeadPosition(HeadPosition* outHeadPosition) const = 0; + + /* + * Assigns 3x3 face's rotation matrix to outRotationMatrix. + * Returns true if data and parameters exist, false otherwise. + */ + virtual pxcBool PXCAPI QueryRotationMatrix(pxcF64 outRotationMatrix[9]) const = 0; + + protected: + virtual ~PoseData() {} + }; + + class ExpressionsData + { + public: + enum FaceExpression + { + EXPRESSION_BROW_RAISER_LEFT = 0, + EXPRESSION_BROW_RAISER_RIGHT, + EXPRESSION_BROW_LOWERER_LEFT, + EXPRESSION_BROW_LOWERER_RIGHT, + + EXPRESSION_SMILE, + EXPRESSION_KISS, + EXPRESSION_MOUTH_OPEN, + + EXPRESSION_EYES_CLOSED_LEFT, + EXPRESSION_EYES_CLOSED_RIGHT, + + EXPRESSION_HEAD_TURN_LEFT, + EXPRESSION_HEAD_TURN_RIGHT, + EXPRESSION_HEAD_UP, + EXPRESSION_HEAD_DOWN, + EXPRESSION_HEAD_TILT_LEFT, + EXPRESSION_HEAD_TILT_RIGHT, + + EXPRESSION_EYES_TURN_LEFT, + EXPRESSION_EYES_TURN_RIGHT, + EXPRESSION_EYES_UP, + EXPRESSION_EYES_DOWN + }; + + struct FaceExpressionResult + { + pxcI32 intensity; // percentage 0 - 100 + pxcI32 reserved[10]; + }; + + /** + @brief Queries single expression result. + @param[in] expression requested expression + @param[out] expressionResult output of expression - for example intensity of expression in frame. + @return true if expression was calculated successfully, false if expression calculation failed. + */ + virtual pxcBool PXCAPI QueryExpression(FaceExpression expression, FaceExpressionResult* expressionResult) const = 0; + + protected: + virtual ~ExpressionsData() {} + }; + + class RecognitionData + { + public: + /** + @brief Register a user in the Recognition database. + @param[in] userID The ID of the detected face to be registered. + @return The unique user ID assigned to the registered face by the Recognition module. + */ + virtual pxcUID PXCAPI RegisterUser() = 0; + + /** + @brief Removes a user from the Recognition database. + @param[in] userID The ID of the user to be removed. + */ + virtual void PXCAPI UnregisterUser() = 0; + + /** + @brief Checks if a user is registered in the Recognition database. + @param[in] userID The ID of the detected face to search for in the database. + @return true - if user is in the database, false otherwise. + */ + virtual pxcBool PXCAPI IsRegistered() const = 0; + + /** + @brief Returns the ID assigned to the current face by the Recognition module + @return The ID assigned by the Recognition module, or -1 if face was not recognized. + */ + virtual pxcUID PXCAPI QueryUserID() const = 0; + + protected: + virtual ~RecognitionData() {} + }; + + class RecognitionModuleData + { + public: + /** + @brief Retrieves the size of the Recognition database for the user to be able to allocate the db buffer in the correct size + @return The size of the database in bytes. + */ + virtual pxcI32 PXCAPI QueryDatabaseSize() const = 0; + + /** + @brief Retrieves the Recognition database to allow the user to save the database for later usage. + @param[in] buffer A user allocated buffer to copy the database into. The user must make sure the buffer is large enough (database size can be determined by calling QueryDatabaseSize()), and deallocated it if necessary. + @return true if database has been successfully copied to db. false - otherwise. + */ + virtual pxcBool PXCAPI QueryDatabaseBuffer(pxcBYTE* buffer) const = 0; + + protected: + virtual ~RecognitionModuleData() {} + }; + + class Face + { + public: + /* + * Returns user ID. + */ + virtual pxcUID PXCAPI QueryUserID() const = 0; + + /* + * Returns user's detection data instance - null if it is not enabled. + */ + virtual PXCFaceData::DetectionData* PXCAPI QueryDetection() = 0; + + /* + * Returns user's landmarks data instance - null if it is not enabled. + */ + virtual PXCFaceData::LandmarksData* PXCAPI QueryLandmarks() = 0; + + /* + * Returns user's pose data - null if it is not enabled. + */ + virtual PXCFaceData::PoseData* PXCAPI QueryPose() = 0; + + /* + * Returns user's expressions data - null if it not enabled. + */ + virtual PXCFaceData::ExpressionsData* PXCAPI QueryExpressions() = 0; + + /* + * Returns user's recognition data - null if it is not enabled. + */ + virtual PXCFaceData::RecognitionData* PXCAPI QueryRecognition() = 0; + + protected: + virtual ~Face() {} + }; + + /* + * Updates data to latest available output. + */ + virtual pxcStatus PXCAPI Update() = 0; + + /* + * Returns detected frame timestamp. + */ + virtual pxcI64 PXCAPI QueryFrameTimestamp() const = 0; + + /* + * Returns number of total detected faces in frame. + */ + virtual pxcI32 PXCAPI QueryNumberOfDetectedFaces() const = 0; + + /* + * Returns tracked face corresponding with the algorithm-assigned faceId, null if no such faceId exists. + */ + virtual PXCFaceData::Face* PXCAPI QueryFaceByID(pxcUID faceId) const = 0; + + /* + * Returns tracked face corresponding with the given index, 0 being the first according the to chosen tracking strategy, null if no such index exists. + */ + virtual PXCFaceData::Face* PXCAPI QueryFaceByIndex(pxcI32 index) const = 0; + + /* + * Returns allocated array of numDetectedFaces tracked faces where the order is indicated by heuristic (GetNumberOfDetectedFaces == numDetectedFaces). + * Size of returned array is guaranteed to be greater or equal to numDetectedFaces. + */ + virtual PXCFaceData::Face** PXCAPI QueryFaces(pxcI32* numDetectedFaces) const = 0; + + /* + * Returns interface for Recognition module data for the entire frame, as opposed to a specific face + */ + virtual PXCFaceData::RecognitionModuleData* QueryRecognitionModule() const = 0; + +#pragma region + struct AlertData + { + /** @enum AlertType + Available events that can be detected by the system (alert types) + */ + enum AlertType + { + ALERT_NEW_FACE_DETECTED = 1, // a new face enters the FOV and its position and bounding rectangle is available. + ALERT_FACE_OUT_OF_FOV, // a new face is out of field of view (even slightly). + ALERT_FACE_BACK_TO_FOV, // a tracked face is back fully to field of view. + ALERT_FACE_OCCLUDED, // face is occluded by any object or hand (even slightly). + ALERT_FACE_NO_LONGER_OCCLUDED, // face is not occluded by any object or hand. + ALERT_FACE_LOST // a face could not be detected for too long, will be ignored. + }; + + AlertType label; // The label that identifies this alert + pxcI64 timeStamp; // The time-stamp in which the event occurred + pxcUID faceId; // The ID of the relevant face, if relevant and known + pxcI32 reserved[10]; + }; + + PXC_DEFINE_CONST(ALERT_NAME_SIZE,30); + + /** + @brief Get the details of the fired alert at the requested index. + @param[in] index the zero-based index of the requested fired alert . + @param[out] alertData contains all the information for the fired event. + @see AlertData + @note the index is between 0 and the result of GetFiredAlertsNumber() + @see GetFiredAlertsNumber() + @return PXC_STATUS_NO_ERROR if returning fired alert data was successful; otherwise, return one of the following errors: + PXC_STATUS_PROCESS_FAILED - Module failure during processing. + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize. + */ + virtual pxcStatus PXCAPI QueryFiredAlertData(pxcI32 index, PXCFaceData::AlertData* alertData) const = 0; + + /** + @brief Return whether the specified alert is fired for a specific face in the current frame, and retrieve its data. + @param[in] alertEvent the label of the alert event. + @param[out] outAlertName parameter to contain the name of the alert,maximum size - ALERT_NAME_SIZE + @see AlertData + @return PXC_STATUS_NO_ERROR if returning the alert's name was successful; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - if outAlertName is null. + PXC_STATUS_DATA_UNAVAILABLE - if no alert corresponding to alertEvent was found. + */ + virtual pxcStatus PXCAPI QueryAlertNameByID(AlertData::AlertType alertEvent, pxcCHAR* outAlertName) const = 0; + + /** + @brief Get the number of fired alerts in the current frame. + @return the number of fired alerts. + */ + virtual pxcI32 PXCAPI QueryFiredAlertsNumber(void) const = 0; + + /** + @brief Return whether the specified alert is fired in the current frame, and retrieve its data if it is. + @param[in] alertEvent the ID of the event. + @param[out] alertData contains all the information for the fired event. + @see AlertData + @return true if the alert is fired, false otherwise. + */ + virtual pxcBool PXCAPI IsAlertFired(AlertData::AlertType alertEvent, PXCFaceData::AlertData* alertData) const = 0; + + /** + @brief Return whether the specified alert is fired for a specific face in the current frame, and retrieve its data. + @param[in] alertEvent the label of the alert event. + @param[in] faceID the ID of the face who's alert should be retrieved. + @param[out] alertData contains all the information for the fired event. + @see AlertData + @return true if the alert is fired, false otherwise. + */ + virtual pxcBool PXCAPI IsAlertFiredByFace(AlertData::AlertType alertEvent, pxcUID faceID, AlertData* alertData) const = 0; + + + +#pragma endregion Alerts + +}; + +/* Convenient Operators */ +static inline PXCFaceData::LandmarksGroupType operator|(PXCFaceData::LandmarksGroupType a, PXCFaceData::LandmarksGroupType b) +{ + return static_cast(static_cast(a) | static_cast(b)); +} + +static inline PXCFaceData::AlertData::AlertType operator|(PXCFaceData::AlertData::AlertType a, PXCFaceData::AlertData::AlertType b) +{ + return static_cast(static_cast(a) | static_cast(b)); +} \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxcfacemodule.h b/modules/control/rssdk/rssdk/pxcfacemodule.h new file mode 100644 index 0000000..1389c11 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcfacemodule.h @@ -0,0 +1,25 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxcbase.h" + +class PXCFaceConfiguration; +class PXCFaceData; +class PXCFaceModule : public PXCBase +{ +public: + PXC_CUID_OVERWRITE(PXC_UID('F','A','3','D')); + + /* create a new copy of active configuration */ + virtual PXCFaceConfiguration* PXCAPI CreateActiveConfiguration() = 0; + + /* create a placeholder for output */ + virtual PXCFaceData* PXCAPI CreateOutput() = 0; +}; diff --git a/modules/control/rssdk/rssdk/pxchandconfiguration.h b/modules/control/rssdk/rssdk/pxchandconfiguration.h new file mode 100644 index 0000000..a79a051 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxchandconfiguration.h @@ -0,0 +1,387 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxchanddata.h" + +/** + @class PXCHandConfiguration + @brief Handles the setup and configuration of the hand module. + This interface should be used to configure the tracking, alerts, gestures and output options. + @note The details of this configuration will be applied only when ApplyChanges is called +*/ +class PXCHandConfiguration: public PXCBase +{ +public: + + /* Constants */ + PXC_CUID_OVERWRITE(PXC_UID('H','A','C','G')); + + /* Event Handlers */ + + /** + @class AlertHandler + Interface for callback of alert events + */ + class AlertHandler { + public: + /** + @brief The OnFiredAlert method is called when a registered alert event is fired. + @param[in] alertData contains all the information for the fired event. + @see PXCHandData::AlertData + */ + virtual void PXCAPI OnFiredAlert(const PXCHandData::AlertData & alertData) = 0; + }; + + /** + @class GestureHandler + Interface for callback of gesture events + */ + class GestureHandler { + public: + + /** + @brief The OnFiredGesture method is called when a registered gesture event is fired. + @param[in] gestureData contains all the info of the fired event. + @see PXCHandData::GestureData + */ + virtual void PXCAPI OnFiredGesture(const PXCHandData::GestureData & gestureData) = 0; + }; + +public: + + /* General */ + + /** + @brief Commit the configuration changes to the module + This method must be called in order for any configuration changes to actually apply + @return PXC_STATUS_NO_ERROR - if the operation succeeded + PXC_STATUS_DATA_NOT_INITIALIZED - if the configuration was not initialized.\n + */ + virtual pxcStatus PXCAPI ApplyChanges() = 0; + + /** + @brief Restore configuration settings to the default values + @return PXC_STATUS_NO_ERROR - if the operation succeeded + PXC_STATUS_DATA_NOT_INITIALIZED - if the configuration was not initialized.\n + */ + virtual pxcStatus PXCAPI RestoreDefaults() = 0; + + /** + @brief Updates configuration settings to the current state of the module + @return PXC_STATUS_NO_ERROR - if the operation succeeded + PXC_STATUS_DATA_NOT_INITIALIZED - if the configuration was not initialized.\n + */ + virtual pxcStatus PXCAPI Update() = 0; + + /* Tracking Configuration */ + + /** + @brief Reset all tracking and alert information. + For example, you might want to call this method when transitioning from one game level + to another, in order not to carry information that is not relevant to the new stage. + @return PXC_STATUS_NO_ERROR if the reset was successful; otherwise, return one of the following errors: + PXC_STATUS_PROCESS_FAILED - Module failure during processing.\n + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n + @note ResetTracking will be executed only when processing the next frame + */ + virtual pxcStatus PXCAPI ResetTracking() = 0; + + /** + @brief Specify the name of the current user for personalization + The user name will be used to save and retrieve specific measurements (calibration) for this user + @param[in] userName the name of the current user + @return PXC_STATUS_NO_ERROR if the name was set successfully + PXC_STATUS_PARAM_UNSUPPORTED - if the input user name is an empty string. + */ + virtual pxcStatus PXCAPI SetUserName(const pxcCHAR *userName) = 0; + + /** + @brief Get the name of the current personalized user. + @return a null terminating string of the user's name + */ + virtual const pxcCHAR* PXCAPI QueryUserName() = 0; + + /** + @brief Enable the calculation of speed information for a specific joint + @param[in] jointLabel the identifier of the joint + @see PXCHandData::JointType + @param[in] jointSpeed the identifiers of joint speed type that it moves towards the target + @see PXCHandData::JointSpeedType + @param[in] time period for which the average speed will be calculated. Use 0 for current value only (not averaged). + @return PXC_STATUS_NO_ERROR if joint-speed was enabled successfully; + PXC_STATUS_PARAM_UNSUPPORTED if one of the arguments is illegal + */ + virtual pxcStatus PXCAPI EnableJointSpeed(PXCHandData::JointType jointLabel, PXCHandData::JointSpeedType jointSpeed, pxcI32 time) = 0; + + /** + @brief Disable the calculation of the speed information for a specific joint + @param[in] jointType the identifier of the joint + @see JointType + @return PXC_STATUS_NO_ERROR if disable joint speed successfully + PXC_STATUS_PARAM_UNSUPPORTED if the joint was not found + */ + virtual pxcStatus PXCAPI DisableJointSpeed(PXCHandData::JointType jointLabel) = 0; + + /** + @brief Set the boundaries of the tracking area. + The boundaries create a frustum shape in which the hand is tracked. + When the tracked hand reaches one of the boundaries (near, far, left, right, top, or bottom), the appropriate alert is fired. + @param nearTrackingDistance Tracking bounds frustum: nearest tracking distance + @param farTrackingDistance Tracking bounds frustum: farthest tracking distance + @param nearTrackingWidth Tracking bounds frustum: width of tracking range at the nearest distance + @param nearTrackingHeight Tracking bounds frustum: height of tracking range at the nearest distance + @return PXC_STATUS_NO_ERROR if the operation succeeded + PXC_STATUS_PARAM_UNSUPPORTED if one of the arguments is illegal + */ + virtual pxcStatus PXCAPI SetTrackingBounds(pxcF32 nearTrackingDistance, pxcF32 farTrackingDistance, pxcF32 nearTrackingWidth, pxcF32 nearTrackingHeight) = 0; + + /** + @brief Get the frustum defining the tracking boundaries + @param[out] nearTrackingDistance Tracking bounds frustum: nearest tracking distance + @param[out] farTrackingDistance Tracking bounds frustum: farthest tracking distance + @param[out] nearTrackingWidth Tracking bounds frustum: width of tracking range at the nearest distance + @param[out] nearTrackingHeight Tracking bounds frustum: height of tracking range at the nearest distance + @return PXC_STATUS_NO_ERROR if the operation succeeded + */ + virtual pxcStatus PXCAPI QueryTrackingBounds(pxcF32& nearTrackingDistance, pxcF32& farTrackingDistance, pxcF32& nearTrackingWidth, pxcF32& nearTrackingHeight) = 0; + + /** + @brief Set tracking mode which indicates which algorithm will be applied for tracking the hands + @param trackingMode: the tracking mode to be set + @Returns PXC_STATUS_NO_ERROR if the tracking mode is set successfully + */ + virtual pxcStatus PXCAPI SetTrackingMode(PXCHandData::TrackingModeType trackingMode) = 0; + + /** + @brief Query tracking mode which indicates which algorithm will be applied for tracking the hands + @Return TrackingModeType + */ + virtual PXCHandData::TrackingModeType PXCAPI QueryTrackingMode() = 0; + + ///@brief Sets the distance unit of the tracking data + virtual pxcStatus PXCAPI SetDistanceUnit(PXCHandData::DistanceUnitType distanceUnit) = 0; + + /** + @brief Query distance unit of the tracking data + @ Returns distance unit type + */ + virtual PXCHandData::DistanceUnitType PXCAPI QueryDistanceUnit() = 0; + + /** + @brief Sets the strength of the smoothing, ranging from 0 (not smoothed) to 1 (very smoothed motion) + @ Returns PXC_STATUS_NO_ERROR, if the smoothing value is set successfully + PXC_STATUS_PARAM_UNSUPPORTED if smoothing value is out of range + */ + virtual pxcStatus PXCAPI SetSmoothingValue(pxcF32 smoothingValue) = 0; + + /** + @brief Query smoothing value ranging from 0 (not smoothed) to 1 (very smoothed motion) + @Return the current smoothing value + */ + virtual pxcF32 PXCAPI QuerySmoothingValue() = 0; + + /** + @brief Enable the calculation of normalized skeleton + Calculating the normalized skeleton applies the pose of the tracked hand to a fixed-size skeleton. + The positions of the normalized skeleton's joints are available by calling IHand::QueryNormalizedJoint + @see PXCHandData::IHand::QueryNormalizedJoint + @param[in] enableFlag flag indicating if the normalized skeleton should be calculated + @Return PXC_STATUS_NO_ERROR, if the enable flag is set successfully + */ + virtual pxcStatus PXCAPI EnableNormalizedJoints(pxcBool enableFlag) = 0; + + /** + @brief Return true if normalized joints calculation is enabled, false otherwise + @Return true if normalized joints calculation is enabled, false otherwise + */ + virtual pxcBool PXCAPI IsNormalizedJointsEnabled() = 0; + + /** + @brief Enable the calculation of the hand segmentation image + @param[in] enableFlag flag indicating if the segmentation image should be calculated + @Return PXC_STATUS_NO_ERROR, if the enable flag is set successfully + */ + virtual pxcStatus PXCAPI EnableSegmentationImage(pxcBool enableFlag) = 0; + + /** + @brief Return true if calculation of the hand segmentation image is enabled, false otherwise + @Return true if calculation of the hand segmentation image is enabled, false otherwise + */ + virtual pxcBool PXCAPI IsSegmentationImageEnabled() = 0; + + /** + @brief Enable the calculation of tracked joints + @param[in] enableFlag flag indicating if the joints' tracking should be calculated + @ Returns PXC_STATUS_NO_ERROR, if the enable flag is set successfully + */ + virtual pxcStatus PXCAPI EnableTrackedJoints(pxcBool enableFlag) = 0; + + /** + @brief Return true if calculation of the tracked joints is enabled, false otherwise + @Return true if calculation of the tracked joints is enabled, false otherwise + */ + virtual pxcBool PXCAPI IsTrackedJointsEnabled() = 0; + + /* Alerts Configuration */ + + /** + @brief Enable alert messaging for a specific event. + @param[in] alertEvent the ID of the event to be enabled. + @return PXC_STATUS_NO_ERROR if enabling the alert was successful; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter. + */ + virtual pxcStatus PXCAPI EnableAlert(PXCHandData::AlertType alertEvent) = 0; + + /** + @brief Enable all alert messaging events. + @return PXC_STATUS_NO_ERROR if enabling all alerts was successful; otherwise, return one of the following errors: + PXC_STATUS_FEATURE_UNSUPPORTED - Module does not support enabling all alerts + */ + virtual pxcStatus PXCAPI EnableAllAlerts(void) = 0; + + /** + @brief Check if an alert is enabled. + @param[in] alertEvent the ID of the event. + @return true if the alert is enabled; otherwise, return false + */ + virtual pxcBool PXCAPI IsAlertEnabled(PXCHandData::AlertType alertEvent) const = 0; + + /** + @brief Disable alert messaging for a specific event. + @param[in] alertEvent the ID of the event to be disabled. + @return PXC_STATUS_NO_ERROR if disabling the alert was successful; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter.\n + PXC_STATUS_DATA_NOT_INITIALIZED - Data was not initialized.\n + */ + virtual pxcStatus PXCAPI DisableAlert(PXCHandData::AlertType alertEvent) = 0; + + /** + @brief Disable all alerts messaging for all events. + @return PXC_STATUS_NO_ERROR if disabling all alerts was successful; otherwise, return one of the following errors: + PXC_STATUS_DATA_NOT_INITIALIZED - Data was not initialized.\n + */ + virtual pxcStatus PXCAPI DisableAllAlerts(void) = 0; + + /** + @brief Register an event handler object for the alerts. + The event handler's OnFiredAlert method will be called each time an alert is identified. + @param[in] alertHandler a pointer to the event handler. + @see AlertHandler::OnFiredAlert + @return PXC_STATUS_NO_ERROR if the registering an event handler was successful; otherwise, return the following error: + PXC_STATUS_PARAM_UNSUPPORTED - if the input handler is null + */ + virtual pxcStatus PXCAPI SubscribeAlert(AlertHandler *alertHandler) = 0; + + /** + @brief Unsubscribe an event handler object for the alerts. + @param[in] alertHandler a pointer to the event handler that should be removed. + @return PXC_STATUS_NO_ERROR if the unregistering the event handler was successful, otherwise, return the following error: + PXC_STATUS_PARAM_UNSUPPORTED - if the input handler is null + */ + virtual pxcStatus PXCAPI UnsubscribeAlert(AlertHandler *alertHandler) = 0; + + /* Gestures Configuration */ + + /** + @brief Load a set of gestures from the specified path. + After this call the gestures that are contained in the gesture-pack will be available for recognition. + @param[in] gesturePackPath the directory of the gestures. + @return PXC_STATUS_NO_ERROR if the set of gestures was loaded successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - if the path is empty or gesture name list is empty + */ + virtual pxcStatus PXCAPI LoadGesturePack(const pxcCHAR* gesturePackPath)=0; + + /** + @brief Unload sets of gestures from the specified path. + @param[in] gesturePackPath the directory of the gestures. + @return PXC_STATUS_NO_ERROR if all gesture pack were unloaded successfully; + */ + virtual pxcStatus PXCAPI UnloadGesturePack(const pxcCHAR* gesturePackPath) =0; + + /** + @brief Unload all the sets of the gestures. + @return PXC_STATUS_NO_ERROR if all gesture packs were unloaded successfully; + */ + virtual pxcStatus PXCAPI UnloadAllGesturesPacks(void)=0; + + /** + @brief Return the total number of gestures that can be recognized. + @return the total number of gestures that can be recognized. + */ + virtual pxcI32 PXCAPI QueryGesturesTotalNumber(void) const = 0; + + /** + @brief Retrieve the gesture name that matches the given index. + @param[in] index the index of the gesture whose name you want to retrieve. + @param[in] bufferSize the size of the gestureName buffer. + @param[out] gestureName a character buffer to be filled with the gesture name. + @return PXC_STATUS_NO_ERROR if the gesture name was retrieved successfully; + PXC_STATUS_ITEM_UNAVAILABLE - if there is no corresponding gesture for the given index value + */ + virtual pxcStatus PXCAPI QueryGestureNameByIndex(pxcI32 index, pxcI32 bufferSize, pxcCHAR *gestureName) const = 0; + + /** + @brief Enable a gesture, so that events are fired when the gesture is identified. + @param[in] gestureName the name of the gesture to enabled. + @param[in] continuousGesture set to "true" to get an event at every frame, or "false" to get only start and end states of the gesture + @return PXC_STATUS_NO_ERROR if the gesture was enabled successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter. + */ + virtual pxcStatus PXCAPI EnableGesture(const pxcCHAR* gestureName, pxcBool continuousGesture)=0; + __inline pxcStatus EnableGesture(const pxcCHAR* gestureName) { return EnableGesture(gestureName, false); } + + /** + @brief Enable all gestures, so that events are fired when any gestures is identified. + @param[in] continuousGesture set to "true" to get an event at every frame, or "false" to get only start and end states of the gesture + @return PXC_STATUS_NO_ERROR if all the gestures were enabled successfully; + */ + virtual pxcStatus PXCAPI EnableAllGestures(pxcBool continuousGesture)=0; + __inline pxcStatus EnableAllGestures(void) { return EnableAllGestures(false); } + + /** + @brief Check whether a gesture is enabled. + @param[in] gestureName the name of the gesture. + @return true if a gesture is enabled, false otherwise. + */ + virtual pxcBool PXCAPI IsGestureEnabled(const pxcCHAR* gestureName) const = 0; + + /** + @brief Deactivate identification of a gesture. Events will no longer be fired for this gesture. + @param[in] gestureName the name of the gesture to deactivate. + @return PXC_STATUS_NO_ERROR if the gesture was deactivated successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter value of gestureName + */ + virtual pxcStatus PXCAPI DisableGesture(const pxcCHAR* gestureName)=0; + + /** + @brief Deactivate identification of all gestures. Events will no longer be fired for any gesture. + @return PXC_STATUS_NO_ERROR if the gestures were deactivated successfully; + */ + virtual pxcStatus PXCAPI DisableAllGestures(void)=0; + + /** + @brief Register an event handler object for the gestures. + The event handler's OnFiredGesture method will be called each time a gesture is identified. + @param[in] gestureHandler a pointer to the gesture handler. + @see GestureHandler::OnFiredGesture + @return PXC_STATUS_NO_ERROR if the subscribe gesture retrieved successfully; otherwise, return the following error: + PXC_STATUS_PARAM_UNSUPPORTED - if the input gesture handler is null. + */ + virtual pxcStatus PXCAPI SubscribeGesture(GestureHandler* gestureHandler) = 0; + + /** + @brief Unsubscribe an event handler object for the gestures. + @param[in] gestureHandler a pointer to the event handler that should be removed. + @return PXC_STATUS_NO_ERROR if the subscribe alert successfully,otherwise, return the following error: + PXC_STATUS_PARAM_UNSUPPORTED - if the input gesture handler is null. + */ + virtual pxcStatus PXCAPI UnsubscribeGesture(GestureHandler *gestureHandler) = 0; +}; + \ No newline at end of file diff --git a/modules/control/rssdk/rssdk/pxchanddata.h b/modules/control/rssdk/rssdk/pxchanddata.h new file mode 100644 index 0000000..a09510e --- /dev/null +++ b/modules/control/rssdk/rssdk/pxchanddata.h @@ -0,0 +1,487 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxcimage.h" + +class PXCHandData: public PXCBase +{ +public: + /* Constants */ + PXC_CUID_OVERWRITE(PXC_UID('H','A','D','T')); + PXC_DEFINE_CONST(NUMBER_OF_FINGERS,5); + PXC_DEFINE_CONST(NUMBER_OF_EXTREMITIES,6); + PXC_DEFINE_CONST(NUMBER_OF_JOINTS,22); + PXC_DEFINE_CONST(RESERVED_NUMBER_OF_JOINTS,32); + PXC_DEFINE_CONST(MAX_NAME_SIZE,64); + PXC_DEFINE_CONST(MAX_PATH_NAME,256); + + /* Enumerations */ + + /** @enum JointType + Identifiers of joints that can be tracked by the hand module + */ + enum JointType + { + /// The center of the wrist + JOINT_WRIST=0 + , JOINT_CENTER /// The center of the palm + , JOINT_THUMB_BASE /// Thumb finger joint 1 (base) + , JOINT_THUMB_JT1 /// Thumb finger joint 2 + , JOINT_THUMB_JT2 /// Thumb finger joint 3 + , JOINT_THUMB_TIP /// Thumb finger joint 4 (fingertip) + , JOINT_INDEX_BASE /// Index finger joint 1 (base) + , JOINT_INDEX_JT1 /// Index finger joint 2 + , JOINT_INDEX_JT2 /// Index finger joint 3 + , JOINT_INDEX_TIP /// Index finger joint 4 (fingertip) + , JOINT_MIDDLE_BASE /// Middle finger joint 1 (base) + , JOINT_MIDDLE_JT1 /// Middle finger joint 2 + , JOINT_MIDDLE_JT2 /// Middle finger joint 3 + , JOINT_MIDDLE_TIP /// Middle finger joint 4 (fingertip) + , JOINT_RING_BASE /// Ring finger joint 1 (base) + , JOINT_RING_JT1 /// Ring finger joint 2 + , JOINT_RING_JT2 /// Ring finger joint 3 + , JOINT_RING_TIP /// Ring finger joint 4 (fingertip) + , JOINT_PINKY_BASE /// Pinky finger joint 1 (base) + , JOINT_PINKY_JT1 /// Pinky finger joint 2 + , JOINT_PINKY_JT2 /// Pinky finger joint 3 + , JOINT_PINKY_TIP /// Pinky finger joint 4 (fingertip) + }; + + /** + @enum ExtremityType + The identifier of an extremity of the tracked hand + */ + enum ExtremityType { + /// The closest point to the camera in the tracked hand + EXTREMITY_CLOSEST=0 + , EXTREMITY_LEFTMOST /// The left-most point of the tracked hand + , EXTREMITY_RIGHTMOST /// The right-most point of the tracked hand + , EXTREMITY_TOPMOST /// The top-most point of the tracked hand + , EXTREMITY_BOTTOMMOST /// The bottom-most point of the tracked hand + , EXTREMITY_CENTER /// The center point of the tracked hand + }; + + /** @enum FingerType + The identifiers of the hand fingers + */ + enum FingerType { + /// Thumb finger + FINGER_THUMB=0 + , FINGER_INDEX /// Index finger + , FINGER_MIDDLE /// Middle finger + , FINGER_RING /// Ring finger + , FINGER_PINKY /// Pinky finger + }; + + /** @enum BodySideType + Defines the side of the body that a hand belongs to + */ + enum BodySideType { + /// The hand-type was not determined + BODY_SIDE_UNKNOWN=0 + , BODY_SIDE_LEFT /// Left side of the body + , BODY_SIDE_RIGHT /// Right side of the body + }; + + /** @enum AlertType + Enumerates the events that can be detected and fired by the module + */ + enum AlertType { + /// A hand is identified and its mask is available + ALERT_HAND_DETECTED = 0x0001 + , ALERT_HAND_NOT_DETECTED = 0x0002 /// A previously detected hand is lost, either because it left the field of view or because it is occluded + , ALERT_HAND_TRACKED = 0x0004 /// Full tracking information is available for a hand + , ALERT_HAND_NOT_TRACKED = 0x0008 /// No tracking information is available for a hand (none of the joints are tracked) + , ALERT_HAND_CALIBRATED = 0x0010 /// Hand measurements are ready and accurate + , ALERT_HAND_NOT_CALIBRATED = 0x0020 /// Hand measurements are not yet finalized, and are not fully accurate + , ALERT_HAND_OUT_OF_BORDERS = 0x0040 /// Hand is outside of the tracking boundaries + , ALERT_HAND_INSIDE_BORDERS = 0x0080 /// Hand has moved back inside the tracking boundaries + , ALERT_HAND_OUT_OF_LEFT_BORDER = 0x0100 /// The tracked object is touching the left border of the field of view + , ALERT_HAND_OUT_OF_RIGHT_BORDER = 0x0200 /// The tracked object is touching the right border of the field of view + , ALERT_HAND_OUT_OF_TOP_BORDER = 0x0400 /// The tracked object is touching the upper border of the field of view + , ALERT_HAND_OUT_OF_BOTTOM_BORDER = 0x0800 /// The tracked object is touching the lower border of the field of view + , ALERT_HAND_TOO_FAR = 0x1000 /// The tracked object is too far + , ALERT_HAND_TOO_CLOSE = 0x2000 /// The tracked object is too close + }; + + + + /** + @enum GestureStateType + Available gesture event states + */ + enum GestureStateType { + /// Gesture started + GESTURE_STATE_START=0 + , GESTURE_STATE_IN_PROGRESS /// Gesture is in progress + , GESTURE_STATE_END /// Gesture ended + }; + + /** + @enum TrackingModeType + The Tracking mode indicates which set of joints will be tracked. + */ + enum TrackingModeType { + /// Track the full skeleton + TRACKING_MODE_FULL_HAND=0 + , TRACKING_MODE_EXTREMITIES /// Track the extremities of the hand + }; + + /** + @enum DistanceUnitType + allows to choose between the units of the output world distances + */ + enum DistanceUnitType + { + /// Display output distances in meters + DISTANCE_UNIT_METERS=0 + ,DISTANCE_UNIT_CENTIMETERS ///Display output distances in centimeters + }; + + /** + @enum JointSpeedType + List of available modes for calculating the joint's speed + */ + enum JointSpeedType { + /// Average speed across time + JOINT_SPEED_AVERAGE=0 + , JOINT_SPEED_ABSOLUTE /// Average of absolute speed across time + }; + + /** + @enum AccessOrderType + List of the different orders in which the hands can be accessed + */ + enum AccessOrderType { + /// Unique ID of the hand + ACCESS_ORDER_BY_ID=0 + , ACCESS_ORDER_BY_TIME /// From oldest to newest hand in the scene + , ACCESS_ORDER_NEAR_TO_FAR /// From near to far hand in scene + , ACCESS_ORDER_LEFT_HANDS /// All left hands + , ACCESS_ORDER_RIGHT_HANDS /// All right hands + , ACCESS_ORDER_FIXED /// The index of each hand is fixed as long as it is detected (and between 0 and 1) + }; + + /* Data Structures */ + + /** @struct JointData + Contains the information about the position and rotation of a joint in the hand's skeleton + */ + struct JointData + { + pxcI32 confidence; /// The confidence score of the tracking data, ranging from 0 to 100 + PXCPoint3DF32 positionWorld; /// The geometric position in world coordinates (meters) + PXCPoint3DF32 positionImage; /// The geometric position in depth coordinates (pixels) + PXCPoint4DF32 localRotation; /// A quaternion representing the local 3D orientation (relative to parent joint) from the joint's parent to the joint + PXCPoint4DF32 globalOrientation; /// A quaternion representing the global 3D orientation (relative to camera) from the joint's parent to the joint + PXCPoint3DF32 speed; /// The speed of the joints in the 3D world coordinates + }; + + /** + @struct ExtremitiesData + Contains the parameters that define extremities points + */ + struct ExtremityData + { + PXCPoint3DF32 pointWorld; /// 3D world coordinates of the extremity point + PXCPoint3DF32 pointImage; /// 2D image coordinates of the extremity point + }; + + /** + @struct FingerData + Contains the parameters that define a finger + */ + struct FingerData + { + pxcI32 foldedness; /// The degree of foldedness of the tracking finger, ranging from 0 to 100 + pxcF32 radius; /// The radius of the tracked fingertip + }; + + /** + @struct AlertData + Containing the parameters that define an alert + */ + struct AlertData + { + AlertType label; /// The label that identifies this alert + pxcUID handId; /// The ID of the relevant hand, if relevant and known + pxcI64 timeStamp; /// The time-stamp in which the event occurred + pxcI32 frameNumber; /// The number of the frame in which the event occurred + }; + + /** + @struct GestureData + Contains the parameters that define a gesture + Default gestures: + "spreadfingers" - hand open facing the camera + "thumbup" - hand closed with thumb finger pointing up + "thumbdown" - hand closed with thumb finger pointing down + "twofingerspinch" - hand open with thumb finger and index finger touching each other + "v_sign" - hand closed with index finger and middle finger pointing up + */ + struct GestureData + { + pxcI64 timeStamp; /// Time-stamp in which the gesture occurred + pxcUID handId; /// ID of the relevant tracked hand, if relevant and known + GestureStateType state; /// The state of the gesture + pxcI32 frameNumber; /// The number of the frame in which the gesture occurred + pxcCHAR name[MAX_NAME_SIZE]; /// Unique name of this gesture + }; + + /* Interfaces */ + + /** + @class IHand + Contains the parameters that define a hand + */ + class IHand + { + public: + + /** @brief the hand's unique identifier + @return the hand's unique identifier + */ + virtual pxcUID PXCAPI QueryUniqueId() const = 0; + + /** + @brief Return the identifier of the user whose hand is represented + */ + virtual pxcUID PXCAPI QueryUserId() const = 0; + + /** + @brief Return the time-stamp in which the collection of the hand data was completed + */ + virtual pxcI64 PXCAPI QueryTimeStamp() const = 0; + + /** + @brief Return true if there is a valid hand calibration. + A valid calibration results in more accurate tracking data, that is better fitted to the user's hand. + */ + virtual pxcBool PXCAPI IsCalibrated(void) const = 0; + + /** + @brief Return the side of the body that the hand belongs to + */ + virtual BodySideType PXCAPI QueryBodySide() const = 0; + + /** + @brief Return the location and dimensions of the tracked hand, represented by a 2D bounding box (pixels) + */ + virtual const PXCRectI32& PXCAPI QueryBoundingBoxImage() const = 0; + + /** + @brief Return the 2D center of mass of the hand in image space (pixels) + */ + virtual const PXCPointF32& PXCAPI QueryMassCenterImage() const = 0; + + /** + @brief Return the 3D center of mass of the hand in world space (meters) + */ + virtual const PXCPoint3DF32& PXCAPI QueryMassCenterWorld() const = 0; + + /** + @brief Return the direction in which the hand's palm is facing + */ + virtual const PXCPoint4DF32& PXCAPI QueryPalmOrientation() const = 0; + + /** + @brief Get detected extremities points data + @param[in] extremityLabel The id of this ExtremityType + @param[out] extremityPoint The extremity point data + @return PXC_STATUS_NO_ERROR for success, an error code otherwise + */ + virtual pxcStatus PXCAPI QueryExtremityPoint(ExtremityType extremityLabel, ExtremityData& extremityPoint) const = 0; + + /** + @brief Get fingers data + @param[in] fingerLabel The id of this finger + @param[out] fingerData The finger data + @return PXC_STATUS_NO_ERROR for success, an error code otherwise + */ + virtual pxcStatus PXCAPI QueryFingerData(FingerType fingerLabel, FingerData& fingerData) const = 0; + + /** + @brief Get tracked hand joint data + @param[in] jointLabel The id of this joint + @param[out] jointData The tracked hand joint data + @return PXC_STATUS_NO_ERROR for success, an error code otherwise + */ + virtual pxcStatus PXCAPI QueryTrackedJoint(JointType jointLabel, JointData& jointData) const = 0; + + /** + @brief Get normalized hand joint data + @param[in] jointLabel The id of this joint + @param[out] jointData The normalized hand joint data + @return PXC_STATUS_NO_ERROR for success, an error code otherwise + */ + virtual pxcStatus PXCAPI QueryNormalizedJoint(JointType jointLabel, JointData& jointData) const = 0; + + /** + @brief Retrieve the 2D image mask of the tracked hand. + In the image mask, each pixel occupied by the hand is white (value of 255) and all other pixels are black (value of 0). + @param[out] image the blob image to be returned + @return PXC_STATUS_NO_ERROR if a current image exists and could be copied; otherwise, return the following error: + PXC_STATUS_DATA_UNAVAILABLE - if segmentation image is not available. + */ + virtual pxcStatus PXCAPI QuerySegmentationImage(PXCImage* & image) const = 0; + + /** + @brief Return true/false if tracked joints of HandData exists + */ + virtual pxcBool PXCAPI HasTrackedJoints() const= 0; + + /** + @brief Return true/false if normalized joints of HandData exists + */ + virtual pxcBool PXCAPI HasNormalizedJoints() const= 0; + + /** + @brief Return true/false if hand segmentation image exists + */ + virtual pxcBool PXCAPI HasSegmentationImage()const= 0; + + }; // class IHand + +public: + /* General */ + + /** + * @brief Updates data to latest available output. + */ + virtual pxcStatus PXCAPI Update() = 0; + + /* Alerts Outputs */ + + /** + @brief Get the number of fired alerts in the current frame. + @return the number of fired alerts. + */ + virtual pxcI32 PXCAPI QueryFiredAlertsNumber(void) const = 0; + + /** + @brief Get the details of the fired alert at the requested index. + @param[in] index the zero-based index of the requested fired alert . + @param[out] alertData contains all the information for the fired event. + @see AlertData + @note the index is between 0 and the result of QueryFiredAlertsNumber() + @see QueryFiredAlertsNumber() + @return PXC_STATUS_NO_ERROR if returning fired alert data was successful; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - if the input parameter value is not supported. For instance, index >= size of all enabled alerts + */ + virtual pxcStatus PXCAPI QueryFiredAlertData(pxcI32 index, AlertData & alertData) const = 0; + + /** + @brief Return whether the specified alert is fired in the current frame, and retrieve its data if it is. + @param[in] alertEvent the ID of the event. + @param[out] alertData contains all the information for the fired event. + @see AlertData + @return true if the alert is fired, false otherwise. + */ + virtual pxcBool PXCAPI IsAlertFired(AlertType alertEvent, AlertData & alertData) const = 0; + + /** + @brief Return whether the specified alert is fired for a specific hand in the current frame, and retrieve its data. + @param[in] alertEvent the label of the alert event. + @param[in] handID the ID of the hand who's alert should be retrieved. + @param[out] alertData contains all the information for the fired event. + @see AlertData + @return true if the alert is fired, false otherwise. + */ + virtual pxcBool PXCAPI IsAlertFiredByHand(AlertType alertEvent, pxcUID handID, AlertData & alertData) const = 0; + + /* Gestures Outputs */ + + /** + @brief Get the number of fired gestures in the current frame. + @return number of fired gestures. + */ + virtual pxcI32 PXCAPI QueryFiredGesturesNumber(void) const = 0; + + /** + @brief Get the details of the fired gesture at the requested index. + @param[in] index the zero-based index of the requested fired gesture. + @param[out] gestureData contains all the information for the fired gesture. + @see GestureData + @note the index is between 0 and the result of QueryFiredGesturesNumber() + @see QueryFiredGesturesNumber() + @return PXC_STATUS_NO_ERROR if the fired gesture data successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - if the input parameter value is not supported. For instance, index >= size of all enabled gestures + */ + virtual pxcStatus PXCAPI QueryFiredGestureData(pxcI32 index, GestureData & gestureData) const = 0; + + /** + @brief Check whether a gesture was fired and return its details if it was. + @param[in] gestureName the name of the gesture to be checked. + @param[out] gestureData will contain all the information for the fired gesture. + @see GestureData + @return true if the gesture was fired, false otherwise. + */ + virtual pxcBool PXCAPI IsGestureFired(const pxcCHAR* gestureName, GestureData & gestureData) const = 0; + + /** + @brief Return whether the specified gesture is fired for a specific hand in the current frame, and retrieve its data. + @param[in] gestureName the name of the gesture to be checked. + @param[in] handID the ID of the hand who's alert should be retrieved. + @param[out] gestureData will contain all the information for the fired gesture. + @see GestureData + @return true if the gesture was fired, false otherwise. + */ + virtual pxcBool PXCAPI IsGestureFiredByHand(const pxcCHAR* gestureName, pxcUID handID, GestureData & gestureData) const = 0; + + /* Hands Outputs */ + + /** + @brief Return the number of hands detected in the current frame. + @return The number of hands detected in the current frame. + */ + virtual pxcI32 PXCAPI QueryNumberOfHands(void) const = 0; + + /** + @brief Retrieve the hand's uniqueId. + @param[in] accessOrder the order in which the hands are enumerated (accessed). + @see AccessOrderType + @param[in] index the index of the hand to be retrieve, based on the given AccessOrder. + @param[out] handId contains the hand's uniqueId. + @return PXC_STATUS_NO_ERROR if the hand exists; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - Unsupported parameter value. For instance, index >= total number of hands + */ + virtual pxcStatus PXCAPI QueryHandId(AccessOrderType accessOrder, pxcI32 index, pxcUID &handId) const = 0; + + /** + @brief Retrieve the hand object data using a specific AccessOrder and index in that order + @param[in] accessOrder the order in which the hands are enumerated (accessed). + @see AccessOrder + @param[in] index the index of the hand to be retrieve, based on the given AccessOrder. + @param[out] hand contains all the information for the hand. + @see HandData + @return PXC_STATUS_NO_ERROR if the hand was retrieved successfully; otherwise, return one of the following errors: + PXC_STATUS_PARAM_UNSUPPORTED - if index >= MAX_NUM_HANDS + PXC_STATUS_DATA_UNAVAILABLE - if index >= number of detected hands + */ + virtual pxcStatus PXCAPI QueryHandData(AccessOrderType accessOrder, pxcI32 index, IHand *& handData) const = 0; + + /** + @brief Retrieve the hand object data using its unique Id + @param[in] handID the unique ID of the requested hand + @param[out] hand contains all the information for the hand. + @see HandData + @return PXC_STATUS_NO_ERROR if the hand was retrieved successfully; otherwise, return one of the following errors: + PXC_STATUS_DATA_UNAVAILABLE - if there is no output hand data + PXC_STATUS_PARAM_UNSUPPORTED - if there is no hand data for the given hand ID. + */ + virtual pxcStatus PXCAPI QueryHandDataById(pxcUID handID, IHand *& handData) const = 0; +}; + +/** Operator | for alertType labels */ +static inline PXCHandData::AlertType operator|(PXCHandData::AlertType a, PXCHandData::AlertType b) +{ + return static_cast(static_cast(a) | static_cast(b)); +} + diff --git a/modules/control/rssdk/rssdk/pxchandmodule.h b/modules/control/rssdk/rssdk/pxchandmodule.h new file mode 100644 index 0000000..2ace542 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxchandmodule.h @@ -0,0 +1,41 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxcbase.h" + + +class PXCHandConfiguration; +class PXCHandData; + +/** + @Class PXCHandModule + The main interface for the hand-module's classes. + Use this interface to get access to the hand-module's configuration and output data +*/ +class PXCHandModule : public PXCBase +{ +public: + + PXC_CUID_OVERWRITE(PXC_UID('H','A','N','N')); + + /** + Create a new instance of the hand-module's active configuration. + @return a pointer to the configuration instance + @see PXCHandConfiguration + */ + virtual PXCHandConfiguration* PXCAPI CreateActiveConfiguration() = 0; + + /** + Create a new instance of the hand-module's output data + @return a pointer to the output-data instance + @see PXCHandData + */ + virtual PXCHandData* PXCAPI CreateOutput() = 0; +}; diff --git a/modules/control/rssdk/rssdk/pxcimage.h b/modules/control/rssdk/rssdk/pxcimage.h new file mode 100644 index 0000000..6b027f1 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcimage.h @@ -0,0 +1,230 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcimage.h +Defines the PXCImage interface, which manages image buffer access. +*/ +#pragma once +#include "pxcbase.h" +#include "pxcaddref.h" +#pragma warning(push) +#pragma warning(disable:4201) /* nameless structs/unions */ + +/** +This class defines a standard interface for image buffer access. + +The interface extends PXCAddRef. Use QueryInstance(), or the helper +function AddRef() to access the PXCAddRef features. + +The interface extends PXCMetadata. Use QueryInstance() to access +the PXCMetadata features. +*/ +class PXCImage:public PXCBase { +public: + PXC_CUID_OVERWRITE(0x24740F76); + PXC_DEFINE_CONST(NUM_OF_PLANES, 4); + + /** + @enum PixelFormat + Describes the image sample pixel format + */ + enum PixelFormat { + PIXEL_FORMAT_ANY=0, /* Unknown/undefined */ + + /* STREAM_TYPE_COLOR */ + PIXEL_FORMAT_YUY2 = 0x00010000, /* YUY2 image */ + PIXEL_FORMAT_NV12, /* NV12 image */ + PIXEL_FORMAT_RGB32, /* BGRA layout on a little-endian machine */ + PIXEL_FORMAT_RGB24, /* BGR layout on a little-endian machine */ + PIXEL_FORMAT_Y8, /* 8-Bit Gray Image */ + + /* STREAM_TYPE_DEPTH */ + PIXEL_FORMAT_DEPTH = 0x00020000, /* 16-bit unsigned integer with precision mm. */ + PIXEL_FORMAT_DEPTH_RAW, /* 16-bit unsigned integer with device specific precision. */ + PIXEL_FORMAT_DEPTH_F32, /* 32-bit float-point with precision mm. */ + + /* STREAM_TYPE_IR */ + PIXEL_FORMAT_Y16 = 0x00040000, /* 16-Bit Gray Image */ + }; + + /** + @brief Convert pixel format to a string representation + @param[in] format pixel format. + @return string presentation. + */ + __inline static const pxcCHAR *PixelFormatToString(PixelFormat format) { + switch (format) { + case PIXEL_FORMAT_RGB24: return (const pxcCHAR*)L"RGB24"; + case PIXEL_FORMAT_RGB32: return (const pxcCHAR*)L"RGB32"; + case PIXEL_FORMAT_YUY2: return (const pxcCHAR*)L"YUY2"; + case PIXEL_FORMAT_NV12: return (const pxcCHAR*)L"NV12"; + case PIXEL_FORMAT_Y8: return (const pxcCHAR*)L"Y8"; + case PIXEL_FORMAT_Y16: return (const pxcCHAR*)L"Y16"; + case PIXEL_FORMAT_DEPTH: return (const pxcCHAR*)L"DEPTH"; + case PIXEL_FORMAT_DEPTH_F32: return (const pxcCHAR*)L"DEPTH(FLOAT)"; + case PIXEL_FORMAT_DEPTH_RAW: return (const pxcCHAR*)L"DEPTH(NATIVE)"; + } + return (const pxcCHAR*)L"Unknown"; + } + + /** + @struct ImageInfo + Describes the image sample detailed information. + */ + struct ImageInfo { + pxcI32 width; /* width of the image in pixels */ + pxcI32 height; /* height of the image in pixels */ + PixelFormat format; /* image pixel format */ + pxcI32 reserved; + }; + + /** + @struct ImageData + Describes the image storage details. + */ + struct ImageData { + PixelFormat format; /* image pixel format */ + pxcI32 reserved[3]; + pxcI32 pitches[NUM_OF_PLANES]; /* image pitches */ + pxcBYTE* planes[NUM_OF_PLANES]; /* image buffers */ + }; + + /** + @enum Access + Describes the image access mode. + */ + enum Access { + ACCESS_READ = 1, /* read only access */ + ACCESS_WRITE = 2, /* write only access */ + ACCESS_READ_WRITE = ACCESS_READ | ACCESS_WRITE, /* read write access */ + }; + + /** + @enum Option + Describes the image options. + */ + enum Option { + OPTION_ANY = 0, + }; + + /** + @brief Return the image sample information. + @return the image sample information in the ImageInfo structure. + */ + virtual ImageInfo PXCAPI QueryInfo(void)=0; + + + virtual pxcI64 PXCAPI QueryTimeStamp(void)=0; + + /** + @brief Return the image stream type. The application should cast the + returned type to PXCCapture::StreamType. + @return the stream type. + */ + virtual pxcEnum PXCAPI QueryStreamType(void)=0; + + /** + @brief Get the image option flags. + @return the option flags. + */ + virtual Option PXCAPI QueryOptions(void)=0; + + /** + @brief Set the sample time stamp. + @param[in] ts The time stamp value, in 100ns. + */ + virtual void PXCAPI SetTimeStamp(pxcI64 ts)=0; + + /** + @brief Set the sample stream type. + @param[in] streamType The sample stream type. + */ + virtual void PXCAPI SetStreamType(pxcEnum streamType)=0; + + /** + @brief Set the sample options. This function overrides any previously set options. + @param[in] options The image options. + */ + virtual void PXCAPI SetOptions(Option options)=0; + + /** + @brief Copy image data from another image sample. + @param[in] src_image The image sample to copy data from. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI CopyImage(PXCImage *src_image)=0; + + /** + @brief Copy image data to the specified external buffer. + @param[in] data The ImageData structure that describes the image buffer. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ExportData(ImageData *data)=0; + + /** + @brief Copy image data from the specified external buffer. + @param[in] data The ImageData structure that describes the image buffer. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ImportData(ImageData *data)=0; + + /** + @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched. + @param[in] access The access mode. + @param[in] format The requested smaple format. + @param[in] options The option flags. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI AcquireAccess(Access access, PixelFormat format, Option options, ImageData *data)=0; + + /** + @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched. + @param[in] access The access mode. + @param[in] format The requested smaple format. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus AcquireAccess(Access access, PixelFormat format, ImageData *data) { + return AcquireAccess(access, format, OPTION_ANY, data); + } + + /** + @brief Lock to access the internal storage of a specified format. + @param[in] access The access mode. + @param[out] data The sample data storage, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus AcquireAccess(Access access, ImageData *data) { + return AcquireAccess(access, PIXEL_FORMAT_ANY, OPTION_ANY, data); + } + + /** + @brief Unlock the previously acquired buffer. + @param[in] data The sample data storage previously acquired. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ReleaseAccess(ImageData *data)=0; + + /** + @brief Increase a reference count of the sample. + */ + __inline void AddRef(void) { + QueryInstance()->AddRef(); + } +}; + +/** +A helper function for bitwise OR of two flags. +*/ +__inline static PXCImage::Option operator | (PXCImage::Option a, PXCImage::Option b) { + return (PXCImage::Option)((int)a|(int)b); +} + +#pragma warning(pop) diff --git a/modules/control/rssdk/rssdk/pxcmetadata.h b/modules/control/rssdk/rssdk/pxcmetadata.h new file mode 100644 index 0000000..d010245 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcmetadata.h @@ -0,0 +1,97 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcmetadata.h + Defines the PXCMetadata interface, which is used for managing + metadata storage. + */ +#pragma once +#include "pxcbase.h" + +/** + This interface manages metadata storage. The PXCSession, PXCImage + and PXCAudio implementations expose the PXCMetadata interface. + */ +class PXCMetadata:public PXCBase { +public: + PXC_CUID_OVERWRITE(0x62398423); + + /** + @brief The function returns a unique identifier for the meta data storage. + @return the unique identifier. + */ + virtual pxcUID PXCAPI QueryUID(void)=0; + + /** + @brief The function retrieves the identifiers of all available meta data. + @param[in] idx The zero-based index to retrieve all identifiers. + @return the metadata identifier, or zero if not available. + */ + virtual pxcUID PXCAPI QueryMetadata(pxcI32 idx)=0; + + /** + @brief The function detaches the specified metadata. + @param[in] id The metadata identifier. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE The metadata is not found. + */ + virtual pxcStatus PXCAPI DetachMetadata(pxcUID id)=0; + + /** + @brief The function attaches the specified metadata. + @param[in] id The metadata identifier. + @param[in] buffer The metadata buffer. + @param[in] size The metadata buffer size, in bytes. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI AttachBuffer(pxcUID id, pxcBYTE *buffer, pxcI32 size)=0; + + /** + @brief The function returns the specified metadata buffer size. + @param[in] id The metadata identifier. + @return the metadata buffer size, or zero if the metadata is not available. + */ + virtual pxcI32 PXCAPI QueryBufferSize(pxcUID id)=0; + + /** + @brief The function retrieves the specified metadata. + @param[in] id The metadata identifier. + @param[in] buffer The buffer pointer to retrieve the metadata. + @param[in] size The buffer size in bytes. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI QueryBuffer(pxcUID id, pxcBYTE *buffer, pxcI32 size)=0; + + /** + @brief The function attaches an instance of a serializeable interface to be metadata storage. + @param[in] id The metadata identifier. + @param[in] instance The serializable instance. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI AttachSerializable(pxcUID id, PXCBase *instance)=0; + + /** + @brief The function creates an instance of a serializeable interface from the metadata storage. + @param[in] id The metadata identifier. + @param[in] cuid The interface identifier. + @param[out] instance The serializable instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI CreateSerializable(pxcUID id, pxcUID cuid, void **instance)=0; + + /** + @brief The function creates an instance of a serializeable interface from the metadata storage. + @param[in] id The metadata identifier. + @param[out] instance The serializable instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + template pxcStatus __inline CreateSerializable(pxcUID id, T **instance) { + return CreateSerializable(id, T::CUID, (void**)instance); + } +}; diff --git a/modules/control/rssdk/rssdk/pxcpowerstate.h b/modules/control/rssdk/rssdk/pxcpowerstate.h new file mode 100644 index 0000000..0e03b8c --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcpowerstate.h @@ -0,0 +1,49 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2013 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcpowerstate.h + Defines the PXCPowerState interface, which exposes controls for + detecting and changing the power state of the runtimes. + */ +#pragma once +#include "pxcsession.h" + +/** + This interface manages the SDK implementation power state. Any SDK I/O + or algorithm module implementation that are power aware exposes this + interface. Programs may use the QueryInstance function to bind to this + interface from any module instance. + */ +class PXCPowerState: public PXCBase { +public: + PXC_CUID_OVERWRITE(PXC_UID('P','W','M','G')); + + enum State + { + STATE_PERFORMANCE, /* full feature set/best algorithm */ + STATE_BATTERY, + }; + + /* Query current power state of the device, returns maximal used state */ + virtual PXCPowerState::State PXCAPI QueryState()=0; + + /* Try to set power state of all used devices, all streams, application should call + QueryStream to check if the desired state was set */ + virtual pxcStatus PXCAPI SetState(State state)=0; +}; + + + + + + + + + + diff --git a/modules/control/rssdk/rssdk/pxcprojection.h b/modules/control/rssdk/rssdk/pxcprojection.h new file mode 100644 index 0000000..6c106ff --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcprojection.h @@ -0,0 +1,127 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2012-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcprojection.h + Defines the PXCProjection interface, which defines mappings between + pixel, depth, and real world coordinates. + */ +#pragma once +#include "pxcimage.h" + +/** + This interface defines mappings between various coordinate systems + used by modules of the SDK. Call the PXCCapture::Device::CreateProjection + to create an instance of this interface. + + The class extends PXCSerializeableService. Use QueryInstance + to access the PXCSerializableService interface. + */ +class PXCProjection: public PXCBase { +public: + PXC_CUID_OVERWRITE(0x494A8537); + + /** + @brief Map depth coordinates to color coordinates for a few pixels. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos_uvz The array of depth coordinates + depth value in the PXCPoint3DF32 structure. + @param[out] pos_ij The array of color coordinates, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI MapDepthToColor(pxcI32 npoints, PXCPoint3DF32 *pos_uvz, PXCPointF32 *pos_ij)=0; + + /** + @brief Map color coordinates to depth coordiantes for a few pixels. + @param[in] depth The depthmap image. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos_ij The array of color coordinates. + @param[out] pos_uv The array of depth coordinates, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI MapColorToDepth(PXCImage *depth, pxcI32 npoints, PXCPointF32 *pos_ij, PXCPointF32 *pos_uv)=0; + + /** + @brief Map depth coordinates to world coordinates for a few pixels. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos_uvz The array of depth coordinates + depth value in the PXCPoint3DF32 structure. + @param[out] pos3d The array of world coordinates, in mm, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ProjectDepthToCamera(pxcI32 npoints, PXCPoint3DF32 *pos_uvz, PXCPoint3DF32 *pos3d)=0; + + /** + @brief Map color pixel coordinates to camera coordinates for a few pixels. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos_ijz The array of color coordinates + depth value in the PXCPoint3DF32 structure. + @param[out] pos3d The array of camera coordinates, in mm, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ProjectColorToCamera(pxcI32 npoints, PXCPoint3DF32 *pos_ijz, PXCPoint3DF32 *pos3d)=0; + + /** + @brief Map camera coordinates to depth coordinates for a few pixels. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos3d The array of world coordinates, in mm. + @param[out] pos_uv The array of depth coordinates, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ProjectCameraToDepth(pxcI32 npoints, PXCPoint3DF32 *pos3d, PXCPointF32 *pos_uv)=0; + + /** + @brief Map camera coordinates to color coordinates for a few pixels. + @param[in] npoints The number of pixels to be mapped. + @param[in] pos3d The array of world coordinates, in mm. + @param[out] pos_ij The array of color coordinates, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ProjectCameraToColor(pxcI32 npoints, PXCPoint3DF32 *pos3d, PXCPointF32 *pos_ij)=0; + + /** + @brief Retrieve the UV map for the specific depth image. The UVMap is a PXCPointF32 array of depth size width*height. + @param[in] depth The depth image instance. + @param[out] uvmap The UV map, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI QueryUVMap(PXCImage *depth, PXCPointF32 *uvmap)=0; + + /** + @brief Retrieve the inverse UV map for the specific depth image. The inverse UV map maps color coordinates + back to the depth coordinates. The inverse UVMap is a PXCPointF32 array of color size width*height. + @param[in] depth The depth image instance. + @param[out] inv_uvmap The inverse UV map, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI QueryInvUVMap(PXCImage *depth, PXCPointF32 *inv_uvmap)=0; + + /** + @brief Retrieve the vertices for the specific depth image. The vertices is a PXCPoint3DF32 array of depth + size width*height. The world coordiantes units are in mm. + @param[in] depth The depth image instance. + @param[out] inv_uvmap The inverse UV map, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI QueryVertices(PXCImage *depth, PXCPoint3DF32 *vertices)=0; + + /** + @brief Get the color pixel for every depth pixel using the UV map, and output a color image, aligned in space + and resolution to the depth image. + @param[in] depth The depth image instance. + @param[in] color The color image instance. + @return The output image in the depth image resolution. + */ + virtual PXCImage* PXCAPI CreateColorImageMappedToDepth(PXCImage *depth, PXCImage *color)=0; + + /** + @brief Map every depth pixel to the color image resolution using the UV map, and output an incomplete + depth image (with holes), aligned in space and resolution to the color image. + @param[in] depth The depth image instance. + @param[in] color The color image instance. + @return The output image in the color image resolution. + */ + virtual PXCImage* PXCAPI CreateDepthImageMappedToColor(PXCImage *depth, PXCImage *color)=0; +}; diff --git a/modules/control/rssdk/rssdk/pxcsensemanager.h b/modules/control/rssdk/rssdk/pxcsensemanager.h new file mode 100644 index 0000000..f72f3e9 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcsensemanager.h @@ -0,0 +1,494 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include +#include "pxccapturemanager.h" +#include "pxcsession.h" +#include "pxcfacemodule.h" +#include "pxcemotion.h" +#include "pxctracker.h" +#include "pxchandmodule.h" +#include "pxctouchlesscontroller.h" +#include "pxc3dseg.h" + +/** + This is the main interface for the SDK pipeline. + Control the pipeline execution with this interface. +*/ +class PXCSenseManager: public PXCBase { +public: + + PXC_CUID_OVERWRITE(0xD8954321); + PXC_DEFINE_CONST(TIMEOUT_INFINITE,-1); + + /** + The PXCSenseManager callback instance. + */ + class Handler { + public: + + /** + @brief The SenseManager calls back this function when there is a device connection or + disconnection. During initialization, the SenseManager callbacks this function when + openning or closing any capture devices. + @param[in] device The video device instance. + @param[in] connected The device connection status. + @return The return status is ignored during the PXCSenseManager initialization. During + streaming, the SenseManager aborts the execution pipeline if the status is an error. + */ + virtual pxcStatus PXCAPI OnConnect(PXCCapture::Device* /*device*/, pxcBool /*connected*/) { + return PXC_STATUS_DEVICE_FAILED; + } + + /** + @brief The SenseManager calls back this function during initialization after each device + configuration is set. + @param[in] mid The module identifier. Usually this is the interface identifier, or PXCCapture::CUID+n for raw video streams. + @param[in] module The module instance, or NULL for raw video streams. + @return The SenseManager aborts the execution pipeline if the status is an error. + */ + virtual pxcStatus PXCAPI OnModuleSetProfile(pxcUID /*mid*/, PXCBase* /*module*/) { + return PXC_STATUS_NO_ERROR; + } + + /** + @brief The SenseManager calls back this function after a module completed processing the frame data. + @param[in] mid The module identifier. Usually this is the interface identifier. + @param[in] module The module instance. + @return The SenseManager aborts the execution pipeline if the status is an error. + */ + virtual pxcStatus PXCAPI OnModuleProcessedFrame(pxcUID /*mid*/, PXCBase* /*module*/, PXCCapture::Sample* /*sample*/) { + return PXC_STATUS_NO_ERROR; + } + + /** + @brief The SenseManager calls back this function when raw video streams (explicitly requested) are available. + @param[in] mid The module identifier. Usually this is the interface identifier. + @param[in] sample The sample from capture device + @return The SenseManager aborts the execution pipeline if the status is an error. + */ + virtual pxcStatus PXCAPI OnNewSample(pxcUID /*mid*/, PXCCapture::Sample* /*sample*/) { + return PXC_STATUS_NO_ERROR; + } + }; + + /** + @brief Return the PXCSession instance. Internally managed. Do not release the instance. + The session instance is managed internally by the SenseManager. Do not release the session instance. + @return The PXCSession instance. + */ + virtual PXCSession* PXCAPI QuerySession(void)=0; + + /** + @brief Return the PXCCaptureManager instance. Internally managed. Do not release the instance. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The PXCCaptureManager instance. + */ + virtual PXCCaptureManager* PXCAPI QueryCaptureManager(void)=0; + + /** + @brief Return the captured sample for the specified module or explicitly/impl requested streams. + For modules, use mid=module interface identifier. + For explictly requested streams via multiple calls to EnableStream(s), use mid=PXCCapture::CUID+0,1,2... + The captured sample is managed internally by the SenseManager. Do not release the instance. + @param[in] mid The module identifier. Usually this is the interface identifier, or PXCCapture::CUID+n for raw video streams. + @return The sample instance, or NULL if the captured sample is not available. + */ + virtual PXCCapture::Sample* PXCAPI QuerySample(pxcUID mid)=0; + + /** + @brief Return available captured sample, explicitly or implicitly requested. + The captured sample is managed internally by the SenseManager. Do not release the sample. + @return The sample instance, or NULL if the captured sample is not available. + */ + __inline PXCCapture::Sample* QuerySample(void) { + return QuerySample(0); + } + + /** + @brief Return the captured sample for the face module. + The captured sample is managed internally by the SenseManager. Do not release the sample. + @return The sample instance, or NULL if the captured sample is not available. + */ + __inline PXCCapture::Sample* QueryFaceSample(void) { + return QuerySample(PXCFaceModule::CUID); + } + + /** + @brief Return the captured sample for the hand module. + The captured sample is managed internally by the SenseManager. Do not release the sample. + @return The sample instance, or NULL if the captured sample is not available. + */ + __inline PXCCapture::Sample* QueryHandSample(void) { + return QuerySample(PXCHandModule::CUID); + } + + /** + @brief Return the captured sample for the emotion module. + The captured sample is managed internally by the SenseManager. Do not release the sample. + @return The sample instance, or NULL if the captured sample is not available. + */ + __inline PXCCapture::Sample* QueryEmotionSample(void) { + return QuerySample(PXCEmotion::CUID); + } + + /** + @brief Return the captured sample for the object tracker module. + The captured sample is managed internally by the SenseManager. Do not release the sample. + @return The sample instance, or NULL if the captured sample is not available. + */ + __inline const PXCCapture::Sample* QueryTrackerSample(void) { + return QuerySample(PXCTracker::CUID); + } + + + /** + @brief Return the module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @param[in] mid The module identifier. Usually this is the interface identifier. + @return The module instance. + */ + virtual PXCBase* PXCAPI QueryModule(pxcUID mid)=0; + + /** + @brief Return the Face module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXCFaceModule* QueryFace(void) { + PXCBase *instance=QueryModule(PXCFaceModule::CUID); + return instance?instance->QueryInstance():0; + } + + /** + @brief Return the emotion module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXCEmotion* QueryEmotion(void) { + PXCBase *instance=QueryModule(PXCEmotion::CUID); + return instance?instance->QueryInstance():0; + } + + /** + @brief Return the tracker module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXCTracker* QueryTracker(void) { + PXCBase *instance=QueryModule(PXCTracker::CUID); + return instance?instance->QueryInstance():0; + } + + + /** + @brief Return the hand module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXCHandModule* QueryHand(void) { + PXCBase *instance=QueryModule(PXCHandModule::CUID); + return instance?instance->QueryInstance():0; + } + + /** + @brief Return the Touchless module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXCTouchlessController* QueryTouchlessController(void) { + PXCBase *instance=QueryModule(PXCTouchlessController::CUID); + return instance?instance->QueryInstance():0; + } + + /** + @brief Return the 3D Segmentation module instance. Between AcquireFrame/ReleaseFrame, the function returns + NULL if the specified module hasn't completed processing the current frame of image data. + The instance is managed internally by the SenseManager. Do not release the instance. + @return The module instance. + */ + __inline PXC3DSeg* Query3DSeg(void) { + PXCBase *instance=QueryModule(PXC3DSeg::CUID); + return instance?instance->QueryInstance():0; + } + + /** + @brief Initialize the SenseManager pipeline for streaming with callbacks. The application must + enable raw streams or algorithm modules before this function. + @param[in] handler Optional callback instance. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI Init(Handler *handler)=0; + + /** + @brief Initialize the SenseManager pipeline for streaming. The application must enable raw + streams or algorithm modules before this function. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus Init(void) { + return Init(0); + } + + /** + @brief Stream frames from the capture module to the algorithm modules. The application must + initialize the pipeline before calling this function. If blocking, the function blocks until + the streaming stops (upon any capture device error or any callback function returns any error. + If non-blocking, the function returns immediately while running streaming in a thread. + AcquireFrame/ReleaseFrame are not compatible with StreamFrames. Run the SenseManager in the pulling + mode with AcquireFrame/ReleaseFrame, or the callback mode with StreamFrames. + @param[in] blocking The blocking status. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI StreamFrames(pxcBool blocking)=0; + + /** + @brief Stream frames from the capture module to the algorithm modules. The application must + initialize the pipeline before calling this function. If blocking, the function blocks until + the streaming stops (upon any capture device error or any callback function returns any error. + If non-blocking, the function returns immediately while running streaming in a thread. + @param[in] blocking The blocking status. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcBool PXCAPI IsConnected(void)=0; + + /** + @brief This function starts streaming and waits until certain events occur. If ifall=true, + the function blocks until all samples are ready and the modules completed processing the samples. + If ifall=false, the function blocks until any of the mentioned is ready. The SenseManager + pipeline pauses at this point for the application to retrieve the processed module data, until + the application calls ReleaseFrame. + AcquireFrame/ReleaseFrame are not compatible with StreamFrames. Run the SenseManager in the pulling + mode with AcquireFrame/ReleaseFrame, or the callback mode with StreamFrames. + @param[in] ifall If true, wait for all modules to complete processing the data. + @param[in] timeout The time out value in milliseconds. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI AcquireFrame(pxcBool ifall, pxcI32 timeout)=0; + + /** + @brief This function starts streaming and waits until certain events occur. If ifall=true, + the function blocks until all samples are ready and the modules completed processing the samples. + If ifall=false, the function blocks until any of the mentioned is ready. The SenseManager + pipeline pauses at this point for the application to retrieve the processed module data, until + the application calls ReleaseFrame. + AcquireFrame/ReleaseFrame are not compatible with StreamFrames. Run the SenseManager in the pulling + mode with AcquireFrame/ReleaseFrame, or the callback mode with StreamFrames. + @param[in] ifall If true, wait for all modules to complete processing the data. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus AcquireFrame(pxcBool ifall=true) { + return AcquireFrame(ifall, (pxcI32)TIMEOUT_INFINITE); + } + + /** + @reserved DO NOT USE THIS FUNCTION. + @brief This function discards any internally cached sample from the capture device (and restart + new streaming.) Use this function together after file playback repositioning to avoid any caching + effects. Use also this function in the snapshot mode to get the most recent sample without any + streaming caching effect. + */ + virtual void PXCAPI FlushFrame(void)=0; + + /** + @brief This function resumes streaming after AcquireFrame. + AcquireFrame/ReleaseFrame are not compatible with StreamFrames. Run the SenseManager in the pulling + mode with AcquireFrame/ReleaseFrame, or the callback mode with StreamFrames. + */ + virtual void PXCAPI ReleaseFrame(void)=0; + + /** + @brief This function closes the execution pipeline. + */ + virtual void PXCAPI Close(void)=0; + + /** + @brief Explicitly request to stream the specified raw streams. If specified more than a stream, + SenseManager will synchronize these streams. If called multiple times, the function treats each + stream request as independent (unaligned.) The stream identifier is PXCCapture::CUID+n. + @param[in] sdesc The stream descriptor. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI EnableStreams(PXCVideoModule::DataDesc *sdesc)=0; + + /** + @brief Explicitly request to stream the specified raw stream. If specified more than one stream, + SenseManager will synchronize these streams. If called multiple times, the function treats each + stream request as independent (unaligned). The stream identifier is PXCCapture::CUID+n. + @param[in] type The stream type. + @param[in] width Optional width. + @param[in] height Optional height. + @param[in] fps Optional frame rate. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableStream(PXCCapture::StreamType type, pxcI32 width=0, pxcI32 height=0, pxcF32 fps=0) { + PXCVideoModule::DataDesc ddesc={}; + ddesc.deviceInfo.streams = type; + PXCVideoModule::StreamDesc& sdesc=ddesc.streams[type]; + sdesc.sizeMin.width=sdesc.sizeMax.width=width; + sdesc.sizeMin.height=sdesc.sizeMax.height=height; + sdesc.frameRate.min=fps; + sdesc.frameRate.max=fps; + return EnableStreams(&ddesc); + } + + /** + @brief Enable a module in the pipeline. + @param[in] mid The module identifier. This is usually the interface identifier. + @param[in] mdesc The module descriptor. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI EnableModule(pxcUID mid, PXCSession::ImplDesc *mdesc)=0; + + /** + @brief Enable the face module in the pipeline. + @param[in] name The optional module name. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableFace(pxcCHAR *name=0) { + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXCFaceModule::CUID; + if (name) wcscpy_s(mdesc.friendlyName, name); + return EnableModule(PXCFaceModule::CUID,&mdesc); + } + + /** + @brief Enable the emotion module in the pipeline. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableEmotion(void) { + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXCEmotion::CUID; + return EnableModule(PXCEmotion::CUID,&mdesc); + } + + /** + @brief Enable the Tracker module in the pipeline. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableTracker(void) { + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXCTracker::CUID; + return EnableModule(PXCTracker::CUID,&mdesc); + } + + + /** + @brief Enable the hand module in the pipeline. + @param[in] name The optional module name. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableHand(pxcCHAR *name=0) { + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXCHandModule::CUID; + if (name) wcscpy_s(mdesc.friendlyName, name); + return EnableModule(PXCHandModule::CUID,&mdesc); + } + + /** + @brief Enable the touchless controller module in the pipeline. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus EnableTouchlessController(void){ + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXCTouchlessController::CUID; + return EnableModule(PXCTouchlessController::CUID,&mdesc); + } + + /** + @brief Enable the 3D Segmentation module in the pipeline. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus Enable3DSeg(pxcCHAR *name = NULL) { + PXCSession::ImplDesc mdesc; + memset(&mdesc,0,sizeof(mdesc)); + mdesc.cuids[0]=PXC3DSeg::CUID; + if (name) wcscpy_s(mdesc.friendlyName,name); + return EnableModule(PXC3DSeg::CUID,&mdesc); + } + + /** + @brief Pause/Resume the execution of the specified module. + @param[in] mid The module identifier. This is usually the interface identifier. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + virtual void PXCAPI PauseModule(pxcUID mid, pxcBool pause)=0; + + /** + @brief Pause/Resume the execution of the face module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void PauseFace(pxcBool pause) { + PauseModule(PXCFaceModule::CUID,pause); + } + + /** + @brief Pause/Resume the execution of the emotion module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void PauseEmotion(pxcBool pause) { + PauseModule(PXCEmotion::CUID,pause); + } + + /** + @brief Pause/Resume the execution of the Tracker module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void PauseTracker(pxcBool pause) { + PauseModule(PXCTracker::CUID,pause); + } + + + /** + @brief Pause/Resume the execution of the hand module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void PauseHand(pxcBool pause) { + PauseModule(PXCHandModule::CUID,pause); + } + + /** + @brief Pause/Resume the execution of the touchless controller module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void PauseTouchlessController(pxcBool pause) { + PauseModule(PXCTouchlessController::CUID,pause); + } + + /** + @brief Pause/Resume the execution of the 3D Segmentation module. + @param[in] pause If true, pause the module. Otherwise, resume the module. + */ + __inline void Pause3DSeg(pxcBool pause) { + PauseModule(PXC3DSeg::CUID,pause); + } + + /** + @brief Create an instance of the PXCSenseManager instance. + @return The PXCSenseManager instance. + */ + __inline static PXCSenseManager* CreateInstance(void) { + PXCSession *session=PXCSession_Create(); + if (!session) return 0; + PXCSenseManager *sm=session->CreateSenseManager(); + session->Release(); + return sm; + } +}; diff --git a/modules/control/rssdk/rssdk/pxcsession.h b/modules/control/rssdk/rssdk/pxcsession.h new file mode 100644 index 0000000..a1ad69b --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcsession.h @@ -0,0 +1,310 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcsession.h + Defines the PXCSession interface, which maintains the SDK context. The + application can query and create instances of I/O and algorithm module + implementations. +*/ +#pragma once +#include "pxcbase.h" +#include "pxcversion.h" +#include "pxcimage.h" +#include "pxcaudio.h" + +class PXCSenseManager; +class PXCCaptureManager; +class PXCAudioSource; +class PXCSession; +extern "C" PXCSession* PXCAPI PXCSession_Create(void); + +/** + This class defines a standard interface for maintaining the SDK context. + The application can query and create instances of I/O and algorithm module + implementations. + + The interface extends PXCMetadata. Use QueryInstance() to access + the PXCMetadata features. +*/ +class PXCSession:public PXCBase { +public: + PXC_CUID_OVERWRITE(PXC_UID('S','E','S',' ')); + + /** + @structure ImplVersion + Describe the video streams requested by a module implementation. + */ + struct ImplVersion { + pxcI16 major; /* The major version number */ + pxcI16 minor; /* The minor version number */ + }; + + /** + @enum ImplGroup + The SDK group I/O and algorithm modules into groups and subgroups. + This is the enumerator for algorithm groups. + */ + enum ImplGroup { + IMPL_GROUP_ANY = 0, /* Undefine group */ + IMPL_GROUP_OBJECT_RECOGNITION = 0x00000001, /* Object recognition algorithms */ + IMPL_GROUP_SPEECH_RECOGNITION = 0x00000002, /* Speech recognition algorithms */ + IMPL_GROUP_SENSOR = 0x00000004, /* I/O modules */ + IMPL_GROUP_CORE = 0x80000000, /* Core SDK modules */ + IMPL_GROUP_USER = 0x40000000, /* User defined algorithms */ + }; + + /** + @enum ImplSubgroup + The SDK group I/O and algorithm modules into groups and subgroups. + This is the enumerator for algorithm subgroups. + */ + enum ImplSubgroup { + IMPL_SUBGROUP_ANY = 0, /* Undefined subgroup */ + + /* object recognition building blocks */ + IMPL_SUBGROUP_FACE_ANALYSIS = 0x00000001, /* face analysis subgroup */ + IMPL_SUBGROUP_GESTURE_RECOGNITION = 0x00000010, /* gesture recognition subgroup */ + IMPL_SUBGROUP_SEGMENTATION = 0x00000020, /* segmentation subgroup */ + IMPL_SUBGROUP_PULSE_ESTIMATION = 0x00000040, /* pulse estimation subgroup */ + IMPL_SUBGROUP_EMOTION_RECOGNITION = 0x00000080, /* emotion recognition subgroup */ + IMPL_SUBGROUP_OBJECT_TRACKING = 0x00000100, /* object detection subgroup */ + IMPL_SUBGROUP_3DSEG = 0x00000200, + + /* sensor building blocks */ + IMPL_SUBGROUP_AUDIO_CAPTURE = 0x00000001, /* audio capture subgroup */ + IMPL_SUBGROUP_VIDEO_CAPTURE = 0x00000002, /* video capture subgroup */ + + /* speech recognition building blocks */ + IMPL_SUBGROUP_SPEECH_RECOGNITION = 0x00000001, /* speech recognition subgroup */ + IMPL_SUBGROUP_SPEECH_SYNTHESIS = 0x00000002, /* speech synthesis subgroup */ + }; + + /** + @structure ImplDesc + The module descriptor lists details about the module implementation. + */ + struct ImplDesc { + ImplGroup group; /* implementation group */ + ImplSubgroup subgroup; /* implementation sub-group */ + pxcUID algorithm; /* algorithm identifier */ + pxcUID iuid; /* implementation unique id */ + ImplVersion version; /* implementation version */ + pxcI32 reserved2; + pxcI32 merit; /* implementation merit */ + pxcI32 vendor; /* vendor */ + pxcUID cuids[4]; /* interfaces supported by implementation */ + pxcCHAR friendlyName[256]; /* friendly name */ + pxcI32 reserved[12]; + }; + + /** + @brief Return the SDK version. + @return the SDK version. + */ + virtual ImplVersion PXCAPI QueryVersion(void)=0; + + /** + @brief Search a module implementation. + @param[in] templat The template for the module search. Zero field values match any. + @param[in] idx The zero-based index to retrieve multiple matches. + @param[out] desc The matched module descritpor, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + virtual pxcStatus PXCAPI QueryImpl(ImplDesc *templat, pxcI32 idx, ImplDesc *desc)=0; + + /** + @brief Create an instance of the specified module. + @param[in] desc The module descriptor. + @param[in] iuid Optional module implementation identifier. + @param[in] cuid Optional interface identifier. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + virtual pxcStatus PXCAPI CreateImpl(ImplDesc *desc, pxcUID iuid, pxcUID cuid, void **instance)=0; + + /** + @brief Create an instance of the specified module. + @param[in] desc The module descriptor. + @param[in] cuid Optional interface identifier. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + pxcStatus __inline CreateImpl(ImplDesc *desc, pxcUID cuid, void **instance) { + return CreateImpl(desc,0,cuid,instance); + } + + /** + @brief Create an instance of the specified module. + @param[in] cuid Optional interface identifier. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + pxcStatus __inline CreateImpl(pxcUID cuid, void **instance) { + return CreateImpl(0, cuid,instance); + } + + /** + @brief Create an instance of the specified module of the specified type. + @param[in] desc The module descriptor. + @param[in] iuid Optional module implementation identifier. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + template pxcStatus __inline CreateImpl(ImplDesc *desc, pxcUID iuid, T **instance) { + return CreateImpl(desc,iuid,T::CUID,(void**)instance); + } + + /** + @brief Create an instance of the specified module of the specified type. + @param[in] desc The module descriptor. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + template pxcStatus __inline CreateImpl(ImplDesc *desc, T **instance) { + return CreateImpl(desc,T::CUID,(void**)instance); + } + + /** + @brief Create an instance of the specified module of the specified type. + @param[in] iuid Optional module implementation identifier. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + template pxcStatus __inline CreateImpl(pxcUID iuid, T **instance) { + return CreateImpl(0,iuid,T::CUID,(void**)instance); + } + + /** + @brief Create an instance of the specified module of the specified type. + @param[out] instance The created instance, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No matched module implementation. + */ + template pxcStatus __inline CreateImpl(T **instance) { + return CreateImpl(T::CUID,(void**)instance); + } + + /** + @brief Create an instance of the PXCSenseManager interface. + @return The PXCSenseManager instance. + */ + __inline PXCSenseManager *CreateSenseManager(void) { + PXCSenseManager *sm=0; + CreateImpl(0, PXC_UID('P','P','U','T'), 0, (void**)&sm); + return sm; + } + + /** + @brief Create an instance of the PXCCaptureManager interface. + @return The PXCCaptureManager instance. + */ + __inline PXCCaptureManager* CreateCaptureManager(void) { + PXCCaptureManager *cm=0; + CreateImpl(0, PXC_UID('C','P','U','T'), 0, (void**)&cm); + return cm; + } + + /** + @brief Create an instance of the PXCAudioSource interface. + @return The PXCAudioSource instance. + */ + __inline PXCAudioSource *CreateAudioSource(void) { + PXCAudioSource *am=0; + CreateImpl(0, PXC_UID('A','D','S','R'), 0, (void**)&am); + return am; + } + + /** + @brief Return the module descriptor + @param[in] module The module instance + @param[out] desc The module descriptor, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE Failed to identify the module instance. + */ + virtual pxcStatus PXCAPI QueryModuleDesc(PXCBase *module, PXCSession::ImplDesc *desc) = 0; + + /** + @brief Create an instance of the PXCImage interface with data. The application must + maintain the life cycle of the image data for the PXCImage instance. + @param[in] info The format and resolution of the image. + @param[in] data Optional image data. + @return The PXCImage instance. + */ + virtual PXCImage* PXCAPI CreateImage(PXCImage::ImageInfo *info, PXCImage::ImageData *data)=0; + + /** + @brief Create an instance of the PXCImage interface. + @param[in] info The format and resolution of the image. + @return The PXCImage instance. + */ + __inline PXCImage* CreateImage(PXCImage::ImageInfo *info) { + return CreateImage(info, 0); + } + + /** + @brief Create an instance of the PXCAudio interface with data. The application must + maintain the life cycle of the audio data for the PXCAudio instance. + @param[in] info The audio channel information. + @param[in] data Optional audio data. + @return The PXCAudio instance. + */ + virtual PXCAudio* PXCAPI CreateAudio(PXCAudio::AudioInfo *info, PXCAudio::AudioData *data)=0; + + /** + @brief Create an instance of the PXCAudio interface. + @param[in] info The audio channel information. + @return The PXCAudio instance. + */ + __inline PXCAudio* CreateAudio(PXCAudio::AudioInfo *info) { + return CreateAudio(info, 0); + } + + /** + @brief Load the module from a file. + @param[in] moduleName The module file name. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI LoadImplFromFile(pxcCHAR *moduleName)=0; + + /** + @brief Unload the specified module. + @param[in] moduleName The module file name. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI UnloadImplFromFile(pxcCHAR *moduleName)=0; + + /** + @brief Create an instance of the PXCSession interface. + @return The PXCSession instance + */ + __inline static PXCSession* CreateInstance(void) { + return PXCSession_Create(); + } +}; + +/** + A helper function for bitwise OR of two flags. +*/ +__inline static PXCSession::ImplGroup operator|(PXCSession::ImplGroup a, PXCSession::ImplGroup b) { + return (PXCSession::ImplGroup)((int)a | (int)b); +} + +/** + A helper function for bitwise OR of two flags. +*/ +__inline static PXCSession::ImplSubgroup operator|(PXCSession::ImplSubgroup a, PXCSession::ImplSubgroup b) { + return (PXCSession::ImplSubgroup)((int)a | (int)b); +} diff --git a/modules/control/rssdk/rssdk/pxcspeechrecognition.h b/modules/control/rssdk/rssdk/pxcspeechrecognition.h new file mode 100644 index 0000000..4c1564c --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcspeechrecognition.h @@ -0,0 +1,191 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcspeechrecognition.h + */ +#pragma once +#include "pxcaudiosource.h" + +/** + This class defines a standard interface for performing speech recognition. +*/ +class PXCSpeechRecognition:public PXCBase { +public: + PXC_CUID_OVERWRITE(0x8013C527); + PXC_DEFINE_CONST(NBEST_SIZE,4); + PXC_DEFINE_CONST(DICTATION_BUFFER_SIZE,1024); + PXC_DEFINE_CONST(TAG_BUFFER_SIZE,1024); + + /** + @struct NBest + The NBest data structure describes the NBest data returned from the recognition engine. + */ + struct NBest { + pxcI32 label; /** The label that refers to the recognized speech */ + pxcI32 confidence; /** The confidence score of the recognitio: 0-100. */ + }; + + /** + @struct RecognitionData + The data structure describes the recgonized speech data. + */ + struct RecognitionData { + pxcI64 timeStamp; /** The time stamp of the recognition, in 100ns. */ + pxcUID grammar; /** The grammar identifier for command and control, or zero for dictation. */ + pxcI32 duration; /** The duration of the speech, in ms. */ + NBest scores[NBEST_SIZE]; /** The top-N recognition results for command and control. */ + pxcI32 reserved[16]; /** @reserved */ + pxcCHAR dictation[DICTATION_BUFFER_SIZE]; /** The recognized dictation data */ + pxcCHAR tags[TAG_BUFFER_SIZE]; /** @reserved Additional tags */ + }; + + /** + @enum AlertType + Enumerates all supported alert events. + */ + enum AlertType { // TODO mynikols rename + ALERT_VOLUME_HIGH = 0x00001, /** The volume is too high. */ + ALERT_VOLUME_LOW = 0x00002, /** The volume is too low. */ + ALERT_SNR_LOW = 0x00004, /** Too much noise. */ + ALERT_SPEECH_UNRECOGNIZABLE = 0x00008, /** There is some speech available but not recognizable. */ + ALERT_SPEECH_BEGIN = 0x00010, /** The begining of a speech */ + ALERT_SPEECH_END = 0x00020, /** The end of a speech */ + ALERT_RECOGNITION_ABORTED = 0x00040, /** The recognition is aborted due to device lost, engine error, etc */ + ALERT_RECOGNITION_END = 0x00080, /** The recognition is completed. The audio source no longer provides data. */ + }; + + /** + @struct AlertData + Describe the alert parameters. + */ + struct AlertData { + pxcI64 timeStamp; /** The time stamp of when the alert occurs, in 100ns. */ + AlertType label; /** The alert event label */ + pxcI32 reserved[6]; + }; + + /** + The handler class for the recognition events. + */ + class Handler { + public: + + /** + @brief The function is invoked when there is some speech recognized. + @param[in] data The data structure to describe the recognized speech. + */ + virtual void PXCAPI OnRecognition(const RecognitionData* /*data*/) {} + + /** + @brief The function is triggered by any alert event. + @param[in] data The data structure to describe the alert. + */ + virtual void PXCAPI OnAlert(const AlertData* /*data*/) {} + }; + + /** + @enum LanguageType + Enumerate all supported languages. + */ + enum LanguageType { + LANGUAGE_US_ENGLISH = PXC_UID('e','n','U','S'), /** US English */ + LANGUAGE_GB_ENGLISH = PXC_UID('e','n','G','B'), /** British English */ + LANGUAGE_DE_GERMAN = PXC_UID('d','e','D','E'), /** German */ + LANGUAGE_US_SPANISH = PXC_UID('e','s','U','S'), /** Spanish */ + LANGUAGE_FR_FRENCH = PXC_UID('f','r','F','R'), /** French */ + LANGUAGE_IT_ITALIAN = PXC_UID('i','t','I','T'), /** Italian */ + LANGUAGE_JP_JAPANESE = PXC_UID('j','a','J','P'), /** Japanese */ + LANGUAGE_CN_CHINESE = PXC_UID('z','h','C','N'), /** Simplified Chinese */ + LANGUAGE_BR_PORTUGUESE = PXC_UID('p','t','B','R'), /** Portuguese */ + }; + + /** + Describe the algorithm configuration parameters. + */ + struct ProfileInfo { + pxcCHAR speaker[128]; /** The optional speaker name for adaptation */ + LanguageType language; /** The supported language */ + pxcI32 endOfSentence; /** The length of end of sentence silence in ms */ + pxcI32 threshold; /** The recognition confidence threshold: 0-100 */ + pxcI32 reserved[13]; + }; + + /** + @brief The function returns the available algorithm configurations. + @param[in] idx The zero-based index to retrieve all algorithm configurations. + @param[out] pinfo The algorithm configuration, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE There is no more configuration. + */ + virtual pxcStatus PXCAPI QueryProfile(pxcI32 idx, ProfileInfo *pinfo)=0; + + /** + @brief The function returns the working algorithm configurations. + @param[out] pinfo The algorithm configuration, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + pxcStatus __inline QueryProfile(ProfileInfo *pinfo) { + return QueryProfile(WORKING_PROFILE,pinfo); + } + + /** + @brief The function sets the working algorithm configurations. + @param[in] config The algorithm configuration. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetProfile(ProfileInfo *config)=0; + + /** + @brief The function builds the recognition grammar from the list of strings. + @param[in] gid The grammar identifier. Can be any non-zero number. + @param[in] cmds The string list. + @param[in] labels Optional list of labels. If not provided, the labels are 1...ncmds. + @param[in] ncmds The number of strings in the string list. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI BuildGrammarFromStringList(pxcUID gid, pxcCHAR *cmds[], pxcI32 *labels, pxcI32 ncmds)=0; + + /** + @brief The function deletes the specified grammar and releases any resources allocated. + @param[in] gid The grammar identifier. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE The grammar is not found. + */ + virtual pxcStatus PXCAPI ReleaseGrammar(pxcUID gid)=0; + + /** + @brief The function sets the active grammar for recognition. + @param[in] gid The grammar identifier. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE The grammar is not found. + */ + virtual pxcStatus PXCAPI SetGrammar(pxcUID gid)=0; + + /** + @brief The function sets the dictation recognition mode. + The function may take some time to initialize. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + pxcStatus __inline SetDictation(void) { + return SetGrammar(0); + } + + /** + @brief The function starts voice recognition. + @param[in] source The optional audio source. If omitted, use system default. + @param[in] handler The callback handler instance. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI StartRec(PXCAudioSource *source, Handler *handler)=0; + + /** + @brief The function stops voice recognition immediately. + */ + virtual void PXCAPI StopRec(void)=0; +}; diff --git a/modules/control/rssdk/rssdk/pxcspeechsynthesis.h b/modules/control/rssdk/rssdk/pxcspeechsynthesis.h new file mode 100644 index 0000000..b22c78f --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcspeechsynthesis.h @@ -0,0 +1,124 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** + @file pxcspeechsynthesis.h + */ +#pragma once +#include "pxcaudio.h" + +/** + This class defines a standard interface for performing speech synthesis. + */ +class PXCSpeechSynthesis: public PXCBase { +public: + + PXC_CUID_OVERWRITE(PXC_UID('V','I','T','S')); + + /** + @enum LanguageType + Enumerate all supported languages. + */ + enum LanguageType { + LANGUAGE_US_ENGLISH = PXC_UID('e','n','U','S'), /** US English */ + LANGUAGE_GB_ENGLISH = PXC_UID('e','n','G','B'), /** British English */ + LANGUAGE_DE_GERMAN = PXC_UID('d','e','D','E'), /** German */ + LANGUAGE_US_SPANISH = PXC_UID('e','s','U','S'), /** Spanish */ + LANGUAGE_FR_FRENCH = PXC_UID('f','r','F','R'), /** French */ + LANGUAGE_IT_ITALIAN = PXC_UID('i','t','I','T'), /** Italian */ + LANGUAGE_JP_JAPANESE = PXC_UID('j','a','J','P'), /** Japanese */ + LANGUAGE_CN_CHINESE = PXC_UID('z','h','C','N'), /** Simplified Chinese */ + LANGUAGE_BR_PORTUGUESE = PXC_UID('p','t','B','R'), /** Portuguese */ + }; + + /** + @enum VoiceType + Enumerate all supported voices. + */ + enum VoiceType { + VOICE_ANY=0, /* Any available voice */ + }; + + /** + @struct ProfileInfo + Describe the algorithm configuration parameters. + */ + struct ProfileInfo { + PXCAudio::AudioInfo outputs; /** The synthesized audio format. Adjust bufferSize for the required latency. */ + LanguageType language; /** The supported language */ + VoiceType voice; /** The voice */ + pxcF32 rate; /** The speaking speed. The default is 1.0. Smaller is slower and bigger is faster. */ + pxcI32 volume; /** The speaking volume from 0 to 100 (loudest). */ + pxcI32 reserved[4]; + }; + + /** + @brief The function returns the available algorithm configuration parameters. + @param[in] pidx The zero-based index to retrieve all configuration parameters. + @param[out] pinfo The configuration parameters, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No more configurations. + */ + virtual pxcStatus PXCAPI QueryProfile(pxcI32 pidx, ProfileInfo *pinfo)=0; + + /** + @brief The function returns the current working algorithm configuration parameters. + @param[out] pinfo The configuration parameters, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + pxcStatus __inline QueryProfile(ProfileInfo *pinfo) { return QueryProfile(WORKING_PROFILE,pinfo); } + + /** + @brief The function sets the current working algorithm configuration parameters. + @param[in] pinfo The configuration parameters. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetProfile(ProfileInfo *pinfo)=0; + + /** + @brief The function synthesizes the sentence for later use. The function may take some time + to generate the fully synthesized speech. + @param[in] sid The sentence identifier. Can be any non-zero unique number. + @param[in] sentence The sentence string. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI BuildSentence(pxcUID sid, pxcCHAR *sentence)=0; + + /** + @brief The function retrieves the PXCAudio buffer for the specified sentence. There could be more + than one PXCAudio buffer. The application should keep retrieving with increased index, until the + function returns NULL. The audio buffer is internally managed. Do not release the instance. + @param[in] sid The sentence identifier. + @param[in] idx The zero-based index to retrieve multiple samples. + @return the Audio buffer, or NULL if there is no more. + */ + virtual PXCAudio* PXCAPI QueryBuffer(pxcUID sid, pxcI32 idx)=0; + + /** + @brief The function returns the number of PXCAudio buffers used for the specified + synthesized sentence. + @param[in] sid The sentence identifier. + @return the number of PXCAudio buffers, or 0 if the sentence is not found. + */ + virtual pxcI32 PXCAPI QueryBufferNum(pxcUID sid)=0; + + /** + @brief The function returns the number of audio samples for the specified synthesized sentence. + Each audio sample consists of multiple channels according to the format definition. + @param[in] sid The sentence identifier. + @return the sample number, or 0 if the sentence is not found. + */ + virtual pxcI32 PXCAPI QuerySampleNum(pxcUID sid)=0; + + /** + @brief The function releases any resources allocated for the sentence identifier. + @param[in] sid The sentence identifier. + */ + virtual void PXCAPI ReleaseSentence(pxcUID sid)=0; +}; diff --git a/modules/control/rssdk/rssdk/pxcstatus.h b/modules/control/rssdk/rssdk/pxcstatus.h new file mode 100644 index 0000000..2cd1179 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcstatus.h @@ -0,0 +1,63 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2013 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcstatus.h + Defines the return status codes used by SDK interfaces. + */ +#pragma once + +/** + This enumeration defines various return codes that SDK interfaces + use. Negative values indicate errors, a zero value indicates success, + and positive values indicate warnings. + */ +enum pxcStatus { + /* success */ + PXC_STATUS_NO_ERROR=0, /** Indicates the operation succeeded without any warning */ + + /* errors */ + PXC_STATUS_FEATURE_UNSUPPORTED= -1, /** Unsupported feature */ + PXC_STATUS_PARAM_UNSUPPORTED= -2, /** Unsupported parameter(s) */ + PXC_STATUS_ITEM_UNAVAILABLE= -3, /** Item not found/not available */ + + PXC_STATUS_HANDLE_INVALID= -101, /** Invalid session, algorithm instance, or pointer */ + PXC_STATUS_ALLOC_FAILED= -102, /** Memory allocation failure */ + + PXC_STATUS_DEVICE_FAILED= -201, /** device failed due to malfunctioning */ + PXC_STATUS_DEVICE_LOST= -202, /** device failed due to unplug or unavailability */ + PXC_STATUS_DEVICE_BUSY= -203, /** device busy */ + + PXC_STATUS_EXEC_ABORTED= -301, /** Execution aborted due to errors in upstream components */ + PXC_STATUS_EXEC_INPROGRESS= -302, /** Asynchronous operation is in execution */ + PXC_STATUS_EXEC_TIMEOUT= -303, /** Operation time out */ + + PXC_STATUS_FILE_WRITE_FAILED= -401, /** Failure in open file in WRITE mode */ + PXC_STATUS_FILE_READ_FAILED= -402, /** Failure in open file in READ mode */ + PXC_STATUS_FILE_CLOSE_FAILED= -403, /** Failure in close a file handle */ + + PXC_STATUS_DATA_UNAVAILABLE= -501, /** Data not available for MW model or processing */ + + PXC_STATUS_DATA_NOT_INITIALIZED= -502, /** Data failed to initialize */ + PXC_STATUS_INIT_FAILED= -503, /** Module failure during initialization */ + + + PXC_STATUS_STREAM_CONFIG_CHANGED= -601, /** Configuration for the stream has changed */ + + PXC_STATUS_POWER_UID_ALREADY_REGISTERED = -701, + PXC_STATUS_POWER_UID_NOT_REGISTERED = -702, + PXC_STATUS_POWER_ILLEGAL_STATE = -703, + PXC_STATUS_POWER_PROVIDER_NOT_EXISTS = -704, + PXC_STATUS_CAPTURE_CONFIG_ALREADY_SET= -801, /** parameter cannot be changed since configuration for capturing has been already set */ + + /* warnings */ + PXC_STATUS_TIME_GAP= 101, /** time gap in time stamps */ + PXC_STATUS_PARAM_INPLACE= 102, /** the same parameters already defined */ + PXC_STATUS_DATA_NOT_CHANGED = 103, /** Data not changed (no new data available)*/ + PXC_STATUS_PROCESS_FAILED= 104 /** Module failure during processing */ +}; diff --git a/modules/control/rssdk/rssdk/pxcsyncpoint.h b/modules/control/rssdk/rssdk/pxcsyncpoint.h new file mode 100644 index 0000000..316dc9f --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcsyncpoint.h @@ -0,0 +1,124 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2011-2013 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +/** @file pxcscheduler.h + Defines the PXCScheduler interface, which is used for controlling + asynchronous pipeline execution. + */ +#pragma once +#include "pxcbase.h" + +/** + This interface manages asynchronous pipeline execution. The application calls an + asynchronous function, which will return immediately with an SP. The application then + synchronize the SP to retrieve the function results. + */ +class PXCSyncPoint:public PXCBase { +public: + + PXC_CUID_OVERWRITE(PXC_UID('S','H','S','P')); + PXC_DEFINE_CONST(TIMEOUT_INFINITE,-1); + PXC_DEFINE_CONST(SYNCEX_LIMIT,64); + + /** + @brief The function synchronizes a single SP with timeout. + @param[in] timeout The timeout value in ms. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_EXEC_TIMEOUT The timeout value is reached. + */ + virtual pxcStatus PXCAPI Synchronize(pxcI32 timeout)=0; + + /** + @brief The function synchronizes a single SP infinitely. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + pxcStatus __inline Synchronize(void) { return Synchronize(TIMEOUT_INFINITE); } + +protected: + + /** + @reserved + Internal function. Do not use. + */ + virtual pxcStatus PXCAPI SynchronizeExINT(pxcI32 n1, PXCSyncPoint **sps, pxcI32 n2, void **events, pxcI32 *idx, pxcI32 timeout)=0; + +public: + + /** + @brief The function synchronizes multiple SPs as well as OS events. Zero SPs or OS events are skipped automatically. + If the idx argument is NULL, the function waits until all events are signaled. + If the idx argument is not NULL, the function waits until any of the events is signaled and returns the index of the signalled events. + @param[in] n The number of SPs to be synchronized. + @param[in] sps The SP array. + @param[in] n2 The number of OS events to be synchronized. + @param[in] events The OS event array. + @param[out] idx The event index, to be returned. + @param[in] timeout The timeout value in ms. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_EXEC_TIMEOUT The timeout value is reached. + */ + __inline static pxcStatus SynchronizeEx(pxcI32 n, PXCSyncPoint **sps, pxcI32 n2, void **events, pxcI32 *idx, pxcI32 timeout) { + for (int i=0;iSynchronizeExINT(n,sps,n2,events,idx,timeout); + return PXC_STATUS_HANDLE_INVALID; + } + + /** + @brief The function synchronizes multiple SPs. Zero SPs are skipped automatically. + If the idx argument is NULL, the function waits until all events are signaled. + If the idx argument is not NULL, the function waits until any of the events is signaled and returns the index of the signalled events. + @param[in] n The number of SPs to be synchronized. + @param[in] sps The SP array. + @param[out] idx The event index, to be returned. + @param[in] timeout The timeout value in ms. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_EXEC_TIMEOUT The timeout value is reached. + */ + __inline static pxcStatus SynchronizeEx(pxcI32 n, PXCSyncPoint **sps, pxcI32 *idx, pxcI32 timeout) { + return SynchronizeEx(n, sps, 0, 0, idx, timeout); + } + + /** + @brief The function synchronizes multiple SPs infinitely. Zero SPs are skipped automatically. + If the idx argument is NULL, the function waits until all events are signaled. + If the idx argument is not NULL, the function waits until any of the events is signaled and returns the index of the signalled events. + @param[in] n The number of SPs to be synchronized. + @param[in] sps The SP array. + @param[out] idx The event index, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline static pxcStatus SynchronizeEx(pxcI32 n, PXCSyncPoint **sps, pxcI32 *idx) { + return SynchronizeEx(n,sps,idx,(pxcI32)TIMEOUT_INFINITE); + } + + /** + @brief The function synchronizes multiple SPs infinitely and returns until all events are signalled. + Zero SPs are skipped automatically. + @param[in] n The number of SPs to be synchronized. + @param[in] sps The SP array. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline static pxcStatus SynchronizeEx(pxcI32 n, PXCSyncPoint **sps) { + return SynchronizeEx(n,sps,0); + } + + /** + @brief The function releases the elements of an SP array, if the elements are not NULL. + @param[in] objects The SP array. + @param[in] startIndex The start index. + @param[in] nitems The number of items. + */ + __inline static void ReleaseSP(PXCSyncPoint **objects, int startIndex, pxcI32 nitems) { + for (int i=startIndex;iRelease(); + objects[i]=0; + } + } + +}; diff --git a/modules/control/rssdk/rssdk/pxctouchlesscontroller.h b/modules/control/rssdk/rssdk/pxctouchlesscontroller.h new file mode 100644 index 0000000..4c95ee8 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxctouchlesscontroller.h @@ -0,0 +1,262 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxccapture.h" +#include "pxchandmodule.h" +#include "pxchanddata.h" +/** + @class PXCTouchlessController + + @brief This module interpert user actions to UX commands intended to control a windows 8 computer, + such as scroll, zoom, select atile etc. The module fire events for each such action as well as inject + touch, mouse and keyboard event to the operating system to perform the action. + Developer may listen to such events to enable application specific reactions, or just enable this module + and depend on the normal OS reactions to the injected events. + There is also a WPF dll that provides default visual feedback which may be easily linked to those events, + see touchless_controller_visual_feedback sample. + Few configuration options are available for developers to influence the way the module opareate, + like enabling or disabling specific behaviors. + */ + +class PXCTouchlessController: public PXCBase { +public: + + PXC_CUID_OVERWRITE(PXC_UID('F','L','K','S')); + + struct ProfileInfo + { + typedef pxcEnum Configuration; // an or value of UX options relevant to specific application + enum { + Configuration_None = 0x00000000, // No option is selected - use default behavior + Configuration_Allow_Zoom = 0x00000001, // Should zoom be allowed + Configuration_Use_Draw_Mode = 0x00000002, // Use draw mode - should be used for applications the need continues interaction (touch + movement) like drawing + Configuration_Scroll_Horizontally = 0x00000004, // Enable horizontal scrolling + Configuration_Scroll_Vertically = 0x00000008, // Enable vertical scrolling + Configuration_Meta_Context_Menu = 0x00000010, // Disable the injection of keyboar/mouse/touch events + Configuration_Enable_Injection = 0x00000020, // Disable the injection of keyboar/mouse/touch events + Configuration_Edge_Scroll_Horizontally = 0x00000040, // Enable horizontal scrolling + Configuration_Edge_Scroll_Vertically = 0x00000080, // Enable vertical scrolling + Configuration_Hide_Cursor_After_Touch_Injection = 0x00000100 // Should windows cursor be hidden after touch injection - other wise windows will make the cursor reappear + }; + + + PXCHandModule* handModule; //the HandAnalysis module used by this module, dont set it when using SenseManager - this is just an output parameter + Configuration config; // An or value of configuration options + }; + + /** + @brief Return the configuration parameters of the SDK's TouchlessController + @param[out] pinfo the profile info structure of the configuration parameters. + @return PXC_STATUS_NO_ERROR if the parameters were returned successfully; otherwise, return one of the following errors: + PXC_STATUS_ITEM_UNAVAILABLE - Item not found/not available.\n + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n + */ + virtual pxcStatus PXCAPI QueryProfile(ProfileInfo *pinfo)=0; + + /** + @brief Set configuration parameters of the SDK TouchlessController. + @param[in] pinfo the profile info structure of the configuration parameters. + @return PXC_STATUS_NO_ERROR if the parameters were set correctly; otherwise, return one of the following errors: + PXC_STATUS_INIT_FAILED - Module failure during initialization.\n + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n + */ + virtual pxcStatus PXCAPI SetProfile(ProfileInfo *pinfo)=0; + + /* + @breif Describe a UXEvent, + */ + struct UXEventData + { + /** + @enum UXEventType + + @brief Values that represent UXEventType. + */ + enum UXEventType + { + UXEvent_StartZoom, // the user start performing a zoom operation - pan my also be performed during zoom + UXEvent_Zoom, // Fired while zoom operation is ongoing + UXEvent_EndZoom, // User stoped zoomig + UXEvent_StartScroll, // the user start performing a scroll or pan operation + UXEvent_Scroll, // Fired while scroll operation is ongoing + UXEvent_EndScroll, // User stoped scrolling (panning) + UXEvent_StartDraw, // User started drawing + UXEvent_Draw, // Fired while draw operation is ongoing + UXEvent_EndDraw, // User finshed drawing + UXEvent_CursorMove, // Cursor moved while not in any other mode + UXEvent_Select, // oser selected a button + UXEvent_GotoStart, // Got to windows 8 start screen + UXEvent_CursorVisible, // Cursor turned visible + UXEvent_CursorNotVisible, // Cursor turned invisible + UXEvent_ReadyForAction, // The user is ready to perform a zoom or scroll operation + UXEvent_StartMetaCounter, // Start Meta Menu counter visual + UXEvent_StopMetaCounter, // Abort Meta Menu Counter Visual + UXEvent_ShowMetaMenu, // Show Meta Menu + UXEvent_HideMetaMenu, // Hide Meta Menu + UXEvent_MetaPinch, // Hide Meta Menu + UXEvent_MetaOpenHand // Hide Meta Menu + }; + UXEventType type; // type of the event + PXCPoint3DF32 position; // position where event happen values are in rang [0,1] + PXCHandData::BodySideType bodySide; // the hand that issued the event + + }; + + /** + @class UXEventHandler + Interface for a callback for all categories of events + */ + class UXEventHandler{ + public: + /** + @brief virtual destructor + */ + virtual ~UXEventHandler(){} + /** + @brief The OnFiredUXEvent method is called when a UXWvent is fired. + @param[in] uxEventData contains all the information for the fired event. + @see UXEventData + */ + virtual void PXCAPI OnFiredUXEvent(const UXEventData *uxEventData)=0; + }; + + + /** + @brief Register an event handler object for UX Event. The event handler's OnFiredUXEvent method will be called each time a UX event is identified. + @param[in] uxEventHandler a pointer to the event handler. + @see UXEventHandler::OnFiredUXEvent + @return PXC_STATUS_NO_ERROR if the registering an event handler was successful; otherwise, return the following error: + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n + */ + virtual pxcStatus PXCAPI SubscribeEvent(UXEventHandler *uxEventHandler) = 0; + + /** + @brief Unsubscribe an event handler object for UX events. + @param[in] uxEventHandler a pointer to the event handler that should be removed. + @return PXC_STATUS_NO_ERROR if the unregistering the event handler was successful, an error otherwise. + */ + virtual pxcStatus PXCAPI UnsubscribeEvent(UXEventHandler *uxEventHandler) = 0; + + /** + @struct AlertData + + @brief An alert data, contain data describing an alert. + */ + struct AlertData + { + /** + @enum AlertType + + @brief Values that represent AlertType. + */ + enum AlertType { + Alert_TooClose, // The user hand is too close to the 3D camera + Alert_TooFar, // The user hand is too far from the 3D camera + Alert_NoAlerts // A previous alerted situation was ended + }; + AlertType type; // the type of the alert + }; + + /** + @class AlertHandler + Interface for a callback for all categories of alerts + */ + class AlertHandler{ + public: + /** + @brief virtual destructor + */ + virtual ~AlertHandler(){} + /** + @brief The OnFiredAlert method is called when a registered alert event is fired. + @param[in] alertData contains all the information for the fired alert. + @see AlertData + */ + virtual void PXCAPI OnFiredAlert(const AlertData *alertData)=0; + }; + + /** + @brief Register an event handler object for alerts. The event handler's OnFiredAlert method will be called each time an alert is identified. + @param[in] alertHandler a pointer to the event handler. + @see AlertHandler::OnFiredAlert + @return PXC_STATUS_NO_ERROR if the registering an event handler was successful; otherwise, return the following error: + PXC_STATUS_DATA_NOT_INITIALIZED - Data failed to initialize.\n + */ + virtual pxcStatus PXCAPI SubscribeAlert(AlertHandler *alertHandler) = 0; + + /** + @brief Unsubscribe an event handler object for alerts. + @param[in] alertHandler a pointer to the event handler that should be removed. + @return PXC_STATUS_NO_ERROR if the unregistering the event handler was successful, an error otherwise. + */ + virtual pxcStatus PXCAPI UnsubscribeAlert(AlertHandler *alertHandler) = 0; + + /** + @enum Action + + @brief Values that represent Action. Those are actions the module will inject to the OS + */ + enum Action + { + Action_None=0, // No action will be injected + Action_LeftKeyPress, // can be used to Go to the next item (Page/Slide/Photo etc.) + Action_RightKeyPress, // can be used to Go to the previouse item (Page/Slide/Photo etc.) + Action_BackKeyPress, // can be used to Go to the previouse item (Page/Slide/Photo etc.) + Action_PgUpKeyPress, // can be used to Go to the previouse item (Page/Slide/Photo etc.) + Action_PgDnKeyPress, // can be used to Go to the previouse item (Page/Slide/Photo etc.) + Action_VolumeUp, + Action_VolumeDown, + Action_Mute, + Action_NextTrack, + Action_PrevTrack, + Action_PlayPause, + Action_Stop, + Action_ToggleTabs, // can be used to display tabs menu in Metro Internet Explorer + }; + + /** + @class AlertHandler + Interface for a callback for all categories of actions + */ + class ActionHandler { + public: + /** + @brief virtual destructor + */ + virtual ~ActionHandler(){} + /** + @brief The OnFiredAction method is called when a registered action mapping is triggered + @param[in] action the action that was fired + @see Action + */ + virtual void PXCAPI OnFiredAction(const Action action)=0; + }; + + /** + @brief Adds a gesture action mapping. + @param [in] gestureName If non-null, name of the gesture. + @param action The action. + @param [in] actionHandler (Optional) If non-null, an action handler that will be called when the gesture will be recognized. + @return PXC_STATUS_NO_ERROR if the mapping was successful, an error otherwise. + */ + virtual pxcStatus PXCAPI AddGestureActionMapping(pxcCHAR* gestureName,Action action,ActionHandler* actionHandler) = 0; + __inline pxcStatus AddGestureActionMapping(pxcCHAR* gestureName,Action action) { + return AddGestureActionMapping(gestureName, action, 0); + } + + /** + @brief Clear all previous Gesture to Action mappings + @return PXC_STATUS_NO_ERROR if the mapping was successful, an error otherwise. + */ + virtual pxcStatus PXCAPI ClearAllGestureActionMappings(void) = 0; + + + virtual pxcStatus PXCAPI ProcessFrame(pxcUID /*mid*/, PXCBase* /*object*/) { return PXC_STATUS_ITEM_UNAVAILABLE; } +}; diff --git a/modules/control/rssdk/rssdk/pxctracker.h b/modules/control/rssdk/rssdk/pxctracker.h new file mode 100644 index 0000000..01d3465 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxctracker.h @@ -0,0 +1,135 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ + +/** @file pxctracker.h +Defines the PXCTracker interface, which programs may use for 3D tracking. +*/ +#pragma once +#include "pxcsession.h" +#include "pxccapture.h" +#pragma warning(push) +#pragma warning(disable:4201) /* nameless structs/unions */ + +/** +This class defines a standard interface for 3D tracking algorithms. +*/ +class PXCTracker:public PXCBase { +public: + PXC_CUID_OVERWRITE(PXC_UID('T','R','K','R')); + + /** + * The tracking states of a target. + * + * The state of a target usually starts with ETS_NOT_TRACKING. + * When it is found in the current camera image, the state change to + * ETS_FOUND for one image, the following images where the location of the + * target is successfully determined will have the state ETS_TRACKING. + * + * Once the tracking is lost, there will be one single frame ETS_LOST, then + * the state will be ETS_NOT_TRACKING again. In case there is extrapolation + * of the pose requested, the transition may be from ETS_TRACKING to ETS_EXTRAPOLATED. + * + * To sum up, these are the state transitions to be expected: + * ETS_NOT_TRACKING -> ETS_FOUND + * ETS_FOUND -> ETS_TRACKING + * ETS_TRACKING -> ETS_LOST + * ETS_LOST -> ETS_NOT_TRACKING + * + * With additional extrapolation, these transitions can occur as well: + * ETS_TRACKING -> ETS_EXTRAPOLATED + * ETS_EXTRAPOLATED -> ETS_LOST + * + * "Event-States" do not necessarily correspond to a complete frame but can be used to + * flag individual tracking events or replace tracking states to clarify their context: + * ETS_NOT_TRACKING -> ETS_REGISTERED -> ETS_FOUND for edge based initialization + */ + enum ETrackingState + { + ETS_UNKNOWN = 0, ///< Tracking state is unknown + ETS_NOT_TRACKING = 1, ///< Not tracking + ETS_TRACKING = 2, ///< Tracking + ETS_LOST = 3, ///< Target lost + ETS_FOUND = 4, ///< Target found + ETS_EXTRAPOLATED = 5, ///< Tracking by extrapolating + ETS_INITIALIZED = 6, ///< The tracking has just been loaded + + ETS_REGISTERED = 7 ///< Event-State: Pose was just registered for tracking + }; + + struct TrackingValues { + ETrackingState state; ///< The state of the tracking values + + PXCPoint3DF32 translation; ///< Translation component of the pose + PXCPoint4DF32 rotation; ///< Rotation component of the pose + + /** + * Quality of the tracking values. + * Value between 0 and 1 defining the tracking quality. + * A higher value means better tracking results. More specifically: + * - 1 means the system is tracking perfectly. + * - 0 means that we are not tracking at all. + */ + pxcF32 quality; + + pxcF64 timeElapsed; ///< Time elapsed (in ms) since last state change of the tracking system + pxcF64 trackingTimeMs; ///< Time (in milliseconds) used for tracking the respective frame + pxcI32 targetID; ///< The ID of the target object + pxcCHAR targetName[256]; ///< The name of the target object + pxcCHAR additionalValues[256]; ///< Extra space for information provided by a sensor that cannot be expressed with translation and rotation properly. + pxcCHAR sensor[256]; ///< The sensor that provided the values + + pxcI32 reserved[32]; // 0 - reserved for module specific parameters + }; + + + /// Set the camera parameters, which can be the result of camera calibration from the toolbox + virtual pxcStatus PXCAPI SetCameraParameters(const pxcCHAR *filename)=0; + + + /** + * Set 2d reference image for tracking + * \param filename: path to image file + * \param[out] targetID: id of added target + * \param widthMM: image width in mm + * \param heightMM: image height in mm + * \param qualityThreshold: + */ + virtual pxcStatus PXCAPI Set2DTrackFromFile(const pxcCHAR *filename, pxcUID& targetID, pxcF32 widthMM, pxcF32 heightMM, pxcF32 qualityThreshold) = 0; + pxcStatus __inline Set2DTrackFromFile(const pxcCHAR *filename, pxcUID& targetID) { return Set2DTrackFromFile(filename, targetID, 0.f, 0.f, 0.7f); } + + virtual pxcStatus PXCAPI Set2DTrackFromImage(PXCImage *image, pxcUID& targetID, pxcF32 widthMM, pxcF32 heightMM, pxcF32 qualityThreshold) = 0; + pxcStatus __inline Set2DTrackFromImage(PXCImage *image, pxcUID& targetID) { return Set2DTrackFromImage(image, targetID, 0.f, 0.f, 0.7f); } + + /** + * Set a 3D tracking configuration + * + * This file can be generated with the Toolbox + * + * \param filename The full path to the configuration file (*.3dmap, *.xml) + * \return true if setting the tracking configuration was successfull, false otherwise + */ + virtual pxcStatus PXCAPI Set3DTrack(const pxcCHAR *filename, pxcUID& firstTargetID, pxcUID& lastTargetID) = 0; + + virtual pxcStatus PXCAPI Set3DInstantTrack(pxcBool egoMotion)=0; + pxcStatus __inline Set3DInstantTrack(void) { return Set3DInstantTrack(false); } + + /** + * Get the number of targest currently tracking + * \return The number of active tracking targets + * + * \sa getTrackingValues + */ + virtual pxcI32 PXCAPI QueryNumberTrackingValues() const = 0; + + // Get the tracking result + virtual pxcStatus PXCAPI QueryAllTrackingValues(PXCTracker::TrackingValues *trackingValues)=0; + virtual pxcStatus PXCAPI QueryTrackingValues(pxcUID cosID, TrackingValues& outTrackingValues)=0; + +}; diff --git a/modules/control/rssdk/rssdk/pxcversion.h b/modules/control/rssdk/rssdk/pxcversion.h new file mode 100644 index 0000000..a7e4046 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcversion.h @@ -0,0 +1,27 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2012 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once + +#define PXC_VERSION_MAJOR 2 +#define PXC_VERSION_MINOR 0 +#define PXC_VERSION_BUILD 1 +#define PXC_VERSION_REVISION 22222 + +#define RSSDK_REG_DEV TEXT("Software\\Intel\\RSSDK") +#define RSSDK_REG_DEV32 TEXT("Software\\Wow6432Node\\Intel\\RSSDK") + +#define RSSDK_REG_RUNTIME TEXT("Software\\Intel\\RSSDK\\v2") +#define RSSDK_REG_RUNTIME32 TEXT("Software\\Wow6432Node\\Intel\\RSSDK\\v2") + +#define RSSDK_REG_DISPATCH RSSDK_REG_RUNTIME TEXT("\\Dispatch") +#define RSSDK_REG_DISPATCH32 RSSDK_REG_RUNTIME32 TEXT("\\Dispatch") + +#define RSDCM_REG_DEV TEXT("Software\\Intel\\RSDCM") +#define RSDCM_REG_DEV32 TEXT("Software\\Wow6432Node\\Intel\\RSDCM") diff --git a/modules/control/rssdk/rssdk/pxcvideomodule.h b/modules/control/rssdk/rssdk/pxcvideomodule.h new file mode 100644 index 0000000..552e3e0 --- /dev/null +++ b/modules/control/rssdk/rssdk/pxcvideomodule.h @@ -0,0 +1,119 @@ +/******************************************************************************* + +INTEL CORPORATION PROPRIETARY INFORMATION +This software is supplied under the terms of a license agreement or nondisclosure +agreement with Intel Corporation and may not be copied or disclosed except in +accordance with the terms of that agreement +Copyright(c) 2013-2014 Intel Corporation. All Rights Reserved. + +*******************************************************************************/ +#pragma once +#include "pxccapture.h" +#include "pxcsession.h" + +class PXCVideoModule : public PXCBase { +public: + + PXC_CUID_OVERWRITE(0x69D5B036); + PXC_DEFINE_CONST(DEVCAP_LIMIT,120); + + /** + @structure DeviceCap + Describes a pair value of device property and its value. + Use the inline functions to access specific device properties. + */ + struct DeviceCap { + PXCCapture::Device::Property label; /* Property type */ + pxcF32 value; /* Property value */ + }; + + /** + @structure StreamDesc + Describes the streams requested by a module implementation. + */ + struct StreamDesc { + PXCSizeI32 sizeMin; /* minimum size */ + PXCSizeI32 sizeMax; /* maximum size */ + PXCRangeF32 frameRate; /* frame rate */ + pxcI32 reserved[6]; + }; + + /** + @structure StreamDescSet + A set of stream descriptors accessed by StreamType. + */ + struct StreamDescSet { + StreamDesc color; + StreamDesc depth; + StreamDesc ir; + StreamDesc left; + StreamDesc right; + StreamDesc reserved[PXCCapture::STREAM_LIMIT-5]; + + /** + @brief Access the stream descriptor by the stream type. + @param[in] type The stream type. + @return The stream descriptor instance. + */ + __inline StreamDesc& operator[](PXCCapture::StreamType type) { + switch (type) { + case PXCCapture::STREAM_TYPE_COLOR: return color; + case PXCCapture::STREAM_TYPE_DEPTH: return depth; + case PXCCapture::STREAM_TYPE_IR: return ir; + case PXCCapture::STREAM_TYPE_LEFT: return left; + case PXCCapture::STREAM_TYPE_RIGHT: return right; + default: + for (int i=sizeof(reserved)/sizeof(reserved[0])-1,j=(1<<(PXCCapture::STREAM_LIMIT-1));i>=0;i--,j>>=1) + if (type&j) return reserved[i]; + return reserved[PXCCapture::STREAM_LIMIT-6]; + } + } + }; + + /** + @structure DataDesc + Data descriptor to describe the module input needs. + */ + struct DataDesc { + StreamDescSet streams; /** requested stream characters */ + DeviceCap devCaps[DEVCAP_LIMIT]; /** requested device properties */ + PXCCapture::DeviceInfo deviceInfo; /** requested device info */ + pxcI32 reserved[8]; + }; + + /** + @brief Return the available module input descriptors. + @param[in] pidx The zero-based index used to retrieve all configurations. + @param[out] inputs The module input descriptor, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + @return PXC_STATUS_ITEM_UNAVAILABLE No specified input descriptor is not available. + */ + virtual pxcStatus PXCAPI QueryCaptureProfile(pxcI32 pidx, DataDesc *inputs) = 0; + + /** + @brief Return the active input descriptor that the module works on. + @param[out] inputs The module input descriptor, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + __inline pxcStatus QueryCaptureProfile(DataDesc *inputs) { + return QueryCaptureProfile(WORKING_PROFILE, inputs); + } + + /** + @brief Set the active input descriptor with the device information from the capture device. + @param[in] inputs The input descriptor with the device information. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI SetCaptureProfile(DataDesc *inputs) = 0; + + /** + @brief Feed captured samples to module for processing. If the samples are not available + immediately, the function will register to run the module processing when the samples + are ready. This is an asynchronous function. The application must synchronize the + returned SP before retrieving any module data, which is not available during processing. + @param[in] images The samples from the capture device. + @param[out] sp The SP, to be returned. + @return PXC_STATUS_NO_ERROR Successful execution. + */ + virtual pxcStatus PXCAPI ProcessImageAsync(PXCCapture::Sample *sample, PXCSyncPoint **sp) = 0; +}; -- 2.1.4