/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2025 SenseGlove * * @section DESCRIPTION * * Unprocessed data received from CV Device(s), used as input for processing. * Used as a separate class so the format is ensured. */ #pragma once #include #include #include #include "DeviceTypes.hpp" #include namespace SGCore { namespace CV { //---------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Tracking Depth Enum /// How much of the CV tracking is being used. Used by other APIs. enum class SGCORE_API ECVTrackingDepth : uint8_t { /// No computer-vision is enabled. Disabled = 0, /// Use CV only for the wrist position/rotation. WristOnly, /// Use CV for both the wrist location and Hand Position. WristAndHandPose, }; //---------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Position Enum /// Used to access specific positions from the CV output, which is an array of Vect3D positions. /// /// Declared in CVHandOutput.cs because these enums are used to index the jointPositions array in /// that class. enum class SGCORE_API ECVHandPoints : uint8_t { /// The position of the Wrist as determined by the CV Model. Wrist = 0, /// The position of the Thumb CMC Joint as determined by the CV Model. ThumbCmc, /// The position of the Thumb MCP Joint as determined by the CV Model. ThumbMcp, /// The position of the Thumb IP Joint as determined by the CV Model. ThumbIp, /// The position of the Thumb tip as determined by the CV Model. ThumbTip, /// The position of the Index MCP Joint as determined by the CV Model. IndexMcp, /// The position of the Index PIP Joint as determined by the CV Model. IndexPip, /// The position of the Index DIP Joint as determined by the CV Model. IndexDip, /// The position of the Index fingertip as determined by the CV Model. IndexTip, /// The position of the Middle MCP Joint as determined by the CV Model. MiddleMcp, /// The position of the Middle PIP Joint as determined by the CV Model. MiddlePip, /// The position of the Middle DIP Joint as determined by the CV Model. MiddleDip, /// The position of the Middle fingertip as determined by the CV Model. MiddleTip, /// The position of the Ring MCP Joint as determined by the CV Model. RingMcp, /// The position of the Ring PIP Joint as determined by the CV Model. RingPip, /// The position of the Ring DIP Joint as determined by the CV Model. RingDip, /// The position of the Ring fingertip as determined by the CV Model. RingTip, /// The position of the Pinky MCP Joint as determined by the CV Model. PinkyMcp, /// The position of the Pinky PIP Joint as determined by the CV Model. PinkyPip, /// The position of the Pinky DIP Joint as determined by the CV Model. PinkyDip, /// The position of the Pinky fingertip as determined by the CV Model. PinkyTip, /// Utility enumerator to check if an array contains enough values. All, }; /// Unprocessed data received from CV Device(s), used as input for processing. class SGCORE_API CVHandTrackingData; }// namespace CV namespace Kinematics { class Vect3D; class Quat; }// namespace Kinematics }// namespace SGCore //---------------------------------------------------------------------------------------------------------------------------------------------------------------------- // CV Output Class /// Unprocessed data received from CV Device(s), used as input for processing. class SGCORE_API SGCore::CV::CVHandTrackingData { private: struct Impl; std::unique_ptr Pimpl; public: /** * The default constructor. */ CVHandTrackingData(); //--------------------------------------------------------------------------------- // Actual C++ Constructors /// Creates a new instance of HandTrackingData. Time is takes from the internal system CVHandTrackingData(const std::vector& CVHandPoints, float certainty, bool bRightHanded, SGCore::EDeviceType forDeviceType, const std::string& subHardwareVersion); /// Creates a new instance of HandTrackingData. CVHandTrackingData(const std::vector& CVHandPoints, float certainty, bool bRightHanded, SGCore::EDeviceType forDeviceType, const std::string& subHardwareVersion, float time); /** * The copy constructor. */ CVHandTrackingData(const CVHandTrackingData& rhs); /** * The move constructor. */ CVHandTrackingData(CVHandTrackingData&& rhs) noexcept; virtual ~CVHandTrackingData(); public: /** * The copy assignment operator. */ CVHandTrackingData& operator=(const CVHandTrackingData& rhs); /** * The move assignment operator. */ CVHandTrackingData& operator=(CVHandTrackingData&& rhs) noexcept; public: /// Simulation time When this Data was received. Used for data smoothing. [[nodiscard]] float GetTimeStamp() const; void SetTimeStamp(float timestamp); /// 21 positions, representing the wrist and finger positions in 3D (world)space. [[nodiscard]] std::vector GetJointPositions() const; void SetJointPositions(const std::vector& positions); /// Left/Right handedness. [[nodiscard]] bool IsRight() const; void SetRight(bool bRight); /// How certain is it that this is an actual hand that we're tracking. [[nodiscard]] float GetCertaintyFactor() const; void SetCertaintyFactor(float factor); /// Which Device this data has been generated for [[nodiscard]] SGCore::EDeviceType GetForDevice() const; void SetForDevice(SGCore::EDeviceType type); /// (sub)hardware version that this data has been generated for. [[nodiscard]] std::string GetForHwVersion() const; void SetHwVersion(const std::string& version); //--------------------------------------------------------------------------------- // Member Functions public: /// Safely retrieve the location of a specific joint. /// /// [[nodiscard]] Kinematics::Vect3D GetPosition(ECVHandPoints location) const; /// Safely retrieve the location of a specific joint. /// /// [[nodiscard]] Kinematics::Vect3D GetPositionByIndex(int32_t location) const; /// Returns true if this pose was made for a specific hand, device, and sub-hw version. /// /// /// /// [[nodiscard]] bool MatchesDevice( bool bRight, SGCore::EDeviceType type, const std::string& hardwareVersion) const; /// Returns true if this pose was made for the same device as another pose. /// /// [[nodiscard]] bool MatchesDevice(const CVHandTrackingData& otherPose) const; /// Get a simple notation of this CV_HandTrackingData. /// [[nodiscard]] std::string ToString() const; /// Prints all of the joint positions within this CV_HandTrackingData. /// /// [[nodiscard]] std::string PrintKeyPoints(const std::string& delimiter = ", ") const; };