///
/// ZWN-XHJ
/// 20211012
///
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class common_data : MonoBehaviour
{
public Dictionary zwn_single_vec = new Dictionary();//关于点数据的存储
List pointIndex = new List { 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 detail_lists = new List { 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;
}
}
}