Example #1
0
    // Use this for initialization
    void Start()
    {
        gestureRecog = gameObject.GetComponent <BaiduARGestureRecog> ();
        particle     = particleObj.transform.GetComponent <ParticleSystem> ();

        if (isStartHandTracking)
        {
            var main = particle.main;
            main.loop = true;

            //System.Type type = particle.main.GetType ();
            //PropertyInfo property = type.GetProperty ("loop");
            //property.SetValue (particle.main, true, null);
        }

        //手势识别
        gestureRecog.OnResultCallBack((bool result) => {
            if (!isStartHandTracking)
            {
                ShowObject(result);
            }
        });

        //实验室功能 手势跟踪
        gestureRecog.OnResultTrackCallBack((List <RecogGesture> lstRecg) => {
            ARDebug.Log("lstRecg.Count; " + lstRecg.Count);
            //recogList = lstRecg;
            if (isStartHandTracking)
            {
                MoveObject(lstRecg);
            }
        });
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        results = GameObject.FindObjectsOfType <BaiduARImageRecognitionResult>();

        BaiduARImageTracker tracker = imageTracker.GetComponent <BaiduARImageTracker>();

        for (int i = 0; i < results.Length; i++)
        {
            for (int j = 0; j < imageTracker.transform.childCount; j++)
            {
                GameObject            obj       = imageTracker.transform.GetChild(j).gameObject;
                BaiduARImageTrackable trackable = obj.GetComponent <BaiduARImageTrackable>();

                if (results[i].filePath.Contains(trackable.filePath))
                {
                    ARDebug.Log("trackable object: " + trackable.name);
                    results[i].OnRespond.AddListener(
                        delegate()
                    {
                        this.ShowObject(trackable.gameObject);
                    });
                    break;
                }
            }
        }
        tracker.OnTrackFail.AddListener(OutFocus);
        ARDebug.Log("imageTracker.transform.childCount: " + imageTracker.transform.childCount);
    }
Example #3
0
    void ShowObject(GameObject obj)
    {
        if (!imageTracker.activeSelf)
        {
            imageTracker.SetActive(true);
        }

        if (currentObj == null || currentObj != obj)
        {
            currentObj = obj;

            BaiduARImageTrackable trackable = obj.GetComponent <BaiduARImageTrackable>();
            trackable.gameObject.SetActive(true);

            anim  = obj.GetComponent <Animator>();
            clips = obj.GetComponent <BaiduARImageTrackable>().clips;

            currentIndex = 0;
            if (audioSource.isPlaying)
            {
                audioSource.Stop();
            }

            ARDebug.Log("trackable.filePath: " + trackable.filePath);
            ARImageTracker.Instance.SetActiveTrack(trackable.filePath);
        }
    }
Example #4
0
    //解析
    private ErrorInfo CreateFromJson(string json)
    {
        ErrorInfo info = JsonUtility.FromJson <ErrorInfo>(json);

        ARDebug.Log("error_code:" + info.error_code + " " + "error_msg:" + info.error_msg);
        return(info);
    }
        public async Task <IActionResult> Remove(int id)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    Warehouse wh = Warehouse.GetWarehouse(id);

                    if (wh == null)
                    {
                        ARDebug.Log("Warehouse with given ID not found. ID: " + id);
                        return StatusCode(500);
                    }
                    else
                    {
                        wh.DBRemove();
                        return Ok();
                    }
                }
                catch (Exception ex)
                {
                    ARDebug.Log(ex.ToString());
                    return StatusCode(500);
                }
            }));
        }
Example #6
0
    // Use this for initialization
    void Start()
    {
        //ARLogin.Instance.OnStopCamera.AddListener (ErrorInfo);
        loading.SetActive(true);

        _sureButton.onClick.AddListener(ErrorOnClick);

        _cameraDevice = FindObjectOfType <BaiduARWebCamera>();
        Transform bg = transform.Find("ResetButton");

        if (bg != null)
        {
            resetBtn     = bg.GetComponent <RectTransform>();
            _resetButton = bg.GetComponent <Button>();
            _resetButton.onClick.AddListener(ResetOnClick);
            _arObjectTrackle = GameObject.FindObjectOfType <BaiduARObjectTrackable>();
        }

        int adjustHeight = 0;

        ARDebug.Log("SystemInfo.deviceModel = " + SystemInfo.deviceModel);

        ARDebug.Log("SystemInfo.nam = " + SystemInfo.deviceName);
        if (ARUtils.IsIPhoneX())
        {
            adjustHeight = 100;
        }

        if (null != resetBtn)
        {
            resetBtn.anchoredPosition3D = new Vector3(resetBtn.anchoredPosition3D.x, resetBtn.anchoredPosition3D.y + 2 * adjustHeight, resetBtn.anchoredPosition3D.z);
        }
        ;
    }
Example #7
0
        /// <summary>
        /// 双掌向前推,左手
        /// </summary>
        /// <returns><c>true</c>, if in waist was fisted, <c>false</c> otherwise.</returns>
        public static bool fistFrontToLeft(Vector3 Wrist, Vector3 elbow, Vector3 shoulder, Vector3 lHip)
        {
            int yAdjust = (int)(lengthShoulder / 2);

            if ((shoulder.y - elbow.y) > yAdjust)
            {
                ARDebug.Log("RistL is too back");
                return(false);
            }

            //判断左手向外插
            if (LeftHandToExtern(Wrist, elbow, shoulder))
            {
                return(false);
            }
            float lLength = shoulder.y - lHip.y;

            if ((Wrist.y - lHip.y) < lLength / 2)
            {
                ARDebug.Log("Mydatasl Wrist 太低");
                return(false);
            }
            if ((elbow.y - lHip.y) < lLength / 1.7)
            {
                ARDebug.Log("Mydatasl elbow 太低");
                return(false);
            }
            int disAdjust = (int)(lengthShoulder / 2);

            //肩膀和肘的距离比较近
            float distance    = (float)Math.Sqrt(Math.Pow((shoulder.y - elbow.y), 2) + Math.Pow((shoulder.x - elbow.x), 2));
            float dist        = (float)Math.Sqrt(Math.Pow((Wrist.y - elbow.y), 2) + Math.Pow((Wrist.x - elbow.x), 2));
            float alldistance = distance + dist;

            ARDebug.Log("alldistance = " + alldistance);
            ARDebug.Log("alldistance disAdjust = " + disAdjust);

            if (alldistance < disAdjust)
            {
                return(true);
            }

            if (Wrist.y > shoulder.y && (alldistance < (100 + disAdjust)))
            {
                return(true);
            }

            //下推掌
            int xAdjust = (int)(lengthShoulder / 15);

            if (Math.Abs(elbow.x - shoulder.x) < xAdjust && (alldistance < (200 + disAdjust)))
            {
                ARDebug.Log("lashenl error");
                return(true);
            }

            return(false);
        }
    public void OnPointerClick(PointerEventData eventData)
    {
        string NameofObject = gameObject.name;

        isOpen = !isOpen;

        Vector2 end = container.localScale;

        end.y = isOpen ? 1 : 0;
        anim  = new ValueAnim <Vector2, Vector2Animable>(container.localScale, end, 0.4f, Easing.easeInElastic);
        DebugScript.Log(NameofObject + " was pressed");
    }
Example #9
0
        //public static Queue<float>[] footDowns = new Queue<float>[2];
        public static bool FootDown(Vector3 firstVet, int index, Vector3 secondVet)
        {
            if (foots[index].Count < footsize)
            {
                return(false);
            }

            float firstFiveFrame = 0;
            float endFiveFrame   = 0;

            float[] footArray = foots[index].ToArray();

            for (int i = 0; i < footArray.Length; i++)
            {
                if (i < footsize / 2)
                {
                    endFiveFrame += footArray[i];
                }
                else
                {
                    firstFiveFrame += footArray[i];
                }
            }

            firstFiveFrame = firstFiveFrame * 2 / footsize;
            endFiveFrame   = endFiveFrame * 2 / footsize;

            float adjust = lengthShoulder / 12;

            if (ARGlobalDefs.IsIosPlatform())
            {
                adjust = lengthShoulder / 18;
            }
            ARDebug.Log("LiftDown adjust == " + adjust);
            ARDebug.Log("LiftDown endFiveFrame == " + endFiveFrame);
            ARDebug.Log("LiftDown firstFiveFrame == " + firstFiveFrame);
            ARDebug.Log("dowaLiftDown ffffirstVet.y == " + firstVet.y);
            float AdjustHeight = adjust * 2;

            if (ARGlobalDefs.IsIosPlatform())
            {
                AdjustHeight = adjust * 3;
            }
            if ((endFiveFrame - firstFiveFrame) > adjust && Math.Abs(firstVet.y - secondVet.y) < AdjustHeight)
            {
                ARDebug.Log("dowaddLiftDownfff datas footDown Dwon i = " + index);
                return(true);
            }
            return(false);
        }
Example #10
0
        /// <summary>
        /// 检测双掌在胸前左手
        /// </summary>
        /// <returns><c>true</c>, if in waist was fisted, <c>false</c> otherwise.</returns>
        public static bool fistFrontChestLeft(Vector3 Wrist, Vector3 elbow, Vector3 shoulder, Vector3 lHip)
        {
            bool ret = false;

            int yAdjust = (int)(lengthShoulder / 18);

            float xDis = shoulder.x - elbow.x;

            if (ARGlobalDefs.IsIosPlatform())
            {
                if (ARScreen.Instance.IsFrontCamera)
                {
                    xDis = -xDis;
                }
            }
            //shoulder和Elbow不在一条直线上
            if (xDis < yAdjust)
            {
                ARDebug.Log("lashen  error");
                return(false);
            }
            //shoulder和elbow不在一起
            if (Math.Abs(shoulder.y - Wrist.y) < yAdjust / 2)
            {
                ARDebug.Log("lashen chayao front no Check");
                return(false);
            }

            float lLength = shoulder.y - lHip.y;

            if ((Wrist.y - lHip.y) < lLength / 1.7)
            {
                ARDebug.Log("Mydatasl Wrist 太低");
                return(false);
            }

            if (fistFrontToLeft(Wrist, elbow, shoulder, lHip))
            {
                ARDebug.Log("lashenqqq Wrist 太高");
                return(false);
            }
            float angle = GetAngle(Wrist, elbow, shoulder);

            if (angle < 180)
            {
                return(true);
            }

            return(ret);
        }
 public async Task <IActionResult> Update(Warehouse wh)
 {
     return(await Task.Run(() =>
     {
         try
         {
             wh.DBUpdate();
             return Ok();
         }
         catch (Exception ex)
         {
             ARDebug.Log(ex.ToString());
             return StatusCode(500);
         }
     }));
 }
Example #12
0
        /// <summary>
        /// 检测双掌合十
        /// </summary>
        /// <returns><c>true</c>, if in waist was fisted, <c>false</c> otherwise.</returns>
        public static bool fistTogether(Vector3 lWrist, Vector3 rWrist)
        {
            int xAdjust = (int)((lengthShoulder / 2));
            int yAdjust = (int)((lengthShoulder / 4));

            if (Math.Abs(lWrist.y - rWrist.y) < yAdjust)
            {
                ARDebug.Log("fistInchayao front no Checking");
                if (Math.Abs(lWrist.x - rWrist.x) < xAdjust)
                {
                    ARDebug.Log("fistInchayao front no Check");
                    return(true);
                }
            }
            return(false);
        }
Example #13
0
        //index = 0表示左脚   index = 1表示右脚
        public static bool FootLift(Vector3 firstVet, int index)
        {
            if (foots[index].Count < footsize)
            {
                return(false);
            }

            float firstFiveFrame = 0;
            float endFiveFrame   = 0;

            float[] footArray = foots[index].ToArray();

            for (int i = 0; i < footArray.Length; i++)
            {
                if (i < footsize / 2)
                {
                    endFiveFrame += footArray[i];
                }
                else
                {
                    firstFiveFrame += footArray[i];
                }
            }
            firstFiveFrame = firstFiveFrame * 2 / footsize;
            endFiveFrame   = endFiveFrame * 2 / footsize;

            float adjust = lengthShoulder / 8;

            if (ARGlobalDefs.IsIosPlatform())
            {
                adjust = lengthShoulder / 12;
            }
            ARDebug.Log("LiftUp adjust == " + adjust);
            ARDebug.Log("LiftUp endFiveFrame == " + endFiveFrame);
            ARDebug.Log("dowaLiftUpfff firstFiveFrame == " + firstFiveFrame);
            ARDebug.Log("dowaLiftDown ffffirstVet.y == " + firstVet.y);
            if ((endFiveFrame - firstFiveFrame) > adjust)
            {
                ARDebug.Log("dowaddLiftUpfff datas footLift Dwon i = " + index);
                return(true);
            }
            return(false);
        }
Example #14
0
 void ShowObject(bool isrecognition)
 {
     ARDebug.Log("isrecognition: " + isrecognition);
     if (isrecognition)
     {
         if (!particle.isPlaying)
         {
             particle.Play();
         }
     }
     else
     {
         if (!particle.isPlaying)
         {
             particle.Stop();
         }
     }
     particleObj.transform.position = new Vector3(0, 0, 100);
 }
Example #15
0
        public bool CheckEffect(int index, Vector3 firstVet, Vector3 secondVet, Vector3 endVet, Vector3 dstVet)
        {
            if (!IsFootUp[index])
            {
                // IsFootUp[index] = ARBodyDataParse.FootLift(firstVet, secondVet,endVet,dstVet);
                IsFootUp[index] = ARHumanBodyDataParse.FootLift(firstVet, index);
                if (IsFootUp[index])
                {
                    ARDebug.Log("index = " + index);
                    if (index == 0)
                    {
                        StopCoroutine("ActionDisable_One");
                        StartCoroutine("ActionDisable_One", index);
                    }
                    else
                    {
                        StopCoroutine("ActionDisable_Two");
                        StartCoroutine("ActionDisable_Two", index);
                    }
                }

                //StartEffect(firstVet, index);
            }
            else
            {
                IsFootDown[index] = ARHumanBodyDataParse.FootDown(firstVet, index, endVet);
                if (IsFootDown[index])
                {
                    //ARDebug.Log("index11 = " + index);
                    IsFootUp[index]   = false;
                    IsFootDown[index] = false;
                    //开启特效
                    StartEffect(firstVet, index);
                    return(true);
                }
            }

            return(false);
        }
Example #16
0
 // Update is called once per frame
 void Update()
 {
     ARDebug.Log("ARExampleContorller Update");
 }
        private void FistFrontChest(List <OutPutData> lstVet, int i)
        {
            bool RightFistFrontChest = false;
            bool LeftFistFrontChest  = false;

            if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5 || lstVet[i - 2].score < 0.5 ||
                lstVet[i + 3].score < 0.5 || lstVet[i + 2].score < 0.5 || lstVet[i + 1].score < 0.5)
            {
                StopSoundEffect(1);
                return;
            }

            if (!wistTogether)
            {
                RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);;
                LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);
                if (RightFistFrontChest && LeftFistFrontChest)
                {
                    if (ARHumanBodyDataParse.fistTogether(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos))
                    {
                        wistTogether = true;
                    }
                }
            }

            if (wistTogether)
            {
                //双掌在胸前的动作
                RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);;
                LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);

                if (RightFistFrontChest && LeftFistFrontChest)
                {
                    FistFrontChestFrameCount = 0;
                    //双掌在胸前动作
                    StopCoroutine("WaitFrontChestEnable");
                    StartCoroutine("WaitFrontChestEnable");
                    ARDebug.Log("chayao chestFront");

                    Vector3 centerChest = (lstVet[i].VectorScreenPos + lstVet[i + 3].VectorScreenPos) / 2;
                    centerChest.y = centerChest.y + ARHumanBodyDataParse.lengthShoulder / 20;
                    //  Vector2 centerChest = new Vector2((lstVet[i].VectorScreenPos.x + lstVet[i +3].VectorScreenPos.x)/2,(lstVet[i].VectorScreenPos.y + lstVet[i + 3].VectorScreenPos.y)/2);
                    ARDebug.Log("my = " + centerChest.x + "  " + centerChest.y);

                    float distance = Vector2.Distance(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos);
                    float z        = 20;
                    z = z * 500 / distance;
                    Static_pose[1].transform.position = ARHumanBodyDataParse.GetGroundVet(centerChest, 0, 0, z);

                    if (!audios[1].activeSelf)
                    {
                        audios[1].SetActive(true);
                    }
                    ARDebug.Log("chayao chestFront Hinde");
                    if (!Static_pose[1].activeSelf)
                    {
                        Static_pose[1].SetActive(true);
                    }
                    audios[0].SetActive(false);

                    return;
                }
                else
                {
                    FistFrontChestFrameCount++;
                    if (FistFrontChestFrameCount > (DomainNumber - 3))
                    {
                        StopSoundEffect(1);
                    }
                }
            }
            else
            {
                //特效消失
                FistFrontChestFrameCount++;
                if (FistFrontChestFrameCount > (DomainNumber - 3))
                {
                    StopSoundEffect(1);
                }
            }
        }
        private void FistFrontIn(List <OutPutData> lstVet, int i)
        {
            bool RightFistFrontChest = false;
            bool LeftFistFrontChest  = false;

            bool RightFistFrontTo = false;
            bool LeftFistFrontTo  = false;

            if (lstVet[i].score < 0.5 || lstVet[i - 1].score < 0.5 || lstVet[i - 2].score < 0.5 ||
                lstVet[i + 3].score < 0.5 || lstVet[i + 2].score < 0.5 || lstVet[i + 1].score < 0.5)
            {
                return;
            }

            RightFistFrontChest = ARHumanBodyDataParse.fistFrontChestRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);
            LeftFistFrontChest  = ARHumanBodyDataParse.fistFrontChestLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);

            if (RightFistFrontChest && LeftFistFrontChest)
            {
                IsWistFrontChest = true;
            }

            if (IsWistFrontChest)
            {
                //双掌向前推动作
                RightFistFrontTo = ARHumanBodyDataParse.fistFrontToRight(lstVet[i].VectorScreenPos, lstVet[i - 1].VectorScreenPos, lstVet[i - 2].VectorScreenPos, lstVet[i + 4].VectorScreenPos);
                LeftFistFrontTo  = ARHumanBodyDataParse.fistFrontToLeft(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos, lstVet[i + 1].VectorScreenPos, lstVet[i + 7].VectorScreenPos);


                if (RightFistFrontTo && LeftFistFrontTo)
                {
                    if (ARHumanBodyDataParse.FistIntenal(lstVet[i - 1].VectorScreenPos, lstVet[i].VectorScreenPos) &&
                        ARHumanBodyDataParse.FistIntenal(lstVet[i + 3].VectorScreenPos, lstVet[i + 2].VectorScreenPos))
                    {
                        return;
                    }
                    IsWistFrontChest         = false;
                    wistTogether             = false;
                    FistFrontChestFrameCount = DomainNumber + 5;
                    StopCoroutine("WaitFrontChestEnable");
                    //时间到了消失
                    if (!Static_pose[2].activeSelf)
                    {
                        Static_pose[2].SetActive(true);
                    }
                    Static_pose[2].GetComponent <ParticleSystem>().Play();
                    Vector3 centerChest = (lstVet[i].VectorScreenPos + lstVet[i + 3].VectorScreenPos) / 2;
                    //  Vector2 centerChest = new Vector2((lstVet[i].VectorScreenPos.x + lstVet[i +3].VectorScreenPos.x)/2,(lstVet[i].VectorScreenPos.y + lstVet[i + 3].VectorScreenPos.y)/2);
                    ARDebug.Log("my = " + centerChest.x + "  " + centerChest.y);

                    float distance = Vector2.Distance(lstVet[i].VectorScreenPos, lstVet[i + 3].VectorScreenPos);
                    ARDebug.Log("distance = " + distance);
                    float z = 20;
                    z = z * 500 / distance;
                    Static_pose[2].transform.position = ARHumanBodyDataParse.GetGroundVet(centerChest, 0, 0, 1000 / ARHumanBodyDataParse.lengthShoulder);
                    //Static_pose[2].transform.position = ARBodyDataParse.GetGroundVet(centerChest, 0, 0, 2);
                    //双掌向前推动作
                    ARDebug.Log("chayao wistFront");

                    if (!audios[2].activeSelf)
                    {
                        audios[2].SetActive(true);
                    }
                    audios[2].GetComponent <AudioSource>().Play();
                    return;
                }
            }
        }
        // Use this for initialization
        void Awake()
        {
            electRoot = FindObjectOfType <ARHumanExampleElectric>();
            footRoot  = FindObjectOfType <ARHumanExampleFootLift>();
            BaiduARHumanPose humanPose = FindObjectOfType <BaiduARHumanPose>();

            exampleUI = FindObjectOfType <ARExampleUI>();
            humanPose.InvokeErrorMessage(delegate(string errNum, string errMsg)
            {
                exampleUI.ErrorInfo(errNum, errMsg);
                ARDebug.LogError("errMsg = " + errMsg);
            });

            humanPose.InvokeClearMessage(delegate()
            {
                ARDebug.Log("InvokeClearMessage ");
                objs.Clear();
            });
            humanPose.InvokePosMessage(delegate(List <OutPutData> lstVet)
            {
                if (lstVet[1].score > 0 && lstVet[8].score > 0)
                {
                    ARHumanBodyDataParse.lengthShoulder = Vector2.Distance(lstVet[1].VectorScreenPos, lstVet[8].VectorScreenPos);
                    ARDebug.Log("datas lengthShoulder = " + ARHumanBodyDataParse.lengthShoulder);

                    if (lstVet[10].score > 0 && lstVet[13].score > 0)
                    {
                        float left  = Vector2.Distance(lstVet[10].VectorScreenPos, lstVet[8].VectorScreenPos);
                        float right = Vector2.Distance(lstVet[13].VectorScreenPos, lstVet[11].VectorScreenPos);
                        if (right < ARHumanBodyDataParse.lengthShoulder && left < ARHumanBodyDataParse.lengthShoulder)
                        {
                            return;
                        }
                    }
                }



                int z = (int)(ARHumanBodyDataParse.lengthShoulder / 60);

                int ZeroCount = 0;
                for (int i = 0; i < lstVet.Count; i++)
                {
                    if (lstVet[i].score > 0.6)
                    {
                        //  if ( i == 4 ||  i == 2 || i == 7  || i ==5)
                        {
                            //GameObject item = objs.GetItem();
                            //if (item == null)
                            //{
                            //    item = CreateCircleGame(z);
                            //    objs.Add(item);
                            //}
                            //item.transform.localScale = Vector3.one * z;
                            //item.SetActive(true);
                            //// item.transform.position = GameObject.Find("UICamera").GetComponent<Camera>().ScreenToWorldPoint(lstVet[i].VectorScreenPos);//lstVet[i].VectorWorldPos;
                            //item.transform.position = FindObjectOfType<ARWebCamera>().GetComponent<Camera>().ScreenToWorldPoint(lstVet[i].VectorScreenPos);//lstVet[i].VectorWorldPos;
                        }
                    }
                    else
                    {
                        ZeroCount++;
                    }
                }
                if (ZeroCount > 15)
                {
                    objs.Clear();
                }

                if (ARHumanBodyDataParse.foots[0] == null)
                {
                    ARHumanBodyDataParse.foots[0] = new Queue <float>();
                    ARHumanBodyDataParse.foots[1] = new Queue <float>();
                }
                if (ARHumanBodyDataParse.foots[0].Count < ARHumanBodyDataParse.footsize)
                {
                    ARHumanBodyDataParse.foots[0].Enqueue(lstVet[10].VectorScreenPos.y);
                    ARHumanBodyDataParse.foots[1].Enqueue(lstVet[13].VectorScreenPos.y);
                }
                else
                {
                    ARHumanBodyDataParse.foots[0].Dequeue();
                    ARHumanBodyDataParse.foots[1].Dequeue();

                    ARHumanBodyDataParse.foots[0].Enqueue(lstVet[10].VectorScreenPos.y);
                    ARHumanBodyDataParse.foots[1].Enqueue(lstVet[13].VectorScreenPos.y);
                }

                electRoot.Electric(lstVet);
                StaticPose(lstVet);

                if (lstVet[10].score > 0 && lstVet[13].score > 0)
                {
                    float left  = Vector2.Distance(lstVet[10].VectorScreenPos, lstVet[8].VectorScreenPos);
                    float right = Vector2.Distance(lstVet[13].VectorScreenPos, lstVet[11].VectorScreenPos);
                    if (right < ARHumanBodyDataParse.lengthShoulder && left < ARHumanBodyDataParse.lengthShoulder)
                    {
                        lastNosePose = lstVet[0].VectorScreenPos;
                        return;
                    }

                    if (!lastNosePose.Equals(Vector2.one))
                    {
                        float Distan = Vector2.Distance(lastNosePose, lstVet[0].VectorScreenPos);
                        lastNosePose = lstVet[0].VectorScreenPos;
                        //Debug.Log("Distan="+Distan);
                        if (Distan > ARHumanBodyDataParse.lengthShoulder / 10)
                        {
                            ARHumanBodyDataParse.foots[0].Clear();
                            ARHumanBodyDataParse.foots[1].Clear();
                            return;
                        }
                    }
                }
                lastNosePose = lstVet[0].VectorScreenPos;
                footRoot.FootLift(lstVet);
            });
        }
Example #20
0
 void Start()
 {
     ARDebug.Log("ARExampleController Start");
 }
Example #21
0
        // Use this for initialization
        void Awake()
        {
            //return;
            BaiduARHumanPose humanPose = FindObjectOfType <BaiduARHumanPose>();

            humanPose.InvokeErrorMessage(delegate(string errNum, string errMsg) {
                ARDebug.LogError("errMsg = " + errMsg);
            });


            humanPose.InvokeClearMessage(delegate(){
                ARDebug.Log("InvokeClearMessage ");
                objs.Clear();
            });

            humanPose.InvokePosMessage(delegate(List <OutPutData> lstVet)
            {
                ARDebug.Log("InvokePosMessage Init lstVet = " + lstVet.Count);
                for (int i = 0; i < lstVet.Count; i++)
                {
                    // ARDebug.Log("i = "+i + " score="+lstVet[i].score);
                    if (lstVet[i].score > 0.6)
                    {
                        GameObject item = objs.GetItem();
                        if (item == null)
                        {
                            item = CreateCircleGame();
                            objs.Add(item);
                        }
                        item.SetActive(true);
                        item.transform.position = lstVet[i].VectorWorldPos;
                    }
                }
                if (lstVet.Count < 18)
                {
                    return;
                }
                ARDebug.Log("InvokePosMessage Init22");
                Vector2 vetpos = new Vector2(lstVet[1].VectorScreenPos.x, lstVet[1].VectorScreenPos.y + (lstVet[1].VectorScreenPos.x - lstVet[2].VectorScreenPos.x));
                if (null == collideScript)
                {
                    collideScript = FindObjectOfType <CollideManage>();
                }
                collideScript.SetTexiaoPos(vetpos);


                for (int i = 0; i < lstVet.Count; i++)
                {
                    if (i == 4)  //表示右手腕
                    {
                        Vector2 vet = Vector2.zero;
                        if (IsBound(lstVet[i].VectorScreenPos)) //如果没有检测到点
                        {
                            lstVet[i].VectorScreenPos = lastVet_righthand;
                        }
                        if (IsBound(lstVet[i - 1].VectorScreenPos)) //如果没有检测到点
                        {
                            lstVet[i - 1].VectorScreenPos = lastVet_righthand;
                        }

                        GetHandPos(lstVet[i - 1].VectorScreenPos, lstVet[i].VectorScreenPos, out vet);

                        if (null == collideScript)
                        {
                            collideScript = FindObjectOfType <CollideManage>();
                        }
                        if (!IsBound(vet))
                        {
                            collideScript.HandleData(vet, HumanPoseType.POSE_RIGHTHAND);
                            lastVet_righthand = vet;
                        }
                    }
                    if (i == 7)  //表示左手腕
                    {
                        Vector2 vet = Vector2.zero;
                        if (IsBound(lstVet[i].VectorScreenPos)) //如果没有检测到点
                        {
                            lstVet[i].VectorScreenPos = lastVet_lefthand;
                        }
                        if (IsBound(lstVet[i - 1].VectorScreenPos)) //如果没有检测到点
                        {
                            lstVet[i - 1].VectorScreenPos = lastVet_lefthand;
                        }

                        GetHandPos(lstVet[i - 1].VectorScreenPos, lstVet[i].VectorScreenPos, out vet);

                        if (null == collideScript)
                        {
                            collideScript = FindObjectOfType <CollideManage>();
                        }
                        if (!IsBound(vet))
                        {
                            collideScript.HandleData(vet, HumanPoseType.POSE_LEFTHAND);
                            lastVet_lefthand = vet;
                        }
                        // collideScript.HandleData(lstVet[i].VectorScreenPos);
                    }
                    if (i == 10) //表示右脚
                    {
                        if (null == collideScript)
                        {
                            collideScript = FindObjectOfType <CollideManage>();
                        }
                        if (IsBound(lstVet[i].VectorScreenPos))
                        {
                            lstVet[i].VectorScreenPos = lastVet_rightwrist;
                        }
                        if (!IsBound(lstVet[i].VectorScreenPos))
                        {
                            collideScript.HandleData(lstVet[i].VectorScreenPos, HumanPoseType.POSE_RIGHTWRIST);
                            lastVet_rightwrist = lstVet[i].VectorScreenPos;
                        }
                    }
                    if (i == 13) //表示左脚
                    {
                        if (null == collideScript)
                        {
                            collideScript = FindObjectOfType <CollideManage>();
                        }
                        if (IsBound(lstVet[i].VectorScreenPos))
                        {
                            lstVet[i].VectorScreenPos = lastVet_leftwrist;
                        }
                        if (!IsBound(lstVet[i].VectorScreenPos))
                        {
                            collideScript.HandleData(lstVet[i].VectorScreenPos, HumanPoseType.POSE_LEFTWRIST);
                            lastVet_leftwrist = lstVet[i].VectorScreenPos;
                        }
                    }
                }
            });
        }