Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     if (BodySrcManager == null)
     {
         Debug.Log("Assign Game Object with Body Source Manager");
     }
     else
     {
         Debug.Log("Started!");
         bodyManager       = BodySrcManager.GetComponent <BodySourceManager>();
         this.kinectSensor = KinectSensor.GetDefault();
         coordinateMapper  = this.kinectSensor.CoordinateMapper;
         FEMCalibrator     = mappingSystem.GetComponent <FEMCalibrator>();
         if (bodyManager == null)
         {
             Debug.Log("bodyManager is null when start");
             return;
         }
     }
 }
Esempio n. 2
0
        public void FixedUpdate()
        {
            if (!initialize)
            {
                return;
            }
            else
            {
                if (dioManager.lookPointerInstanceBgiies.zoomActive)
                {
                    return;
                }
            }
            if (updateFrame < 1)
            {
                updateFrame++;
                return;
            }
            updateFrame = 0;
            // get bodies either from BodySourceManager object get them from a BodyReader
            var bodySourceManager = bodyManager.GetComponent <BodySourceManager>();

            bodies = bodySourceManager.GetData();
            if (bodies == null)
            {
                return;
            }


            // iterate through each body and update face source
            for (int i = 0; i < bodyCount; i++)
            {
                // check if a valid face is tracked in this face source
                if (faceFrameSources[i].IsTrackingIdValid)
                {
                    using (FaceFrame frame = faceFrameReaders[i].AcquireLatestFrame())
                    {
                        if (frame != null)
                        {
                            if (frame.TrackingId == 0)
                            {
                                continue;
                            }

                            // do something with result
                            var result = frame.FaceFrameResult;

                            // extract face rotation in degrees as Euler angles
                            if (result.FaceRotationQuaternion != null)
                            {
                                int pitch, yaw, roll;
                                ExtractFaceRotationInDegrees(result.FaceRotationQuaternion, out pitch, out yaw, out roll);

                                posRay   = new Vector3(yaw * multX, pitch * multY, 0.45f);
                                posWorld = Camera.main.WorldToScreenPoint(posRay);
                                ray      = Camera.main.ScreenPointToRay(posWorld);
                            }
                        }
                    }
                }
                else
                {
                    // check if the corresponding body is tracked
                    if (bodies[i].IsTracked)
                    {
                        // update the face frame source to track this body
                        faceFrameSources[i].TrackingId = bodies[i].TrackingId;
                    }
                }
            }
        }