示例#1
0
    private static void UpdateGaze()
    {
        foreach (var key in gazeKeys)
        {
            if (gazeDictionary.ContainsKey(key))
            {
                switch (key)
                {
                case "norm_pos":                               // 2D case
                    eyeDataKey = key + "_" + stringForEyeID(); // we add the identifier to the key
                    PupilData.AddGazeToEyeData(eyeDataKey, Position(gazeDictionary[key], false));
                    break;

                case "eye_centers_3d":
                case "gaze_normals_3d":
                    // in case of eye_centers_3d and gaze_normals_3d, we get an dictionary with one positional object for each eye id (the key)
                    if (gazeDictionary [key] is Dictionary <object, object> )
                    {
                        foreach (var item in (gazeDictionary[key] as Dictionary <object, object>))
                        {
                            eyeDataKey = key + "_" + item.Key.ToString();
                            PupilData.AddGazeToEyeData(eyeDataKey, Position(item.Value, true));
                        }
                    }
                    break;

                default:
                    PupilData.AddGazeToEyeData(key, Position(gazeDictionary[key], true));
                    break;
                }
            }
        }
    }
示例#2
0
    private static void UpdateGaze()
    {
        CheckModeConsistency();
        foreach (var key in gazeKeys)
        {
            if (gazeDictionary.ContainsKey(key))
            {
                switch (key)
                {
                case "norm_pos":                                                         // 2D case
                    eyeDataKey = key + "_" + StringFromDictionary(gazeDictionary, "id"); // we add the identifier to the key
                    var position2D = Position(gazeDictionary [key], false);
                    PupilData.AddGazeToEyeData(eyeDataKey, position2D);
                    if (isRecording)
                    {
                        AddToRecording(eyeDataKey, position2D, true);
                    }
                    break;

                case "eye_centers_3d":
                case "gaze_normals_3d":
                    // in case of eye_centers_3d and gaze_normals_3d, we get an dictionary with one positional object for each eye id (the key)
                    if (gazeDictionary [key] is Dictionary <object, object> )
                    {
                        foreach (var item in (gazeDictionary[key] as Dictionary <object, object>))
                        {
                            eyeDataKey = key + "_" + item.Key.ToString();
                            var position = Position(item.Value, true);
                            position.y *= -1f;                                                                                  // Pupil y axis is inverted
                            PupilData.AddGazeToEyeData(eyeDataKey, position);
                        }
                    }
                    break;

                default:
                    var position3D = Position(gazeDictionary [key], true);
                    position3D.y *= -1f;                                                                                // Pupil y axis is inverted
                    PupilData.AddGazeToEyeData(key, position3D);
                    if (isRecording)
                    {
                        AddToRecording(key, position3D);
                    }
                    break;
                }
            }
        }
    }