示例#1
0
        /// <summary>
        /// Extracts the tracker data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public GazeData ExtractTrackerData(EyeTrackingController.SampleStruct data)
        {
            GazeData result = new GazeData();

            float gazePosXLeft  = Convert.ToSingle(data.leftEye.gazeX);
            float gazePosXRight = Convert.ToSingle(data.rightEye.gazeX);
            float gazePosYLeft  = Convert.ToSingle(data.leftEye.gazeY);
            float gazePosYRight = Convert.ToSingle(data.rightEye.gazeY);

            result.GazePosX = (gazePosXLeft + gazePosXRight) / 2;
            result.GazePosY = (gazePosYLeft + gazePosYRight) / 2;

            if (result.GazePosX > 1000 * 10)
            {
                result.GazePosX = result.GazePosX / 1000;
            }
            if (result.GazePosY > 1000 * 10)
            {
                result.GazePosY = result.GazePosY / 1000;
            }

            long MICROSECONDS = 1000;

            result.Time   = (data.timestamp / MICROSECONDS);
            this.lastTime = result.Time;

            result.PupilDiaX = Convert.ToSingle(data.leftEye.diam);
            result.PupilDiaY = Convert.ToSingle(data.rightEye.diam);

            return(result);
        }
示例#2
0
        public void GazeDataThreadProc()
        {
            while (!_terminating)
            {
                EyeTrackingController.SampleStruct sampleData = new EyeTrackingController.SampleStruct();
                if (_eyeTracker.iV_GetSample(ref sampleData) != (int)EyeTrackingController.RetCode.Success)
                {
                    Thread.Sleep(_sleepTime);
                    continue;
                }

                EventHandler <GazeEventArgs> handler = GazeEvent;
                if (handler != null)
                {
                    GazeEventArgs gazeEventArgs = new GazeEventArgs(sampleData.leftEye.gazeX,
                                                                    sampleData.leftEye.gazeY,
                                                                    sampleData.timestamp / 1000,
                                                                    Fixation.Unknown,
                                                                    false);
                    handler(this, gazeEventArgs);
                }

                Thread.Sleep(_sleepTime);
            }
        }
示例#3
0
        public void testExtractTrackerDataRightEyeZero()
        {
            EyeTrackingController.SampleStruct testdata = getTestdata();
            testdata.leftEye.gazeX  = 10;
            testdata.leftEye.gazeY  = 10;
            testdata.rightEye.gazeX = 0;
            testdata.rightEye.gazeY = 0;

            GazeData gazeData = cut.ExtractTrackerData(testdata);

            Assert.IsNotNull(gazeData);
            assertEqualDecimal(5f, gazeData.GazePosX);
            assertEqualDecimal(5f, gazeData.GazePosY);
        }
示例#4
0
        public void testExtractTrackerDataWithZeroValues()
        {
            EyeTrackingController.SampleStruct testdata = getTestdata();
            testdata.rightEye.gazeX = 0;
            testdata.rightEye.gazeY = 0;
            testdata.leftEye.gazeX  = 0;
            testdata.leftEye.gazeY  = 0;

            GazeData gazeData = cut.ExtractTrackerData(testdata);

            Assert.IsNotNull(gazeData);

            Assert.AreEqual(0, gazeData.GazePosX);
            Assert.AreEqual(0, gazeData.GazePosY);
        }
示例#5
0
        /// <summary>
        /// Gets the sample callback function.
        /// </summary>
        /// <param name="sampleData">The sample data.</param>
        void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData)
        {
            string data = ("Data from SampleCallback - timestamp: " + sampleData.timestamp.ToString() +
                           " - GazeRX: " + sampleData.rightEye.gazeX.ToString() +
                           " - GazeRY: " + sampleData.rightEye.gazeY.ToString() +
                           " - GazeLX: " + sampleData.leftEye.gazeX.ToString() +
                           " - GazeLY: " + sampleData.leftEye.gazeY.ToString() +
                           " - DiamRX: " + sampleData.rightEye.diam.ToString() +
                           " - DiamLX: " + sampleData.leftEye.diam.ToString() +
                           " - DistanceR: " + sampleData.rightEye.eyePositionZ.ToString() +
                           " - DistanceL: " + sampleData.leftEye.eyePositionZ.ToString());

            //log("GetSampleCallbackFunction: " + data);
            if (listener != null)
            {
                listener.onSampleData(sampleData);
            }
        }
示例#6
0
        /// <summary>
        /// Ons the sample data.
        /// </summary>
        /// <param name="data">The data.</param>
        public void onSampleData(EyeTrackingController.SampleStruct data)
        {
            lock (LOCK)
            {
                if (!IsTracking)
                {
                    return;
                }
                if (this.GazeDataChanged == null)
                {
                    return;
                }
                GazeData gazeData = ExtractTrackerData(data);

                GazeDataChangedEventArgs eventArgs = new GazeDataChangedEventArgs(gazeData);

                this.OnGazeDataChanged(eventArgs);
            }
        }
示例#7
0
        protected EyeTrackingController.SampleStruct getTestdata()
        {
            EyeTrackingController.SampleStruct testdata = new EyeTrackingController.SampleStruct();
            testdata.leftEye.diam         = 10;
            testdata.leftEye.eyePositionX = 2;
            testdata.leftEye.eyePositionY = 3;
            testdata.leftEye.eyePositionZ = 4;

            testdata.rightEye.diam         = 10;
            testdata.rightEye.eyePositionX = 8;
            testdata.rightEye.eyePositionY = 9;
            testdata.rightEye.eyePositionZ = 10;

            testdata.leftEye.gazeX  = 10;
            testdata.leftEye.gazeY  = 10;
            testdata.rightEye.gazeX = 20;
            testdata.rightEye.gazeY = 10;

            testdata.planeNumber = 13;
            testdata.timestamp   = 12340000;
            return(testdata);
        }