| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- /// <summary>
- /// ZWN-XHJ
- /// 20211012
- /// </summary>
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class common_data : MonoBehaviour
- {
- public Dictionary<int, Vector3> zwn_single_vec = new Dictionary<int, Vector3>();//关于点数据的存储
- List<int> pointIndex = new List<int> { 0, 5, 6, 11, 12, 13, 14, 15, 16 };
- Vector3 head, right_hand, left_hand, right_shoulder, left_shoulder,
- right_hip, left_hip, right_knee, left_knee, right_ankle, left_ankle, right_ankle_last, left_ankle_last,
- chest, right_Elbow, left_Elbow;
- [HideInInspector]
- public List<int> detail_lists = new List<int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- bool pose_correct = false;
- int lose_num = 0, half_lose_num = 0, half_num_is_pose = 0, num_is_pose = 0;
- bool half_pose_correct = false;
- public static common_data single;
- void Awake()
- {
- single = this;
- for (int i = 0; i < 17; i++)
- {
- if (zwn_single_vec.ContainsKey(i))
- {
- zwn_single_vec[i] = new Vector3(-1, -1, 0);
- }
- else
- {
- zwn_single_vec.Add(i, new Vector3(-1, -1, 0));
- }
- }
- }
- // Update is called once per frame
- void Update()
- {
- //关于点数据的存储和更新
- #region
- //if (Helper.zwn_pose_true)
- //{
- // for (int i = 0; i < 17; i++)
- // {
- // if (zwn_single_vec.ContainsKey(i))
- // {
- // if (zwn_common_data.single.zwn_pose_cur.point.probs[i] > 0.35f)
- // {
- // zwn_single_vec[i] =
- // new Vector3(
- // zwn_common_data.single.zwn_pose_cur.point.landmarks[i].x,
- // Helper.Height
- // - zwn_common_data.single.zwn_pose_cur.point.landmarks[i].y, 0);
- // }
- // else
- // {
- // zwn_single_vec[i] = new Vector3(-1, -1, 0);
- // }
- // }
- // else
- // {
- // if (zwn_common_data.single.zwn_pose_cur.point.probs[i] > 0.35f)
- // {
- // zwn_single_vec.Add(i, new Vector3(
- // zwn_common_data.single.zwn_original_pose[i].x,
- // Helper.Height
- // - zwn_common_data.single.zwn_original_pose[i].y, 0));
- // }
- // else
- // {
- // zwn_single_vec.Add(i, new Vector3(-1, -1, 0));
- // }
- // }
- // }
- //}
- #endregion
- lose_num = 0;
- for (int i = 0; i < pointIndex.Count; i++)
- {
- if (zwn_single_vec[pointIndex[i]].x == -1 || zwn_single_vec[pointIndex[i]].y == -1)
- {
- lose_num += 1;
- }
- else
- {
- lose_num += 0;
- }
- }
- if (lose_num > 7)
- {
- num_is_pose += 1;
- if (num_is_pose > 30)
- {
- num_is_pose = 0;
- pose_correct = false;
- //"最新错误记录:" + "未检测到人体";
- detail_lists[2] = 0;
- }
- }
- else
- {
- pose_correct = true;
- //"\n有人";
- num_is_pose = 0;
- detail_lists[2] = 1;
- }
- half_lose_num = 0;
- for (int i = 0; i < pointIndex.Count - 4; i++)
- {
- if (zwn_single_vec[pointIndex[i]].x == -1 || zwn_single_vec[pointIndex[i]].y == -1)
- {
- half_lose_num += 1;
- }
- else
- {
- half_lose_num += 0;
- }
- }
- if (half_lose_num > 7 - 4)
- {
- half_num_is_pose += 1;
- if (half_num_is_pose > 30)
- {
- half_num_is_pose = 0;
- half_pose_correct = false;
- //"最新错误记录:" + "未检测到人体";
- detail_lists[3] = 0;
- }
- }
- else
- {
- half_pose_correct = true;
- //"\n有人";
- half_num_is_pose = 0;
- detail_lists[3] = 1;
- }
- }
- }
|