Jump to content
 

jason_lu

Verified Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

1 Neutral

About jason_lu

  • Rank
    Contributor

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi assimkz: In SRanipal SDK, these function are pass variable by reference. The boolean return value can verify if the data is valid. You can get data with belows blueprint sample. Best Regards Jason
  2. Hi kadakadakScott: You can follow these step to get 120 frame data per second. - Create an empty scene and add SRanipal_Framework into the scene. (The framework GameObject will be in Prefab folder) - Create an empty GameObject and attach below two script on it. - Start the scene preview then you can check the EyeData's frame sequence and timestamp in DataRecord.txt Notice, If you use this method to get EyeData or VerboseData, you should not use other function in SRanipal_Eye simultaneously since the function in SRanipal_Eye are implement within Unity's main thread. Best Regards Jason // Sample_MainThread.csusing System.Collections;using System.Collections.Generic;using UnityEngine;using ViveSR.anipal.Eye;namespace Test120FPS{ public class Sample_MainThread : MonoBehaviour { private Sample_GetDataThread DataThread = null; private EyeData data = new EyeData(); // Use this for initialization void Start() { DataThread = FindObjectOfType<Sample_GetDataThread>(); if (DataThread == null) return; } // You can get data from another thread and use MonoBehaviour's method here. // But in Unity's Update function, you can only have 90 FPS. void Update() { data = DataThread.data; Debug.Log("Left eye openness: " + data.verbose_data.left.eye_openness); Debug.Log("Right eye openness: " + data.verbose_data.right.eye_openness); } }} // Sample_GetDataThread.csusing System.Collections;using System.Collections.Generic;using UnityEngine;using System;using System.Threading;using System.IO;using ViveSR.anipal.Eye;namespace Test120FPS{ public class Sample_GetDataThread : MonoBehaviour { public EyeData data = new EyeData(); private Thread thread; private const int FrequencyControl = 1; private const int MaxFrameCount = 3600; void Start() { thread = new Thread(QueryEyeData); thread.Start(); } private void OnApplicationQuit() { thread.Abort(); } private void OnDisable() { thread.Abort(); } // You can only use C# native function in Unity's thread. // Use EyeData's frame_sequence to calculate frame numbers and record data in file. void QueryEyeData() { int FrameCount = 0; int PrevFrameSequence = 0, CurrFrameSequence = 0; bool StartRecord = false; while (FrameCount < MaxFrameCount) { ViveSR.Error error = SRanipal_Eye.GetEyeData(ref data); if (error == ViveSR.Error.WORK) { CurrFrameSequence = data.frame_sequence; if (CurrFrameSequence != PrevFrameSequence) { FrameCount ++; PrevFrameSequence = CurrFrameSequence; StartRecord = true; } } // Record time stamp every 120 frame. if (FrameCount % 120 == 0 && StartRecord) { long ms = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; string text = "CurrentFrameSequence: " + CurrFrameSequence + " CurrentSystemTime(ms): " + ms.ToString() + Environment.NewLine; File.AppendAllText("DataRecord.txt", text); FrameCount = 0; } Thread.Sleep(FrequencyControl); } } }}
×
×
  • Create New...