Ejemplo n.º 1
0
 private void AddHandSkeletonStringBuffer(StringBuilder sb, ARHand hand)
 {
     sb.Append(System.Environment.NewLine).Append("Handtype=").Append(hand.Handtype)
     .Append(System.Environment.NewLine);
     sb.Append("SkeletonCoordinateSystem=").Append(hand.SkeletonCoordinateSystem);
     sb.Append(System.Environment.NewLine);
     float[] skeletonArray = hand.GetHandskeletonArray();
     sb.Append("HandskeletonArray length:[").Append(skeletonArray.Length).Append("]")
     .Append(System.Environment.NewLine);
     Log.Info(TAG, "SkeletonArray.length:" + skeletonArray.Length);
     for (int i = 0; i < skeletonArray.Length; i++)
     {
         Log.Info(TAG, "SkeletonArray:" + skeletonArray[i]);
     }
     sb.Append(System.Environment.NewLine);
     int[] handSkeletonConnection = hand.GetHandSkeletonConnection();
     sb.Append("HandSkeletonConnection length:[").Append(handSkeletonConnection.Length)
     .Append("]").Append(System.Environment.NewLine);
     Log.Info(TAG, "handSkeletonConnection.length:" + handSkeletonConnection.Length);
     for (int i = 0; i < handSkeletonConnection.Length; i++)
     {
         Log.Info(TAG, "handSkeletonConnection:" + handSkeletonConnection[i]);
     }
     sb.Append(System.Environment.NewLine).Append("-----------------------------------------------------");
 }
Ejemplo n.º 2
0
 void Start()
 {
     LandmarkObj     = Manager.instance.LandmarkObj;
     currentHand     = new ARHand();
     currentHandRect = new HandRect();
     oldHandRect     = new HandRect();
 }
Ejemplo n.º 3
0
 void Start()
 {
     Hand            = Manager.instance.HandOnSpace;
     currentHand     = new ARHand();
     currentHandRect = new HandRect();
     oldHandRect     = new HandRect();
 }
Ejemplo n.º 4
0
        public ARTrackable ARTrackableFactory(IntPtr nativeHandle, bool isCreate = false)
        {
            if (nativeHandle == IntPtr.Zero)
            {
                return(null);
            }
            ARTrackable result;

            if (m_trackableDict.TryGetValue(nativeHandle, out result))
            {
                m_ndkSession.TrackableAdapter.Release(nativeHandle);
                return(result);
            }
            if (isCreate)
            {
                NDKARTrackableType ndkTrackableType = m_ndkSession.TrackableAdapter.GetType(nativeHandle);
                ARDebug.LogInfo("trackable type {0}", ndkTrackableType.ToString());
                switch (ndkTrackableType)
                {
                case NDKARTrackableType.Plane:
                    result = new ARPlane(nativeHandle, m_ndkSession);
                    break;

                case NDKARTrackableType.Point:
                    result = new ARPoint(nativeHandle, m_ndkSession);
                    break;

                case NDKARTrackableType.Body:
                    result = new ARBody(nativeHandle, m_ndkSession);
                    break;

                case NDKARTrackableType.Hand:
                    result = new ARHand(nativeHandle, m_ndkSession);
                    break;

                case NDKARTrackableType.Face:
                    result = new ARFace(nativeHandle, m_ndkSession);
                    break;

                case NDKARTrackableType.AugmentedImage:
                    result = new ARAugmentedImage(nativeHandle, m_ndkSession);
                    break;

                //todo add more trackable
                default:
                    m_ndkSession.TrackableAdapter.Release(nativeHandle);
                    throw new NotImplementedException("ARTrackableFactory: no constructor for requested type");
                }

                m_trackableDict.Add(nativeHandle, result);
                return(result);
            }
            return(null);
        }
Ejemplo n.º 5
0
 void Start()
 {
     Hand            = HTManager.instance.HandOnSpace;
     TriHand         = HTManager.instance.TriHand;
     Triangle        = HTManager.instance.Triangle;
     controller      = Triangle.transform.Find("Controller").GetComponent <VRHandController>();
     geo             = HTManager.instance.Geometry;
     currentHand     = new ARHand();
     currentHandRect = new HandRect();
     oldHandRect     = new HandRect();
 }
Ejemplo n.º 6
0
 private void AddGestureActionStringBuffer(StringBuilder sb, ARHand hand)
 {
     int[] gestureAction = hand.GetGestureAction();
     sb.Append("gestureAction length:[").Append(gestureAction.Length).Append("]").Append(System.Environment.NewLine);
     for (int i = 0; i < gestureAction.Length; i++)
     {
         Log.Info(TAG, "GestureAction:" + gestureAction[i]);
         sb.Append("gestureAction[").Append(i).Append("]:[").Append(gestureAction[i])
         .Append("]").Append(System.Environment.NewLine);
     }
     sb.Append(System.Environment.NewLine);
 }
Ejemplo n.º 7
0
 private void AddGestureCenterStringBuffer(StringBuilder sb, ARHand hand)
 {
     float[] gestureCenter = hand.GetGestureCenter();
     sb.Append("gestureCenter length:[").Append(gestureCenter.Length).Append("]").Append(System.Environment.NewLine);
     for (int i = 0; i < gestureCenter.Length; i++)
     {
         Log.Info(TAG, "GestureCenter:" + gestureCenter[i]);
         sb.Append("gestureCenter[").Append(i).Append("]:[").Append(gestureCenter[i])
         .Append("]").Append(System.Environment.NewLine);
     }
     sb.Append(System.Environment.NewLine);
 }
Ejemplo n.º 8
0
 private void AddHandNormalStringBuffer(StringBuilder sb, ARHand hand)
 {
     sb.Append("GestureType=").Append(hand.GestureType).Append(System.Environment.NewLine);
     sb.Append("GestureCoordinateSystem=").Append(hand.GestureCoordinateSystem).Append(System.Environment.NewLine);
     float[] gestureOrientation = hand.GetGestureOrientation();
     sb.Append("gestureOrientation length:[").Append(gestureOrientation.Length).Append("]")
     .Append(System.Environment.NewLine);
     for (int i = 0; i < gestureOrientation.Length; i++)
     {
         Log.Info(TAG, "gestureOrientation:" + gestureOrientation[i]);
         sb.Append("gestureOrientation[").Append(i).Append("]:[").Append(gestureOrientation[i])
         .Append("]").Append(System.Environment.NewLine);
     }
     sb.Append(System.Environment.NewLine);
 }
Ejemplo n.º 9
0
        public void Initialize(ARHand hand)
        {
            m_hand       = hand;
            m_handCamera = Camera.main;

            m_hwCube = GameObject.Find("Cube");
            m_hwCube.SetActive(false);
            m_spider = GameObject.Find("spider3");
            m_spider.SetActive(false);
            m_spiderColor = GameObject.Find("spider");
            m_spiderColor.transform.localScale = new Vector3(0, 0, 0);
            m_bulbasaur = GameObject.Find("bulbasaur");
            m_bulbasaur.SetActive(false);
            m_lightBlast = GameObject.Find("energyBlast");
            m_lightBlast.SetActive(false);

            m_handBox = new GameObject("HandBox");
            m_handBox.transform.localScale    = new Vector3(1f, 1f, 1f);
            m_handBox.transform.position      = new Vector3(0f, 0f, 0f);
            m_handBox.transform.localPosition = new Vector3(0, 0, 0);
            m_handBox.SetActive(false);

            m_boxLineRenderer = m_handBox.AddComponent <LineRenderer>();
            m_boxLineRenderer.positionCount = 5;
            m_boxLineRenderer.startWidth    = 0.03f;
            m_boxLineRenderer.endWidth      = 0.03f;


            //hand skeleton
            m_handSkeleton = new GameObject("HandSkeleton");
            m_handSkeleton.SetActive(false);
            for (int i = 0; i < m_kMaxSkeletonPoint; i++)
            {
                m_handSkeletonPoint[i] = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                m_handSkeletonPoint[i].transform.localScale = new Vector3(0.008f, 0.008f, 0.008f);
                m_handSkeletonPoint[i].transform.SetParent(m_handSkeleton.transform, false);
            }
            for (int i = 0; i < m_kMaxSkeletonConnections; i++)
            {
                m_handSkeletonLines[i] = new GameObject();
                m_handSkeletonLines[i].transform.SetParent(m_handSkeleton.transform, false);

                m_handSkeletonConnectionRenderer[i] = m_handSkeletonLines[i].AddComponent <LineRenderer>();
                m_handSkeletonConnectionRenderer[i].positionCount = 2;
                m_handSkeletonConnectionRenderer[i].startWidth    = 0.003f;
                m_handSkeletonConnectionRenderer[i].endWidth      = 0.003f;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Update gesture-related information.
        /// </summary>
        /// <param name="sb">String buffer.</param>
        /// <param name="hand">ARHand.</param>
        private void UpdateMessageData(StringBuilder sb, ARHand hand)
        {
            float fpsResult = DoFpsCalculate();

            sb.Append("FPS=").Append(fpsResult).Append(System.Environment.NewLine);
            AddHandNormalStringBuffer(sb, hand);
            AddGestureActionStringBuffer(sb, hand);
            AddGestureCenterStringBuffer(sb, hand);
            float[] gestureHandBoxPoints = hand.GetGestureHandBox();

            sb.Append("GestureHandBox length:[").Append(gestureHandBoxPoints.Length).Append("]")
            .Append(System.Environment.NewLine);
            for (int i = 0; i < gestureHandBoxPoints.Length; i++)
            {
                Log.Info(TAG, "gesturePoints:" + gestureHandBoxPoints[i]);
                sb.Append("gesturePoints[").Append(i).Append("]:[").Append(gestureHandBoxPoints[i]).Append("]")
                .Append(System.Environment.NewLine);
            }
            AddHandSkeletonStringBuffer(sb, hand);
        }
 // return true nếu 1 cao hơn 2
 public bool isHigherByLandmark(ARHand state1, ARHand state2, int landmark, int distance)
 {
     return(cam.WorldToScreenPoint(state1.GetLandmark(landmark)).y - cam.WorldToScreenPoint(state2.GetLandmark(landmark)).y > distance);
 }
 void Start()
 {
     Hand        = GameObject.Find("HandOnSpace");
     currentHand = new ARHand();
 }
 public bool isHigerThan(ARHand hand, int landmark1, int landmark2, float distance)
 {
     return(cam.WorldToScreenPoint(hand.GetLandmark(landmark1)).y - cam.WorldToScreenPoint(hand.GetLandmark(landmark2)).y > distance);
 }
 public bool angleFingerStraight(ARHand hand, int fingerWirst)
 {
     return(Vector3.Angle(hand.GetLandmark(fingerWirst + 1) - hand.GetLandmark(fingerWirst), hand.GetLandmark(fingerWirst + 2) - hand.GetLandmark(fingerWirst + 1)) < 20);
 }
 public float angleFinger(ARHand hand, int fingerWirst)
 {
     return(Vector3.Angle(hand.GetLandmark(fingerWirst + 1) - hand.GetLandmark(fingerWirst), hand.GetLandmark(fingerWirst + 3) - hand.GetLandmark(fingerWirst + 1)));
 }
 public float angleBig(ARHand hand)
 {
     return(Vector3.Angle(hand.GetLandmark(3) - hand.GetLandmark(2), hand.GetLandmark(4) - hand.GetLandmark(3)));
 }
 public float angleIndexWithHand(ARHand hand)
 {
     return(Vector3.Angle(hand.GetLandmark(5) - hand.GetLandmark(0), hand.GetLandmark(8) - hand.GetLandmark(5)));
 }