Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        // Create a new instance of dictionaries we'll use
        labelDictionary   = new Dictionary <Color, List <string> >();
        eyeTrackingLogger = new EyeTrackingLogger();

        // Initialize variables
        CreateNewScene("Scene_000");
    }
Exemplo n.º 2
0
    // Initialize fresh tracking instance for new scene. Read in skybox labels if exist.
    public void CreateNewScene(string sceneName)
    {
        // Create a new instance of dictionaries we'll use
        labelDictionary   = new Dictionary <Color, List <string> >();
        eyeTrackingLogger = new EyeTrackingLogger();
        labelTexture      = new Texture2D(2, 2);

        // Initialize variables
        currentEyeBlinkCount = 0;
        lastEyeBlinkCount    = 0;
        lastEyeClosedStatus  = Fove.Managed.EFVR_Eye.Neither;
        currentScene         = sceneName;

        // Check if file exists
        if (File.Exists(LABEL_IMAGE + sceneName + ".jpg") == false)
        {
            return;
        }
        if (File.Exists(LABEL_TEXT + sceneName + ".txt") == false)
        {
            return;
        }

        // Read in texture label
        byte[] labelTextureByteStream = File.ReadAllBytes(LABEL_IMAGE + sceneName + ".jpg");
        labelTexture.LoadImage(labelTextureByteStream);

        // Read in the labels
        string[] labels = System.IO.File.ReadAllLines(LABEL_TEXT + sceneName + ".txt");
        for (int i = 0; i < labels.Length; i += 2)
        {
            // Get the path to object and remove trailing/leading white spaces
            string[] pathToObject = labels[i].Split(',');
            for (int k = 0; k < pathToObject.Length; k++)
            {
                pathToObject[k] = pathToObject[k].Trim().Replace(' ', '_');
            }

            // Get the color
            string[] colorRGB   = labels[i + 1].Split(' ');
            Color    labelColor = new Color(
                (float)Convert.ToDecimal(colorRGB[0]),
                (float)Convert.ToDecimal(colorRGB[1]),
                (float)Convert.ToDecimal(colorRGB[2]));

            // Assign to dictionary to keep track
            labelDictionary.Add(labelColor, new List <string>(pathToObject));
        }
    }