Beispiel #1
0
    void CustomReceiveData(string topic, Dictionary <string, object> dictionary, byte[] thirdFrame = null)
    {
        if (topic.StartsWith("pupil"))
        {
            foreach (var item in dictionary)
            {
                switch (item.Key)
                {
                case "topic":
                case "method":
                case "id":
                    var textForKey = PupilTools.StringFromDictionary(dictionary, item.Key);
                    // Do stuff
                    break;

                case "confidence":
                    print("Conf : " + PupilTools.FloatFromDictionary(dictionary, item.Key));
                    // Do stuff
                    break;

                case "norm_pos":
                    print("Norm : " + PupilTools.VectorFromDictionary(dictionary, item.Key));
                    // Do stuff
                    break;

                case "ellipse":
                    var dictionaryForKey = PupilTools.DictionaryFromDictionary(dictionary, item.Key);
                    foreach (var pupilEllipse in dictionaryForKey)
                    {
                        switch (pupilEllipse.Key.ToString())
                        {
                        case "angle":
                            var angle = (float)(double)pupilEllipse.Value;
                            // Do stuff
                            break;

                        case "center":
                            print("Center : " + PupilTools.ObjectToVector(pupilEllipse.Value));
                            break;

                        case "axes":
                            print("Axes : " + PupilTools.ObjectToVector(pupilEllipse.Value));
                            // Do stuff
                            break;

                        default:
                            break;
                        }
                    }
                    // Do stuff
                    break;

                default:
                    break;
                }
            }
        }
    }