2 Replies Latest reply on Feb 24, 2017 12:25 PM by Intel Corporation

    Gaze Tracking - NULL Exception

    Dntfreitas

      I am trying to do a Gaze Tracking (C# and Unity) and, has mention in the documentation, the first step is to make a calibration.

       

      The above code is what I tried to do for the calibration:

        void Start ()
           {
       
               sm = PXCMSenseManager.CreateInstance ();
       
               if (sm == null) {
       
                   Debug.LogError ("SenseManager Initialization Failed");
       
                   return;
       
               }
       
               sm.EnableFace ();
       
             
       
               if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR)
                   Debug.LogError ("PXCSenseManager.EnableHand: " + sts);
       
               faceAnalyzer = sm.QueryFace();
       
               if (faceAnalyzer == null) {
       
                   Debug.LogError ("PXCSenseManager.QueryFace");
       
               }
       
               // Initialize the execution pipeline */
               sts = sm.Init ();
       
               if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR) {
                   Debug.LogError ("PXCMSenseManager.Init Failed");
       
                   OnDisable ();
       
                   return;
       
               }
       
               //Retrieve a PXCMFaceConfiguration instance from a face to enable Gestures and Alerts */
               PXCMFaceConfiguration config = faceAnalyzer.CreateActiveConfiguration ();
       
               PXCMFaceConfiguration.GazeConfiguration gazec = config.QueryGaze();
       
               config.detection.isEnabled = true;
       
               gazec.isEnabled = true;
       
               config.ApplyChanges ();
       
           }
      

       

        void Update ()
           {
       
               // Make sure PXCMSenseManager Instance is Initialized 
               if (sm == null) {
       
                   return;
       
               }
       
               // Wait until any frame data is available true(aligned) false(unaligned) 
               if (sm.AcquireFrame (true) != pxcmStatus.PXCM_STATUS_NO_ERROR) {
       
                   return;
       
               }
       
               faceAnalyzer = sm.QueryFace();
       
               while (sm.AcquireFrame (true).IsSuccessful ()) {
       
                   if (faceAnalyzer != null) {
                       
                       // faced is the GazeCalibData instance
                       PXCMPointI32 calibp;
       
                       PXCMFaceData.GazeCalibData.CalibrationState state = faced.QueryCalibrationState();
       
                       switch (state) {
       
                           case PXCMFaceData.GazeCalibData.CalibrationState.CALIBRATION_IDLE:
                               Debug.Log("Calibration started!");
                               
                               break;
                           case PXCMFaceData.GazeCalibData.CalibrationState.CALIBRATION_NEW_POINT:
                               Debug.Log("New calibration point!");
       
                               calibp = faced.QueryCalibPoint ();
                               
                               break;
                           case PXCMFaceData.GazeCalibData.CalibrationState.CALIBRATION_SAME_POINT:
                               Debug.Log("Keep looking!");
       
                               break;
                           case PXCMFaceData.GazeCalibData.CalibrationState.CALIBRATION_DONE:
                               Debug.Log("Calibration done!");
       
                               // Save the calibration data.
       
                               break;
                           }
                           
                   }
       
                   // Resume next frame processing
                   sm.ReleaseFrame ();
               }
       
           }
      

       

      The NULL exception happens on line 27 of the function Update(). Can you detect why?

        • 1. Re: Gaze Tracking - NULL Exception
          MartyG

          Looking at other samples that have used these instructions, the first thing I would try is changing the Start()'s line 21 from:

           

          faceAnalyzer = sm.QueryFace();

           

          to

           

          faceAnalyzer = sm>QueryFace();

           

          QueryFace() instructions tend to involve 'sum' signs such as +, - and >, so this made me wonder if with your quoted script, the writer meant to type a > symbol and didn't do the shift-key, getting a full stop instead 

          • 2. Re: Gaze Tracking - NULL Exception
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello Dntfreitas,
             
            Do you have any updates about this? Did MartyG's suggestion helped? Or, are you still having issues?
            Please let us know, we'll try to help you in any way we can.
             
            Pedro M.