/// <summary> ///录入关节信息 /// </summary> /// <param name="playerGesture"></param> public void SetGestureJointData(PlayerGestureInfo.GestureType gestureType, PlayerGestureData playerGesture) { SetGestureJointPos(gestureType, playerGesture, HandRightJoints); SetGestureJointPos(gestureType, playerGesture, HandLeftJoints); SetGestureJointPos(gestureType, playerGesture, FootRightJoints); SetGestureJointPos(gestureType, playerGesture, FootLeftJoints); byte[] buff = KINECTManager.Instance.GetOrbbecImage(KinectImageType.colour).ScaleTexture(192, 108).EncodeToJPG(10); Texture2D texture2D = new Texture2D(0, 0); texture2D.LoadImage(buff); texture2D.Apply(); switch (gestureType) { case PlayerGestureInfo.GestureType.End: playerGesture.playerGestureInfo.intoPhotoBase64 = new _Texture2D(texture2D); //保存当前图像成Base64作为识别手势的标准 break; case PlayerGestureInfo.GestureType.Start: playerGesture.playerGestureInfo.leavePhotoBase64 = new _Texture2D(texture2D); //保存当前图像成Base64作为识别手势的标准 break; default: break; } GC.Collect(); Resources.UnloadUnusedAssets();//内存释放 }
//封装设置关节方向方法, private void SetGestureJointPos(PlayerGestureInfo.GestureType gestureType, PlayerGestureData playerGesture, KinectInterop.JointType[] jointTypes) { for (int i = 0; i < jointTypes.Length - 1; i++) { Vector3 pos1 = KINECTManager.Instance.GetIndexJointPos(0, jointTypes[i], Camera.main, new Rect(0, 0, 1920, 1080)); Vector3 pos2 = KINECTManager.Instance.GetIndexJointPos(0, jointTypes[i + 1], Camera.main, new Rect(0, 0, 1920, 1080)); _Vector3 dis = new _Vector3((pos2 - pos1).normalized); playerGesture.playerGestureInfo.SetPlayerGestureJointData(gestureType, jointTypes[i], dis); } }