123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402 |
- using System;
- using System.Runtime.InteropServices;
- using Rokid.UXR.Utility;
- using UnityEngine;
- namespace Rokid.UXR.Native
- {
- public partial class NativeInterface
- {
- public partial class NativeAPI
- {
- /// <summary>
- /// Init gesture
- /// </summary>
- public static void InitGesture()
- {
- if (Utils.IsAndroidPlatfrom())
- NativeInterface.NativeAPI.openGestureTracker();
- }
- /// <summary>
- /// Relese gesture
- /// </summary>
- public static void ReleaseGesure()
- {
- if (Utils.IsAndroidPlatfrom())
- NativeInterface.NativeAPI.closeGestureTracker();
- }
- /// <summary>
- /// Retrieve the number of tracked hand vertices.
- /// </summary>
- /// <returns></returns>
- public static int GetTrackingHandVertsNum()
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandVertsNum();
- return 0;
- }
- /// <summary>
- /// Retrieve the number of tracked skeletons.
- /// </summary>
- /// <returns></returns>
- public static int GetTrackingHandSkeletonNum()
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandSkeletonNum();
- return 0;
- }
- /// <summary>
- /// Retrieve the number of tracked hands.
- /// </summary>
- /// <returns></returns>
- public static int GetTrackingHandNum()
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandNum();
- return 0;
- }
- /// <summary>
- /// Retrieve the type of tracked hands
- /// </summary>
- /// <param name="index">hand index</param>
- /// <returns> 0:lefthand 1:righthand</returns>
- public static int GetTrackingHandLrHand(int index)
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandLrHand(index);
- return 0;
- }
- /// <summary>
- /// Retrieve the type of tracked gestures.
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public static int GetTrackingGestureType(int index)
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingGestureType(index);
- return 0;
- }
- /// <summary>
- /// Retrieve the type of tracked gestures.
- /// When there is a conflict between "grip" and "pinch" in the combine type, prioritize selecting "grip."
- /// </summary>
- /// <param name="index"></param>
- /// <returns></returns>
- public static int GetTrackingHandCombineGestureType(int index)
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandCombineGestureType(index);
- return 0;
- }
- /// <summary>
- /// Retrieve the skeleton information in camera space.
- /// </summary>
- /// <param name="skeletonCAM"></param>
- /// <param name="index"></param>
- public static void GetTrackingHandSkeletonCAM(float[] skeletonCAM, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandSkeletonCAM(skeletonCAM, index);
- }
- /// <summary>
- /// Retrieve the skeleton information in NDC (Normalized Device Coordinates) space.
- /// </summary>
- /// <param name="skeletonNDC"></param>
- /// <param name="index"></param>
- public static void GetTrackingHandSkeletonNDC(float[] skeletonNDC, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandSkeletonNDC(skeletonNDC, index);
- }
- /// <summary>
- /// Retrieve the mesh points of the hand in NDC (Normalized Device Coordinates) space.
- /// </summary>
- /// <param name="vertsNDC"></param>
- /// <param name="index"></param>
- public static void GetTrackingHandVertsNDC(float[] vertsNDC, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandVertsNDC(vertsNDC, index);
- }
- /// <summary>
- /// Retrieve the mesh points of the hand in camera space.
- /// </summary>
- /// <param name="vertsCAM"></param>
- /// <param name="index"></param>
- public static void GetTrackingHandVertsCAM(float[] vertsCAM, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandVertsCAM(vertsCAM, index);
- }
- /// <summary>
- /// Retrieve the rotation of the hand as a quaternion.
- /// </summary>
- /// <param name="rotation">quaternion</param>
- /// <param name="index">hand index</param>
- public static void GetTrackingHandRootRotation(float[] rotation, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandRootRotation(rotation, index);
- }
- /// <summary>
- /// Retrieve the type of palm and back of the hand.
- /// </summary>
- /// <param name="index">hand index</param>
- /// <returns></returns>
- public static int GetTrackingHandOrientation(int index)
- {
- if (Utils.IsAndroidPlatfrom())
- return getTrackingHandOrientation(index);
- return 0;
- }
- /// <summary>
- /// Retrieve the coordinate axes of the hand in camera space.
- /// </summary>
- /// <param name="axis"></param>
- /// <param name="index"></param>
- public static void GetTrackingHandRootRotationAxisCAM(float[] axis, int index)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandRootRotationAxisCAM(axis, index);
- }
- /// <summary>
- /// Retrieve the hand velocity tracking.
- /// </summary>
- /// <param name="data"></param>
- /// <param name="index"></param>
- // public static void GetTrackingHandVelocity(float[] data, int index)
- // {
- // if (Utils.IsAndroidPlatfrom())
- // getTrackingHandVelocity(data, index);
- // }
- /// <summary>
- /// Retrieve the timestamp of the gesture image moment.
- /// </summary>
- /// <returns></returns>
- public static long GetCurrentFrameTimeStamp()
- {
- if (Utils.IsAndroidPlatfrom())
- return getCurrentFrameTimeStamp();
- return 0;
- }
- /// <summary>
- /// Retrieve the timestamp of the completed gesture image processing.
- /// </summary>
- /// <returns></returns>
- public static long GetFinishProcessTimeStamp()
- {
- if (Utils.IsAndroidPlatfrom())
- return GetFinishProcessTimeStamp();
- return 0;
- }
- /// <summary>
- /// Set the tracking count for hands.
- /// </summary>
- /// <param name="maxHandNum"></param>
- public static void SetMaxHandNum(int maxHandNum)
- {
- if (Utils.IsAndroidPlatfrom())
- setMaxHandNum(maxHandNum);
- }
- /// <summary>
- /// Enable DSP
- /// <param name = "useDsp" >
- /// 0 means neither detection nor tracking DSP is enabled
- /// 1 means detection is enabled, but tracking is disabled.
- /// 2 means detection is disabled, but tracking is enabled.
- /// 3 means both detection and tracking are enabled.
- /// </ param >
- /// </summary>
- public static void SetUseDsp(int useDsp)
- {
- if (Utils.IsAndroidPlatfrom())
- setUseDsp(useDsp);
- }
- /// <summary>
- /// Enable fisheye distortion correction
- /// </summary>
- /// <param name="useFishEyeDistort">,0-false,1-true</param>
- public static void SetUseFishEyeDistort(int useFishEyeDistort)
- {
- if (Utils.IsAndroidPlatfrom())
- setUseFishEyeDistort(useFishEyeDistort);
- }
- /// <summary>
- /// Retrieve skeleton rotation data
- /// </summary>
- /// <param name="data"></param>
- /// <param name="index">hand index</param>
- /// <param name="type">0-matrix(21*9),1-quaternion(21*4),2-euler(21*3</param>
- public static void GetTrackingHandSkeletonRotationAll(float[] data, int index, int type)
- {
- if (Utils.IsAndroidPlatfrom())
- getTrackingHandSkeletonRotationAll(data, index, type);
- }
- /// <summary>
- /// Set gesture loglevel
- /// </summary>
- /// <param name="logLevel"> "debug", "info", "warn", "err", "fatal", "none"</param>
- public static void SetGestureLogLevel(string logLevel)
- {
- if (Utils.IsAndroidPlatfrom())
- {
- setGestureLogLevel(logLevel);
- }
- }
- /// <summary>
- /// It is physical camera pose
- /// </summary>
- /// <param name="timestamp"></param>
- /// <returns></returns>
- [Obsolete("Only gesture use")]
- public static Pose GetHeadPoseForGes(long timestamp)
- {
- Pose pose = Pose.identity;
- if (Utils.IsAndroidPlatfrom())
- {
- getHistoryHeadPosePysRHS(timestamp, position, rotation);
- pose.position = new Vector3(position[0], position[1], -position[2]);
- pose.rotation = new Quaternion(-rotation[0], -rotation[1], rotation[2], rotation[3]);
- }
- return pose;
- }
- /// <summary>
- /// Get upforward influencePow
- /// </summary>
- /// <returns></returns>
- public static float GetUpForwardInfluencePow()
- {
- if (Utils.IsAndroidPlatfrom())
- return getUpForwardInfluencePow();
- return 0;
- }
- #region NativeInterface
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void openGestureTracker();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void closeGestureTracker();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandVertsNum();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandSkeletonNum();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandNum();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandLrHand(int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingGestureType(int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandCombineGestureType(int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandSkeletonCAM(float[] skeletonCAM, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandVertsNDC(float[] vertsNDC, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandVertsCAM(float[] vertsCAM, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandSkeletonNDC(float[] skeletonNDC, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandRootRotation(float[] rotation, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern int getTrackingHandOrientation(int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandRootRotationAxisCAM(float[] axis, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN), Obsolete]
- static extern void getTrackingHandStableAnchorPoint(float[] stableAnchorPoint, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandSkeletonRotationAll(float[] data, int index, int type);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandVelocity(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern long getCurrentFrameTimeStamp();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern long getFinishProcessTimeStamp();
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void setMaxHandNum(int maxHandNum);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void setUseDsp(int useDsp);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void setUseFishEyeDistort(int useFishEyeDistort);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN, CharSet = CharSet.Ansi)]
- static extern void setGestureLogLevel(string logLevel);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getHistoryHeadPosePysRHS(long timestamp, float[] position, float[] orientation);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern float getUpForwardInfluencePow();
- #region OPEN_GL_INTERFACE
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandVertsCAM_GLAxis(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandSkeletonCAM_GLAxis(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandRootRotation_GLAxis(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandRootRotationEuler_GLAxis(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandRootRotationAxisCAM_GLAxis(float[] data, int index);
- [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
- static extern void getTrackingHandSkeletonRotationAll_GLAxis(float[] data, int index, int type);
- #endregion
- #endregion
- }
- }
- }
|