Example #1
0
 private static bool hasEyeTracking()
 {
     EyeTracking.Initialize();
     return
         (EyeTrackingHost.TobiiEngineAvailability.Equals(EngineAvailability.Running));
     //&& EyeTrackingHost.GetInstance().EyeTrackingDeviceStatus.Equals(DeviceStatus.Tracking);
 }
Example #2
0
    void getEyePos()
    {
        if (index < lr.numPositions - 1)
        {
            Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

            if (EyeTracking.GetGazePoint().IsValid)
            {
                Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));

                roundedSampleInput.x /= Camera.main.pixelWidth;
                roundedSampleInput.y /= Camera.main.pixelHeight;
                Debug.Log(roundedSampleInput);
                Vector3 newPos = new Vector3(roundedSampleInput.x, roundedSampleInput.y, 0f);

                positions [index] = newPos;
                index++;
                //Debug.Log (index);
            }
        }
        else if (index == lr.numPositions - 1)
        {
            lr.SetPositions(positions);
            index = lr.numPositions;
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        lr = GetComponent <LineRenderer> ();
        EyeTracking.Initialize();

        lr.numPositions = 500;
    }
Example #4
0
    private void NewGravity()
    {
        bool addForce = (Player.EYE_TRACKER && EyeTracking.GetGazePoint().IsValid) ||
                        (!Player.EYE_TRACKER && Input.GetMouseButton(0));

        if (addForce)
        {
            if (Player.EYE_TRACKER)
            {
                _newPosition = _camera.ScreenToWorldPoint(new Vector3(EyeTracking.GetGazePoint().Screen.x,
                                                                      EyeTracking.GetGazePoint().Screen.y, Z));
            }
            else
            {
                _newPosition = _camera.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Z));
            }
            if (icon)
            {
                AssignNewPosition();
                RenderIcon(true);
                ShowVortex(true, _camera.WorldToViewportPoint(_newPosition));
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (icon)
            {
                RenderIcon(false);
                ShowVortex(false, _offScreen);
            }
        }
    }
Example #5
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
        }
    }
Example #6
0
    private void AddingForce()
    {
        bool addForce = (EYE_TRACKER && EyeTracking.GetGazePoint().IsValid) ||
                        (!EYE_TRACKER && _gravityScript.ButtonClick);

        if (addForce)
        {
            _rigidbody.AddForce((_gravityScript.NewPosition - transform.position).normalized * _gravityScript.GetGravity);
            _rigidbody.AddTorque((_gravityScript.NewPosition - transform.position).magnitude / 100);
        }
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        gaze = EyeTracking.GetGazePoint();
        var v = gaze.Viewport * 10f;


        if (gaze.IsValid)
        {
            transform.position = new Vector3(v.x, v.y, 0f);
        }
    }
Example #8
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
            xCoord.text = "x (in px): " + roundedSampleInput.x;
            yCoord.text = "y (in px): " + roundedSampleInput.y;
        }
    }
Example #9
0
    void Update()
    {
        #region 判斷是否要開啟 Debug 的訊息
        if (Input.GetKeyDown(KeyCode.D))
        {
            IsDebugMode = !IsDebugMode;
        }
        #endregion
        #region 任務時間計算
        if (!counter.IsRecordBefore)
        {
            counter.TimeCounter += Time.deltaTime;
        }
        #endregion
        #region 眼動儀抓點
        if (!EyeTracking.GetGazePoint().IsValid)
        {
            return;
        }
        FinalPoint = ScreenToWorld(EyeTracking.GetGazePoint().Screen);
        if (IsUseFilter)
        {
            FinalPoint = DoubleExpFilter(FinalPoint);
        }

        recordData.Add(FinalPoint);
        #endregion
        #region 移動滑鼠 & 點擊判斷
        CursorAPI.SetCursorPosAPI(FinalPoint);

        // 判斷距離有沒有在設定的範圍內,有的話就加時間
        float dist = Vector3.Distance(HistoryPointTime0, FinalPoint);
        if (dist <= DiffDistance)
        {
            DiffCounter += Time.deltaTime;
        }
        else
        {
            DiffCounter = 0;
        }

        // 如果超過 DiffTime 代表傳送點擊事件
        if (DiffCounter >= DiffTime)
        {
            CursorAPI.CursorClickAPI();
            DiffCounter = 0;
        }


        // 最後要更新過去的點
        HistoryPointTime0 = FinalPoint;
        #endregion
    }
Example #10
0
    // Update is called once per frame
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            StoreGazePoint(gazePoint);

            _lastGazePoint = gazePoint;
        }
    }
Example #11
0
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));

            Vector3 newPos = Camera.main.WorldToViewportPoint(new Vector3(roundedSampleInput.x, roundedSampleInput.y, 0f) - new Vector3(Camera.main.pixelWidth / 2, Camera.main.pixelHeight / 2, 0f));

            transform.position = newPos;
        }
    }
    // Use this for initialization
    void Start()
    {
        _gazePointProvider = EyeTrackingHost.GetInstance().GetGazePointDataProvider();
        gazePointTracker   = GameObject.FindWithTag("gazepoint");
        gazeawareObject    = GameObject.FindWithTag("gazeaware");
        canvas             = GameObject.Find("Canvas");
        timer    = GameObject.Find("Timer").GetComponent <Text>();
        myCamera = GameObject.FindWithTag("MainCamera").GetComponent <Camera>();
        EyeTracking.SetCurrentUserViewPointCamera(myCamera);
        logger.contWrite = false;

        Debug.Log("Gaze aware object " + gazeawareObject.name);
    }
Example #13
0
    /// <summary>
    /// Print the Gaze Tracking status
    /// </summary>
    private void UpdateGazeTrackingView()
    {
        var gazeTracking = EyeTracking.GetGazeTrackingStatus().Status;

        TextViewGazeTracking.text = gazeTracking.ToString();

        if (EyeTracking.GetGazeTrackingStatus().IsTrackingEyeGaze)
        {
            TextViewIsGazeTracked.text = "Yes";
        }
        else
        {
            TextViewIsGazeTracked.text = "No";
        }
    }
Example #14
0
    void Start()
    {
        EyeTracking.Initialize();

        // 設定 Debug 的 Style
        style.normal.textColor = Color.white;
        style.fontSize         = 50;

        StartCoroutine(FPSCounter());

        #region 抓 Mission Time Counter
        GameObject MissionTime = GameObject.FindGameObjectWithTag("Mission Time Tracker");
        counter = MissionTime.GetComponent <MissionTimeCounter>();
        #endregion
    }
Example #15
0
    /// <summary>
    /// Print the User Presence status
    /// </summary>
    private void UpdateUserPresenceView()
    {
        var userPresence = EyeTracking.GetUserPresence().Status;

        TextViewUserPresenceStatus.text = userPresence.ToString();

        if (EyeTracking.GetUserPresence().IsUserPresent)
        {
            TextViewIsUserPresent.text = "Yes";
        }
        else
        {
            TextViewIsUserPresent.text = "No";
        }
    }
Example #16
0
        private static void WriteEyeCSV()
        {
            EyeTracking eyeTracking = GameObject.Find("Fitts").GetComponent <EyeTracking>();

            foreach (EyeTracking.EyeExportStatistic data in eyeTracking.eyeStatistic)
            {
                sbEye.AppendLine(data.timestamp + delimiter
                                 + data.leftEye.pupil_diameter_mm + delimiter
                                 + data.rightEye.pupil_diameter_mm + delimiter
                                 + data.combinedEye.eye_data.pupil_diameter_mm + delimiter
                                 + data.leftEye.gaze_origin_mm.x + ":" + data.leftEye.gaze_origin_mm.y + ":" + data.leftEye.gaze_origin_mm.z + ":" + delimiter
                                 + data.rightEye.gaze_origin_mm.x + ":" + data.rightEye.gaze_origin_mm.y + ":" + data.rightEye.gaze_origin_mm.z + ":" + delimiter
                                 + data.combinedEye.eye_data.gaze_origin_mm.x + ":" + data.combinedEye.eye_data.gaze_origin_mm.y + ":" + data.combinedEye.eye_data.gaze_origin_mm.z + ":" + delimiter
                                 + data.combinedEye.convergence_distance_mm + delimiter
                                 + data.combinedEye.convergence_distance_validity);
            }
        }
    void Update()
    {
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
            xCoord.text = "x (in px): " + roundedSampleInput.x;
            yCoord.text = "y (in px): " + roundedSampleInput.y;

            Dictionary <string, string> data = new Dictionary <string, string>();
            data["x"] = roundedSampleInput.x.ToString();
            data["y"] = roundedSampleInput.y.ToString();

            socket.Emit("coors", new JSONObject(data));
            //Debug.Log(roundedSampleInput.x + ", " + roundedSampleInput.y);
        }
    }
    //Check every frame if object is looked at (or pointed at)
    void Update()
    {
        //Using Gaze coordinates from Eyetracker
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            _ray = Camera.main.ScreenPointToRay(gazePosition);
            CastRay(_ray);
            //Mouse input
        }
        else if (mouseInput)
        {
            _ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            CastRay(_ray);
        }
    }
Example #19
0
    // Update is called once per frame
    void Update()
    {
        GazePoint gp = EyeTracking.GetGazePoint();

        if (!gp.IsWithinScreenBounds)
        {
            return;
        }
        //print(gp.Screen.x + "+" + gp.Screen.y);

        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(gp.Screen.x, gp.Screen.y, 0));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, float.MaxValue, lmask))
        {
            //print("I'm looking at " + hit.transform.name);
            transform.position = hit.point;
        }
        //print("I'm looking at nothing!");
    }
Example #20
0
    // Update is called once per frame
    void WriteLineToFile()
    {
        using (StreamWriter sw = new StreamWriter(fileName, true))
        {
            //Only log if eyetracker active, meaning screen values are not NaN
            Vector2 gazePoint = EyeTracking.GetGazePoint().Screen;

            if (EyeTracking.GetGazePoint().IsValid)  // Do not log NaN values TODO does that also remove negative values?
            {
                //Debug.Log("New line to text" + " " + gazePoint.x);
                Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePoint.x), Mathf.RoundToInt(gazePoint.y));
                string  time = DateTime.Now.ToString("HH_mm_ss__fff-dd-MM-yyyy");
                // Add line to file
                sw.WriteLine(time + "," + roundedSampleInput.x + "," + roundedSampleInput.y);
            }
            else
            {
                //Debug.Log("Eyetracker inactive");
            }
        }
    }
Example #21
0
    void Update()
    {
        //Checks when eye tracker is available. Translates controls depending on setting.
        if (GetValidEyeTracking)
        {
            transform.position = Vector3.Lerp(transform.position, mainCamera.ScreenToWorldPoint(
                                                  new Vector3(EyeTracking.GetGazePoint().Screen.x, EyeTracking.GetGazePoint().Screen.y, transform.position.z)),
                                              _eyeSpeed * Time.deltaTime);
        }
        else
        {
            transform.position = mainCamera.ScreenToWorldPoint(
                new Vector3(Input.mousePosition.x, Input.mousePosition.y, transform.position.z));
        }

        //Displays icon when eye tracker is available.
        if (eyecon.enabled != GetValidEyeTracking)
        {
            eyecon.enabled = GetValidEyeTracking;
        }
    }
Example #22
0
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            if (UseFilter)
            {
                UpdateGazeBubblePosition(gazePoint);
            }
            else
            {
                UpdateGazePointCloud(gazePoint);
            }

            _lastGazePoint = gazePoint;
        }

        UpdateGazePointCloudVisibility();
        UpdateGazeBubbleVisibility();
    }
Example #23
0
    //Check every frame if object is looked at (or pointed at)
    void Update()
    {
        //Using Gaze coordinates from Eyetracker
        Vector2 gazePosition = EyeTracking.GetGazePoint().Screen;

        if (EyeTracking.GetGazePoint().IsValid)
        {
            //Vector2 roundedSampleInput = new Vector2(Mathf.RoundToInt(gazePosition.x), Mathf.RoundToInt(gazePosition.y));
            //Debug.Log(roundedSampleInput);
            //Debug.Log(Input.mousePosition.ToString());

            _ray = Camera.main.ScreenPointToRay(gazePosition);

            CastRay(_ray);
            //Mouse input
        }
        else if (mouseInput)
        {
            _ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            CastRay(_ray);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (ended)
     {
         return;
     }
     if (isMouseInput)
     {
         readMouseInput();
     }
     else
     {
         GazePoint gazePoint = EyeTracking.GetGazePoint();
         if (gazePoint.SequentialId > lastGazePoint.SequentialId && gazePoint.IsWithinScreenBounds)
         {
             GameObject focusedObject    = EyeTracking.GetFocusedObject();
             Vector3    gazePointInWorld = getPositionInWorld(gazePoint.Screen);
             Vector3    normalized       = gazePointInWorld;
             if (focusedObject != null)
             {
                 normalized = normalize(gazePointInWorld, this.lastGazePointLoc);
                 gazeawareFocused(normalized, focusedObject);
                 this.lastGazePointLoc = normalized;
             }
             else
             {
                 fall();
             }
             updateTrackerPosition(normalized);
             this.lastGazePoint = gazePoint;
         }
     }
     if (this.started)
     {
         updateTimer();
     }
 }
Example #25
0
    void Update()
    {
        GazePoint gazePoint = EyeTracking.GetGazePoint();

        if (gazePoint.SequentialId > _lastGazePoint.SequentialId &&
            gazePoint.IsWithinScreenBounds)
        {
            if (UseFilter)
            {
                UpdateGazeBubblePosition(gazePoint);
            }
            else
            {
                //This is the row equivalent where we store in file in the GazeplotTofile. THis means that the output from that file should be
                //sent to the UpdateGazePointCloud method equivalent.
                UpdateGazePointCloud(gazePoint);
            }

            _lastGazePoint = gazePoint;
        }

        UpdateGazePointCloudVisibility();
        UpdateGazeBubbleVisibility();
    }
Example #26
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        var dstatus = "status:\n";

        dstatus += DemoController.step.ToString() + "\n";
        gaze     = EyeTracking.GetGazePoint();
        var presence = EyeTracking.GetUserPresence();

        if (presence.IsUserPresent)
        {
            dstatus += "user present\n";
        }
        else
        {
            dstatus += "user absent\n";
        }

        //get the target if valid
        if (gaze.IsValid)
        {
            dstatus += "gaze VALID\n";
            dstatus += "x: " + gaze.Screen.x.ToString() + " y: " + gaze.Screen.y.ToString() + "\n";
            Ray ray = cam.ScreenPointToRay(new Vector3(gaze.Screen.x, gaze.Screen.y, 0f));

            Debug.DrawRay(ray.origin, ray.direction * 5f, Color.red, 1f);

            if (Physics.Raycast(ray, out hit, 10f, lmask))
            {
                target = hit.point;
            }
        }
        else
        {
            dstatus += "gaze INVALID\n";
        }

        //smoothed move
        var smoothedPosition = cube.transform.position;

        smoothedPosition       += (target - smoothedPosition) * Time.deltaTime * smoothing;
        cube.transform.position = smoothedPosition;

        //smoothing options
        if (Input.GetKeyDown(KeyCode.UpArrow) && smoothing < 10f)
        {
            smoothing += 0.5f;
        }
        if (Input.GetKeyDown(KeyCode.DownArrow) && smoothing > 1f)
        {
            smoothing -= 0.5f;
        }


        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            cup.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            landingZone.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            audiance.transform.position = cube.transform.position;
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            ArduinoSend.WriteToArduino("n");
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            DemoController.setStep(DemoController.demoSteps.calibration);
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            DemoController.setStep(DemoController.demoSteps.pickup);
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            DemoController.setStep(DemoController.demoSteps.place);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            DemoController.setStep(DemoController.demoSteps.audience);
        }


        dstatus += "smoothing: " + smoothing.ToString() + "\n";


        dstatus += "cubeX: " + cube.transform.position.x.ToString() + "\n";
        dstatus += "cubeX scaled: " + ((int)((cube.transform.position.x + 3) * 30)).ToString() + "\n";

        dtext.text = dstatus;
    }
Example #27
0
 private void Update()
 {
     DispatchPositionEvent(positionInput, EyeTracking.GetGazePoint().Screen);
     SpaceInput();
 }