示例#1
0
        private void Update()
        {
            //if (SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.WORKING &&
            //    SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.NOT_SUPPORT) return;

            //if (SRanipal_Eye_Framework.Instance.EnableEyeDataCallback == true && eye_callback_registered == false)
            //{
            //    SRanipal_Eye.WrapperRegisterEyeDataCallback(Marshal.GetFunctionPointerForDelegate((SRanipal_Eye.CallbackBasic)EyeCallback));
            //    eye_callback_registered = true;
            //    test = 1;
            //}
            //else if (SRanipal_Eye_Framework.Instance.EnableEyeDataCallback == false && eye_callback_registered == true)
            //{
            //    SRanipal_Eye.WrapperUnRegisterEyeDataCallback(Marshal.GetFunctionPointerForDelegate((SRanipal_Eye.CallbackBasic)EyeCallback));
            //    eye_callback_registered = false;
            //    test = 2;
            //}
            //else
            //{
            //    SRanipal_Eye.WrapperUnRegisterEyeDataCallback(Marshal.GetFunctionPointerForDelegate((SRanipal_Eye.CallbackBasic)EyeCallback));
            //    test = 3;
            //}
            SRanipal_Eye_API.GetEyeData(ref eye_data);
            left_width  = eye_data.verbose_data.left.pupil_diameter_mm;
            right_width = eye_data.verbose_data.right.pupil_diameter_mm;
        }
        private void ApplyEyeTracking()
        {
            if (workable != true)
            {
                return;
            }
            EyeData EyeData_ = new EyeData();
            var     result   = SRanipal_Eye_API.GetEyeData(ref EyeData_);

            UpdateEye(EyeData_);
        }
示例#3
0
 private static bool UpdateData()
 {
     if (Time.frameCount == LastUpdateFrame)
     {
         return(LastUpdateResult == Error.WORK);
     }
     else
     {
         LastUpdateFrame = Time.frameCount;
     }
     LastUpdateResult = SRanipal_Eye_API.GetEyeData(ref EyeData_);
     return(LastUpdateResult == Error.WORK);
 }
    // Update is called once per frame
    void Update()
    {
        var error   = SRanipal_Eye_API.GetEyeData(ref EyeData);
        var newData = SRanipal_Eye.GetVerboseData(out EyeData.verbose_data);

        //No new data received from camera sensor - skip step
        if (!newData)
        {
            return;
        }

        //Show error only once and not every frame
        if (error != ViveSR.Error.WORK && lastError != error)
        {
            Debug.LogError("An error happened: " + error.ToString());
        }
        lastError = error;

        var leftEye  = EyeData.verbose_data.left.gaze_direction_normalized;
        var rightEye = EyeData.verbose_data.right.gaze_direction_normalized;

        // if (leftEye != Vector3.zero && rightEye != Vector3.zero)
        // Debug.Log("Eyes: LEFT:=" + leftEye + ", RIGHT:=" + rightEye);


        if (leftEye != Vector3.zero)
        {
            this.validTracking = true;
            CalculateWorldSpace(leftEye);
        }
        else if (rightEye != Vector3.zero)
        {
            this.validTracking = true;
            CalculateWorldSpace(rightEye);
        }
        else
        {
            this.validTracking = false;
        }
    }
示例#5
0
    void recordCsv()
    {
        List <String> data = new List <String>();

        data.Add(currentIndex.ToString());

        data.Add(currentColor);

        data.Add((startedTalking && !stoppedTalking).ToString());

        Action <Vector3> addVector3ToCsv = (Vector3 vector3) =>
        {
            data.Add(vector3.x.ToString());
            data.Add(vector3.y.ToString());
            data.Add(vector3.z.ToString());
        };

        Ray cameraRay = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));

        addVector3ToCsv(cameraRay.direction);

        Ray gazeRay = new Ray();

        SRanipal_Eye.GetGazeRay(GazeIndex.COMBINE, out gazeRay);
        addVector3ToCsv(gazeRay.direction);

        //EyeData eyeData = new EyeData();

        ViveSR.anipal.Eye.EyeData eyeData = new ViveSR.anipal.Eye.EyeData();
        SRanipal_Eye_API.GetEyeData(ref eyeData);

        data.Add(eyeData.verbose_data.left.pupil_diameter_mm.ToString());
        data.Add(eyeData.verbose_data.left.pupil_diameter_mm.ToString());

        data.Add(eyeData.verbose_data.left.eye_openness.ToString());
        data.Add(eyeData.verbose_data.right.eye_openness.ToString());

        csv.Row(data);
    }
示例#6
0
                private void Update()
                {
                    if (SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.WORKING &&
                        SRanipal_Eye_Framework.Status != SRanipal_Eye_Framework.FrameworkStatus.NOT_SUPPORT)
                    {
                        return;
                    }

                    if (NeededToGetData)
                    {
                        if (SRanipal_Eye_Framework.Instance.EnableEyeDataCallback == true && eye_callback_registered == false)
                        {
                            SRanipal_Eye.WrapperRegisterEyeDataCallback(Marshal.GetFunctionPointerForDelegate((SRanipal_Eye.CallbackBasic)EyeCallback));
                            eye_callback_registered = true;
                        }
                        else if (SRanipal_Eye_Framework.Instance.EnableEyeDataCallback == false && eye_callback_registered == true)
                        {
                            SRanipal_Eye.WrapperUnRegisterEyeDataCallback(Marshal.GetFunctionPointerForDelegate((SRanipal_Eye.CallbackBasic)EyeCallback));
                            eye_callback_registered = false;
                        }
                        else if (SRanipal_Eye_Framework.Instance.EnableEyeDataCallback == false)
                        {
                            SRanipal_Eye_API.GetEyeData(ref eyeData);
                        }

                        bool isLeftEyeActive  = false;
                        bool isRightEyeAcitve = false;
                        if (SRanipal_Eye_Framework.Status == SRanipal_Eye_Framework.FrameworkStatus.WORKING)
                        {
                            isLeftEyeActive  = eyeData.verbose_data.left.GetValidity(SingleEyeDataValidity.SINGLE_EYE_DATA_GAZE_ORIGIN_VALIDITY);
                            isRightEyeAcitve = eyeData.verbose_data.right.GetValidity(SingleEyeDataValidity.SINGLE_EYE_DATA_GAZE_ORIGIN_VALIDITY);
                        }
                        else if (SRanipal_Eye_Framework.Status == SRanipal_Eye_Framework.FrameworkStatus.NOT_SUPPORT)
                        {
                            isLeftEyeActive  = true;
                            isRightEyeAcitve = true;
                        }

                        if (isLeftEyeActive || isRightEyeAcitve)
                        {
                            if (eye_callback_registered == true)
                            {
                                SRanipal_Eye.GetEyeWeightings(out EyeWeightings, eyeData);
                            }
                            else
                            {
                                SRanipal_Eye.GetEyeWeightings(out EyeWeightings);
                            }
                            UpdateEyeShapes(EyeWeightings);
                        }
                        else
                        {
                            for (int i = 0; i < (int)EyeShape.Max; ++i)
                            {
                                bool isBlink = ((EyeShape)i == EyeShape.Eye_Left_Blink || (EyeShape)i == EyeShape.Eye_Right_Blink);
                                EyeWeightings[(EyeShape)i] = isBlink ? 1 : 0;
                            }

                            UpdateEyeShapes(EyeWeightings);

                            return;
                        }

                        Vector3 GazeOriginCombinedLocal, GazeDirectionCombinedLocal = Vector3.zero;
                        if (eye_callback_registered == true)
                        {
                            if (SRanipal_Eye.GetGazeRay(GazeIndex.COMBINE, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal, eyeData))
                            {
                            }
                            else if (SRanipal_Eye.GetGazeRay(GazeIndex.LEFT, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal, eyeData))
                            {
                            }
                            else if (SRanipal_Eye.GetGazeRay(GazeIndex.RIGHT, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal, eyeData))
                            {
                            }
                        }
                        else
                        {
                            if (SRanipal_Eye.GetGazeRay(GazeIndex.COMBINE, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal))
                            {
                            }
                            else if (SRanipal_Eye.GetGazeRay(GazeIndex.LEFT, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal))
                            {
                            }
                            else if (SRanipal_Eye.GetGazeRay(GazeIndex.RIGHT, out GazeOriginCombinedLocal, out GazeDirectionCombinedLocal))
                            {
                            }
                        }
                        UpdateGazeRay(GazeDirectionCombinedLocal);
                    }
                }
示例#7
0
        public StringBuilder StartTracking(String time, int frameCount, StringBuilder csvLogger)
        {
            // Get Eye data from TOBI API
            TobiiXR_EyeTrackingData localEyeData = TobiiXR.GetEyeTrackingData(TobiiXR_TrackingSpace.Local);
            TobiiXR_EyeTrackingData worldEyeData = TobiiXR.GetEyeTrackingData(TobiiXR_TrackingSpace.World);


            // Get Eye data from SRNipal
            ViveSR.Error error = SRanipal_Eye_API.GetEyeData(ref _eyeData);

            if (error == Error.WORK)
            {
                _sRanipalEyeVerboseData = _eyeData.verbose_data;

                // Left Eye Data
                SingleEyeData sRleftEyeData = _sRanipalEyeVerboseData.left;
                // Right Eye
                SingleEyeData sRrightEyeData = _sRanipalEyeVerboseData.right;

                // Write in the CSV file
                csvLogger.AppendFormat(
                    "{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}," +
                    "{19}, {20}, {21}, {22}, {23}, {24}, {25},{26}, {27}, {28}, {29}, {30}, {31}, {32}, {33}, {34}, {35}," +
                    "{36}, {37}, {38}, {39}",
                    // Time and Frame count
                    time, frameCount,

                    // Convergence Distance
                    worldEyeData.ConvergenceDistanceIsValid,
                    worldEyeData.ConvergenceDistance,

                    // Eye Openness
                    sRleftEyeData.eye_openness,
                    sRrightEyeData.eye_openness,

                    // Eye blinking
                    localEyeData.IsLeftEyeBlinking,
                    localEyeData.IsRightEyeBlinking,

                    // Pupil Diameter
                    sRleftEyeData.pupil_diameter_mm,
                    sRrightEyeData.pupil_diameter_mm,

                    // Pupil Position in Sensor area (x, y)
                    sRleftEyeData.pupil_position_in_sensor_area.x,
                    sRleftEyeData.pupil_position_in_sensor_area.y,
                    sRrightEyeData.pupil_position_in_sensor_area.x,
                    sRrightEyeData.pupil_position_in_sensor_area.y,

                    // IS local Gaze Valid
                    localEyeData.GazeRay.IsValid,

                    // Local Space Gaze Origin Combined
                    localEyeData.GazeRay.Origin.x,
                    localEyeData.GazeRay.Origin.y,
                    localEyeData.GazeRay.Origin.z,

                    // Local Space Gaze Direction Combined
                    localEyeData.GazeRay.Direction.x,
                    localEyeData.GazeRay.Direction.y,
                    localEyeData.GazeRay.Direction.z,

                    // IS World Gaze Valid
                    worldEyeData.GazeRay.IsValid,

                    //world space Gaze Origin Combined
                    worldEyeData.GazeRay.Origin.x,
                    worldEyeData.GazeRay.Origin.y,
                    worldEyeData.GazeRay.Origin.z,

                    // world space Gaze Direction Combined
                    worldEyeData.GazeRay.Direction.x,
                    worldEyeData.GazeRay.Direction.y,
                    worldEyeData.GazeRay.Direction.z,

                    // Gaze Origin in mm
                    sRleftEyeData.gaze_origin_mm.x,
                    sRleftEyeData.gaze_origin_mm.y,
                    sRleftEyeData.gaze_origin_mm.z,
                    sRrightEyeData.gaze_origin_mm.x,
                    sRrightEyeData.gaze_origin_mm.y,
                    sRrightEyeData.gaze_origin_mm.z,

                    // Normalized Gaze direction
                    sRleftEyeData.gaze_direction_normalized.x,
                    sRleftEyeData.gaze_direction_normalized.y,
                    sRleftEyeData.gaze_direction_normalized.z,
                    sRrightEyeData.gaze_direction_normalized.x,
                    sRrightEyeData.gaze_direction_normalized.y,
                    sRrightEyeData.gaze_direction_normalized.z
                    );

                csvLogger.AppendLine();
            }

            return(csvLogger);
        }
 private void Update()
 {
     SRanipal_Eye_API.GetEyeData(ref eye);
     eyeStatistic.Add(new EyeExportStatistic(eye));
 }