diff options
author | Stéphane Lenclud <github@lenclud.com> | 2019-01-31 10:32:17 +0100 |
---|---|---|
committer | Stéphane Lenclud <github@lenclud.com> | 2019-02-07 13:24:13 +0100 |
commit | a774441fde00f0ce6c8387339c786e9e2f42f088 (patch) | |
tree | 0877ab55801aee6b4de748dcbd1190a4922da41b /tracker-kinect-face/tracker.h | |
parent | b9d34a26d35d05f793161e54001329edb5122a81 (diff) |
Kinect: First draft.
Diffstat (limited to 'tracker-kinect-face/tracker.h')
-rw-r--r-- | tracker-kinect-face/tracker.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tracker-kinect-face/tracker.h b/tracker-kinect-face/tracker.h new file mode 100644 index 00000000..88243b1f --- /dev/null +++ b/tracker-kinect-face/tracker.h @@ -0,0 +1,90 @@ + + + +#include <cmath> + +#include "api/plugin-api.hpp" +#include "compat/timer.hpp" +#include "compat/macros.hpp" + +// Kinect Header files +#include <Kinect.h> +#include <Kinect.Face.h> + +#pragma once + +// Safe release for interfaces +template<class Interface> +inline void SafeRelease(Interface *& pInterfaceToRelease) +{ + if (pInterfaceToRelease != nullptr) + { + pInterfaceToRelease->Release(); + pInterfaceToRelease = nullptr; + } +} + + +class KinectFaceTracker : public ITracker +{ +public: + KinectFaceTracker(); + ~KinectFaceTracker() override; + module_status start_tracker(QFrame *) override; + void data(double *data) override; + +private: + static const double incr[6]; + double last_x[6]{}; + Timer t; + + // Kinect stuff + + // define the face frame features required to be computed by this application + static const DWORD c_FaceFrameFeatures = + FaceFrameFeatures::FaceFrameFeatures_BoundingBoxInColorSpace + | FaceFrameFeatures::FaceFrameFeatures_PointsInColorSpace + | FaceFrameFeatures::FaceFrameFeatures_RotationOrientation + | FaceFrameFeatures::FaceFrameFeatures_Happy + | FaceFrameFeatures::FaceFrameFeatures_RightEyeClosed + | FaceFrameFeatures::FaceFrameFeatures_LeftEyeClosed + | FaceFrameFeatures::FaceFrameFeatures_MouthOpen + | FaceFrameFeatures::FaceFrameFeatures_MouthMoved + | FaceFrameFeatures::FaceFrameFeatures_LookingAway + | FaceFrameFeatures::FaceFrameFeatures_Glasses + | FaceFrameFeatures::FaceFrameFeatures_FaceEngagement; + + static const int cColorWidth = 1920; + static const int cColorHeight = 1080; + + + void Update(); + HRESULT InitializeDefaultSensor(); + void ProcessFaces(); + HRESULT UpdateBodyData(IBody** ppBodies); + void ExtractFaceRotationInDegrees(const Vector4* pQuaternion, double* pPitch, double* pYaw, double* pRoll); + + // Current Kinect + IKinectSensor* m_pKinectSensor; + + // Coordinate mapper + ICoordinateMapper* m_pCoordinateMapper; + + // Color reader + IColorFrameReader* m_pColorFrameReader; + + // Body reader + IBodyFrameReader* m_pBodyFrameReader; + + // Face sources + IFaceFrameSource* m_pFaceFrameSources[BODY_COUNT]; + + // Face readers + IFaceFrameReader* m_pFaceFrameReaders[BODY_COUNT]; + + // + RGBQUAD* m_pColorRGBX; + + Vector4 faceRotation; + +}; |