Esempio n. 1
0
    void Start()
    {
//		print ("Start of pupil gaze tracker");

        Settings = PupilSettings.Instance;


        string str = PupilConversions.ReadStringFromFile("camera_intrinsics");

        PupilConversions.ReadCalibrationData(str, ref PupilData.CalibrationData);

        Settings.framePublishing.StreamCameraImages = false;
        if (Settings.framePublishing.StreamCameraImages)
        {
            Settings.framePublishing.InitializeFramePublishing();
        }

        if (PupilGazeTracker._Instance == null)
        {
            PupilGazeTracker._Instance = this;
        }

        PupilData.calculateMovingAverage = true;

        //make sure that if the toggles are on it functions as the toggle requires it
        if (isOperatorMonitor && OnOperatorMonitor == null)
        {
            OperatorMonitor.Instantiate();
        }
        //OnOperatorMonitor += DrawOperatorMonitor;
        if (Settings.debugView.active)
        {
            debugInstance.StartCalibrationDebugView();
        }

        PupilGazeTracker.Instance.ProjectName = Application.productName;

        Settings.connection.isConnected = false;
        Settings.DataProcessState       = PupilSettings.EStatus.Idle;

        var relativeRightEyePosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightEye) - UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye);

        Settings.calibration.rightEyeTranslation = new float[] { relativeRightEyePosition.z *PupilSettings.PupilUnitScalingFactor, 0, 0 };
        var relativeLeftEyePosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftEye) - UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye);

        Settings.calibration.leftEyeTranslation = new float[] { relativeLeftEyePosition.z *PupilSettings.PupilUnitScalingFactor, 0, 0 };

#if !UNITY_WSA
        if (Settings.connection.isAutorun)
        {
            RunConnect();
        }
#else
        RunConnect();
#endif
    }
Esempio n. 2
0
    void Start()
    {
        //		print ("Start of pupil gaze tracker");

        Settings = PupilTools.Settings;


        string str = PupilConversions.ReadStringFromFile("camera_intrinsics");

        PupilConversions.ReadCalibrationData(str, ref PupilData.CalibrationData);

        Settings.framePublishing.StreamCameraImages = false;
        if (Settings.framePublishing.StreamCameraImages)
        {
            Settings.framePublishing.InitializeFramePublishing();
        }

        if (PupilGazeTracker._Instance == null)
        {
            PupilGazeTracker._Instance = this;
        }

        PupilData.calculateMovingAverage = true;

        //make sure that if the toggles are on it functions as the toggle requires it
        if (isOperatorMonitor && OnOperatorMonitor == null)
        {
            OperatorMonitor.Instantiate();
        }
        //OnOperatorMonitor += DrawOperatorMonitor;
        if (Settings.debugView.active)
        {
            debugInstance.StartCalibrationDebugView();
        }

        PupilGazeTracker.Instance.ProjectName = Application.productName;

        Settings.connection.isConnected = false;
        Settings.dataProcess.state      = PupilSettings.EStatus.Idle;

        if (Settings.connection.isAutorun)
        {
            RunConnect();
        }
    }
Esempio n. 3
0
        void ClosePipe()
        {
            var camera = GetComponent <Camera>();

            // Destroy the blitter object.
            if (_tempBlitter != null)
            {
                Destroy(_tempBlitter);
                _tempBlitter = null;
            }

            // Release the temporary render target.
            if (_tempTarget != null && _tempTarget == camera.targetTexture)
            {
                camera.targetTexture = null;
                RenderTexture.ReleaseTemporary(_tempTarget);
                _tempTarget = null;
            }

            // Close the output stream.
            if (_pipe != null)
            {
                Debug.Log("Capture ended (" + _pipe.Filename + ")" + ". Rendered frame count on MainThread : " + renderedFrameCount + ". Written out frame count on SecondaryThread : " + writtenFrameCount + ". Leftover : " + renderPipeQueue.Count);

                // Write pupil timestamps to a file
                string timeStampFileName  = "Unity_" + PupilTools.Settings.currentCamera.name;
                byte[] timeStampByteArray = PupilConversions.doubleArrayToByteArray(timeStampList.ToArray());
                File.WriteAllBytes(_pipe.FilePath + "/" + timeStampFileName + ".time", timeStampByteArray);

                _pipe.Close();

                if (!string.IsNullOrEmpty(_pipe.Error))
                {
                    Debug.LogWarning(
                        "ffmpeg returned with a warning or an error message. " +
                        "See the following lines for details:\n" + _pipe.Error
                        );
                }

                _pipe = null;
            }
        }
Esempio n. 4
0
 public void UpdatePosition(Vector2 newPosition)
 {
     UpdatePosition(PupilConversions.Vector2ToFloatArray(newPosition));
 }