Jump to content

alwyuyang

Verified Members
  • Posts

    38
  • Joined

  • Last visited

Posts posted by alwyuyang

  1. Here is part of the source code in SRanipal_EyeData.cs, but regarding the VerboseData, I don't understand what is the "CombinedEyeData" because it also contains a "SingleEyeData" . 

                public struct VerboseData
                {
                    /** A instance of the struct as @ref EyeData related to the left eye*/
                    public SingleEyeData left;
                    /** A instance of the struct as @ref EyeData related to the right eye*/
                    public SingleEyeData right;
                    /** A instance of the struct as @ref EyeData related to the combined eye*/
                    public CombinedEyeData combined;
                    public TrackingImprovements tracking_improvements;
                }

     

     

                public struct CombinedEyeData
                {
                    public SingleEyeData eye_data;
                    public bool convergence_distance_validity;
                    public float convergence_distance_mm;
                }

    As we have already obtained the single eye data of the left and right eyes, what is the  "SingleEyeData eye_data" inside the CombinedEyeData? Is it an average of the left and right eye data, seems confusing? 

    Thank you in advance and sorry for the annoying questions. 

    @imarin18 @Daniel_Y @Corvus   

     

     

     

     

  2.        public struct SingleEyeData
                {
                    /** The bits containing all validity for this frame.*/
                    public System.UInt64 eye_data_validata_bit_mask;
                    /** The point in the eye from which the gaze ray originates in meter miles.(right-handed coordinate system)*/
                    public Vector3 gaze_origin_mm;
                    /** The normalized gaze direction of the eye in [0,1].(right-handed coordinate system)*/
                    public Vector3 gaze_direction_normalized;
                    /** The diameter of the pupil in meter miles*/
                    public float pupil_diameter_mm;
                    /** A value representing how open the eye is.*/
                    public float eye_openness;
                    /** The normalized position of a pupil in [0,1]*/
                    public Vector2 pupil_position_in_sensor_area;
    
                    public bool GetValidity(SingleEyeDataValidity validity)
                    {
                        return (eye_data_validata_bit_mask & (ulong)(1 << (int)validity)) > 0;
                    }
                }

    Here is the source code of the SingleEyeData, but I don't know how to run GetValidity(SingleEyeDataVadity validity). What is the input variable validity?  I can easily access to the property of SingleEyeData through: eye.data.gaze_origin_mm, but when it comes to GetValidity, I don't know which is the input. Could you please do me a favor?

    @imarin18 @Daniel_Y@kbombeke

    Thank you in advance. 

  3. Hello, 

    I am using the attached scripts to log my eye data with vive pro; however when the user is detected, I didn't get updated eye data for each timestamp. Anyone knows the reason?

    The scripts were attached to the same game object. 

    From left to right( a detail explanation was given in the code) : Time.time, unixTime, unity3d frame count , timestamp, frame_sequence, no_user, verbose_data.right.pupil_diameter_mm,..

    4,463005. 1581521362,642. 0. 2034174. 5856. True. 4,223083. 0,05946324. 34,59949. 1,743484. -41,28214. -0,01016235. -0,3304138. 0,9437714. 0,420842. 0,7114134 
    4,463005. 1581521362,847. 1. 2034174. 5856. True. 4,223083. 0,05946324. 34,59949. 1,743484. -41,28214. -0,01016235. -0,3304138. 0,9437714. 0,420842. 0,7114134 
    4,483005. 1581521362,86. 2. 2034174. 5856. True. 4,223083. 0,05946324. 34,59949. 1,743484. -41,28214. -0,01016235. -0,3304138. 0,9437714. 0,420842. 0,7114134 
    4,494838. 1581521362,866. 3. 2034174. 5856. True. 4,223083. 0,05946324. 34,59949. 1,743484. -41,28214. -0,01016235. -0,3304138. 0,9437714. 0,420842. 0,7114134 
    4,504498. 1581521362,876. 4. 2034174. 5856. True. 4,223083. 0,05946324. 34,59949. 1,743484. -41,28214. -0,01016235. -0,3304138. 0,9437714. 0,420842. 0,7114134 

    where the data of yellow fonts comes from unity3d internal functions while the  red fonts come from the vive pro eye API. You can see that Vive eye keeps the same out during the loop. Why?

    I attach also the output of  eye data. Thank you in advance if you could give me a hand. 

    Best regards,

    Sample_MainThread.cs Sample_GetDataThread.cs leftEyeData.txt outFromThread.txt rightEyeData.txt combinedEyeData.txt

  4. On 2/12/2020 at 3:53 AM, Corvus said:

    I tried with that code, but I cannot close my application when it should be closed( like crash) . Do you have any updated version which can overcome this problem? Thank you very much. 

     

    @Corvus

  5. On 6/19/2019 at 3:25 PM, jason_lu said:

     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);            }        }    }}

     

     

    I used this code, but I cannot close my application when it should be closed. Could you please give me a hand?

     

    @Daniel_Y @VIVE_Jason_Lu

  6. On 7/15/2019 at 6:45 PM, Corvus said:

    Here's some sample code to help you get started in Unity.

     

    
    private static EyeData eyeData;private static VerboseData verboseData;private float pupilDiameterLeft, pupilDiameterRight;private Vector2 pupilPositionLeft, pupilPositionRight;private float eyeOpenLeft, eyeOpenRight;void Update(){    SRanipal_Eye.GetEyeData(ref eyeData);    SRanipal_Eye.GetVerboseData(out verboseData);    // pupil diameter    pupilDiameterLeft = eyeData.verbose_data.left.pupil_diameter_mm;    pupilDiameterRight = eyeData.verbose_data.right.pupil_diameter_mm;    // pupil positions    pupilPositionLeft = eyeData.verbose_data.left.pupil_position_in_sensor_area;    pupilPositionRight = eyeData.verbose_data.right.pupil_position_in_sensor_area;    // eye open    eyeOpenLeft = eyeData.verbose_data.left.eye_openness;    eyeOpenRight = eyeData.verbose_data.right.eye_openness;}

    Why don't you create a subthread to read and send the data so that to have the data with 120 Hz? 

    Did you try that (I fail to do that because I don't know how to manage the thread in Unity3d). Thank you if you have any ideas. 

     

  7. I build my application for VIVE eye pro, however I see nothing from the HMD monitor and everything is displayed on PC screen. I try to oscillate the HMD to check if it is in tracking, and I found that the movement of the HMD  doesn't affect what was displayed on PC screen. The HMD display shows light and there is no bug reported by SteamVR and Wireless connection.

     

    In addition, I cannot see VR Home  scene which is supposed to be launched by SteamVR. Anybody can solve the problem?

     

    Best regards,

     

    @VibrantNebula

  8. 15 hours ago, mrk88 said:

    ViveProEyeProducerThread.cs 2.09 kB · 1 download

     

    Thanks. I attach this script to a GameObject in my scene. 

    I am not able to collect any verbose data while using a thread. The verbose data I can only collect in Update function. and that is where I'm confused. If we can only collect verbose data in Update(), then we will be collecting them with 90Hz frequency not 120.

    Thanks for sharing the script which is the same to mine. Actually I have the same problem. I think we are looking for an equivalent "Update() function of Vive Eye" which can run automatically in 120 Hz, right? This is the problem we have no idea. 

     

     

    @Daniel_Y @zzy @Corvus

  9. On 10/8/2019 at 11:23 PM, ScottHerz said:

    FWIW, here's what I ended up doing (to avoid aborting the thread and the reach-in for EyeData on who-knows-what-thread).

    
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System;
    using System.Threading;
    using System.IO;
    using ViveSR.anipal.Eye;
    
    public class ViveProEyeProducerThread : MonoBehaviour
    {
        public Action<EyeData> NewOffThreadEyeDataAction;
    
        private EyeData EyeData = new EyeData();
        private Thread Thread;
        private const int FrequencyControl = 1;
        private bool Abort = false;
    
        void Start()
        {
            Abort = false;
            Thread = new Thread(QueryEyeData);
            Thread.Start();
        }
    
        private void OnApplicationQuit()
        {
            Abort = true;
        }
    
        private void OnDisable()
        {
            Abort = true;
        }
    
        void QueryEyeData()
        {
            int PrevFrameSequence = 0, CurrFrameSequence = 0;
    
            while (Abort == false) {
                ViveSR.Error error = SRanipal_Eye.GetEyeData(ref EyeData);
                if (error == ViveSR.Error.WORK) {
                    CurrFrameSequence = EyeData.frame_sequence;
                    if (CurrFrameSequence != PrevFrameSequence) {
                        PrevFrameSequence = CurrFrameSequence;
    
                        if (Abort == false && NewOffThreadEyeDataAction != null) {
                            NewOffThreadEyeDataAction(EyeData);
                        }
                    }
                }
                Thread.Sleep(FrequencyControl);
            }
        }
    }

     

    Is this the alternative "Sample_GetDataThread.cs", could you please add the "Sample_MainThread.cs".  I don't understand " public Action<EyeData> NewOffThreadEyeDataAction;  private EyeData EyeData = new EyeData();  ", which are different to the version before. Could you explain a little bit, thank you very much.

×
×
  • Create New...