1 Reply Latest reply on Jan 10, 2017 12:53 PM by Intel Corporation

    QueryGaze method always returns null?

    Michael_K

      Hello,

       

      I am currently writing an Unity application which should be extended with gazetracking. I downloaded the Unity toolkit and tried to get gaze data but the QueryGaze method always returns null. In the start method I enable gazetracking in the face configuration file, which should enable gazetracking, but QueryGaze still Returns null. Any idea why this is the case? I am using the Lenovo Ideadcentre AIO 700 with the F200 camera.

       

      Kind Regards

      Michael

       

      public class GazeTrackingTest : MonoBehaviour
      {
      
           private PXCMFaceConfiguration _faceConf;
           private PXCMFaceModule _faceMod;
           private PXCMFaceData _faceData;
           private PXCMFaceData.Face _faceDataFace;
           private PXCMFaceData.GazeData _faceDataGaze;
       
           // Use this for initialization
           void Start () 
           {
               SenseToolkitManager.Instance.SetSenseOption(SenseOption.SenseOptionID.Face);
               SenseToolkitManager.Instance.SenseManager.EnableFace();
               SenseToolkitManager.Instance.SenseManager.Init();
      
       
               
               _faceMod = SenseToolkitManager.Instance.SenseManager.QueryFace();
               _faceConf = _faceMod.CreateActiveConfiguration();
               _faceConf.detection.isEnabled = true;
       
               PXCMFaceConfiguration.GazeConfiguration _gazec = _faceConf.QueryGaze();
               _gazec.isEnabled = true;
               _faceConf.ApplyChanges();
           }
           
           // Update is called once per frame
           void Update () 
           {      
               _faceMod = SenseToolkitManager.Instance.SenseManager.QueryFace();
               if (_faceMod != null)
               {
                   _faceData = _faceMod.CreateOutput();
                   _faceData.Update();
       
                   int numberOfFaces = _faceData.QueryNumberOfDetectedFaces();
       
                   if (numberOfFaces > 0)
                   {
                       _faceDataFace = _faceData.QueryFaceByIndex(0);
       
                       if (_faceDataFace != null)
                       {
                           _faceDataGaze = _faceDataFace.QueryGaze();
       
                           if (_faceDataGaze != null)
                           {
                               Debug.Log(_faceDataGaze.QueryGazePoint().ToString());
                           }
                           else
                           {
                               Debug.Log("_faceDataGaze == null");
                           }
                       }
                       else
                       {
                           Debug.Log("_faceDataFace == null");
                       }
                   }
               }
           }
      }