diff --git a/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLJoint.cs b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLJoint.cs new file mode 100644 index 0000000..8836d15 --- /dev/null +++ b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLJoint.cs @@ -0,0 +1,47 @@ +using HuaweiMobileServices.Utils; +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; + +namespace HuaweiMobileServices.ML.SkeletonDetection +{ + public class MLJoint : JavaObjectWrapper + { + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLJoint"; + private static readonly AndroidJavaClass sJavaClass = new AndroidJavaClass(CLASS_NAME); + + public MLJoint(AndroidJavaObject javaObject) : base(javaObject) + { + } + + public MLJoint(string javaObjectCanonicalName, params object[] args) : base(javaObjectCanonicalName, args) + { + } + + public static int TYPE_HEAD_TOP => sJavaClass.GetStatic(nameof(TYPE_HEAD_TOP)); + public static int TYPE_LEFT_ANKLE => sJavaClass.GetStatic(nameof(TYPE_LEFT_ANKLE)); + public static int TYPE_LEFT_ELBOW => sJavaClass.GetStatic(nameof(TYPE_LEFT_ELBOW)); + public static int TYPE_LEFT_HIP => sJavaClass.GetStatic(nameof(TYPE_LEFT_HIP)); + public static int TYPE_LEFT_KNEE => sJavaClass.GetStatic(nameof(TYPE_LEFT_KNEE)); + public static int TYPE_LEFT_SHOULDER => sJavaClass.GetStatic(nameof(TYPE_LEFT_SHOULDER)); + public static int TYPE_LEFT_WRIST => sJavaClass.GetStatic(nameof(TYPE_LEFT_WRIST)); + public static int TYPE_NECK => sJavaClass.GetStatic(nameof(TYPE_NECK)); + public static int TYPE_RIGHT_ANKLE => sJavaClass.GetStatic(nameof(TYPE_RIGHT_ANKLE)); + public static int TYPE_RIGHT_ELBOW => sJavaClass.GetStatic(nameof(TYPE_RIGHT_ELBOW)); + public static int TYPE_RIGHT_HIP => sJavaClass.GetStatic(nameof(TYPE_RIGHT_HIP)); + public static int TYPE_RIGHT_KNEE => sJavaClass.GetStatic(nameof(TYPE_RIGHT_KNEE)); + public static int TYPE_RIGHT_SHOULDER => sJavaClass.GetStatic(nameof(TYPE_RIGHT_SHOULDER)); + public static int TYPE_RIGHT_WRIST => sJavaClass.GetStatic(nameof(TYPE_RIGHT_WRIST)); + + + + public float GetPointX() => Call("getPointX"); + public float GetPointY() => Call("getPointY"); + public float GetScore() => Call("getScore"); + public float GetType() => Call("getType"); + + public override bool Equals(object other) => CallAsBool("equals", other); + public override int GetHashCode() => Call("hashCode"); + } +} diff --git a/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeleton.cs b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeleton.cs new file mode 100644 index 0000000..2bf5e30 --- /dev/null +++ b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeleton.cs @@ -0,0 +1,27 @@ +using HuaweiMobileServices.Base; +using HuaweiMobileServices.Utils; +using System.Collections.Generic; +using UnityEngine; + +namespace HuaweiMobileServices.ML.SkeletonDetection +{ + public class MLSkeleton : JavaObjectWrapper + { + + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLSkeleton"; + + public MLSkeleton(AndroidJavaObject javaObject) : base(javaObject) + { + } + + public MLSkeleton(string javaObjectCanonicalName, params object[] args) : base(javaObjectCanonicalName, args) + { + } + + public IList GetJoints() => CallAsWrapperList("getJoints"); + + + public MLJoint GetJointPoint(int pointType) => CallAsWrapper("getJointPoint", pointType); + + } +} diff --git a/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzer.cs b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzer.cs new file mode 100644 index 0000000..efc3d9e --- /dev/null +++ b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzer.cs @@ -0,0 +1,36 @@ +using HuaweiMobileServices.Base; +using HuaweiMobileServices.ML.Common; +using HuaweiMobileServices.ML.TextRecognition; +using HuaweiMobileServices.Utils; +using System.Collections.Generic; +using UnityEngine; + +namespace HuaweiMobileServices.ML.SkeletonDetection +{ + public class MLSkeletonAnalyzer: JavaObjectWrapper + { + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzer"; + + public MLSkeletonAnalyzer(AndroidJavaObject javaObject) : base(javaObject) + { + } + + public MLSkeletonAnalyzer(string javaObjectCanonicalName, params object[] args) : base(javaObjectCanonicalName, args) + { + } + + //SparseArray + public IList AnalyseFrame(MLFrame mLFrame) => CallAsWrapperList("analyseFrame", mLFrame); + + public ITask> AsyncAnalyseFrame(MLFrame mlFrame) + { + var task = Call("asyncAnalyseFrame", mlFrame); + return new TaskWrapper>(task, AndroidJavaObjectExtensions.AsListFromWrappable); + } + + public float CaluteSimilarity(IList skeleton1, IList skeleton2) => Call("getScore", skeleton1 ,skeleton2); + + public void Stop() => Call("stop"); + + } +} diff --git a/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerFactory.cs b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerFactory.cs new file mode 100644 index 0000000..59d207a --- /dev/null +++ b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerFactory.cs @@ -0,0 +1,33 @@ +using HuaweiMobileServices.ML.Common; +using HuaweiMobileServices.ML.LanguageDetection; +using HuaweiMobileServices.ML.LanguageDetection.Local; +using HuaweiMobileServices.Utils; +using System; +using System.Collections.Generic; +using System.Text; +using UnityEngine; + +namespace HuaweiMobileServices.ML.SkeletonDetection +{ + public class MLSkeletonAnalyzerFactory : JavaObjectWrapper + { + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzerFactory"; + private static readonly AndroidJavaClass sJavaClass = new AndroidJavaClass(CLASS_NAME); + + public MLSkeletonAnalyzerFactory(AndroidJavaObject javaObject) : base(javaObject) + { + } + + public MLSkeletonAnalyzerFactory(string javaObjectCanonicalName, params object[] args) : base(javaObjectCanonicalName, args) + { + } + + public MLSkeletonAnalyzerFactory(MLApplication mlApplication) : base(CLASS_NAME, mlApplication) { } + + public static MLSkeletonAnalyzerFactory GetInstance() => sJavaClass.CallStaticAsWrapper("getInstance"); + + public MLSkeletonAnalyzer GetSkeletonAnalyzer() => CallAsWrapper("getSkeletonAnalyzer"); + public MLSkeletonAnalyzer GetSkeletonAnalyzer(MLSkeletonAnalyzerSetting setting) => CallAsWrapper("getSkeletonAnalyzer", setting); + + } +} diff --git a/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerSetting.cs b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerSetting.cs new file mode 100644 index 0000000..818f564 --- /dev/null +++ b/hms-sdk-unity/HuaweiMobileServices/ML/SkeletonDetection/MLSkeletonAnalyzerSetting.cs @@ -0,0 +1,38 @@ + +using HuaweiMobileServices.ML.LanguageDetection.Local; +using HuaweiMobileServices.Utils; +using UnityEngine; + +namespace HuaweiMobileServices.ML.SkeletonDetection +{ + public class MLSkeletonAnalyzerSetting : JavaObjectWrapper + { + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzerSetting"; + private static readonly AndroidJavaClass sJavaClass = new AndroidJavaClass(CLASS_NAME); + public MLSkeletonAnalyzerSetting(AndroidJavaObject javaObject) : base(javaObject) + { + } + + public MLSkeletonAnalyzerSetting(string javaObjectCanonicalName, params object[] args) : base(javaObjectCanonicalName, args) + { + } + + public static int TYPE_NORMAL => sJavaClass.GetStatic(nameof(TYPE_NORMAL)); + public static int TYPE_YOGA => sJavaClass.GetStatic(nameof(TYPE_YOGA)); + + + + public class Factory : JavaObjectWrapper + { + private const string CLASS_NAME = "com.huawei.hms.mlsdk.skeleton.MLSkeletonAnalyzerSetting$Factory"; + public Factory(AndroidJavaObject javaObject) : base(javaObject) { } + public Factory() : base(CLASS_NAME) { } + + public MLSkeletonAnalyzerSetting Create() => CallAsWrapper("create"); + + public Factory SetAnalyzerType(int analyzerType) => CallAsWrapper("setAnalyzerType", analyzerType); + + } + + } +}