Esempio n. 1
0
        internal Face(FaceData data)
        {
            Measurements  = data.measurements;
            FeaturePoints = data.featurePoints;

            Expressions = new Dictionary <Affdex2.Expressions, float>();
            for (int i = 0; i < data.expressions.Length; i++)
            {
                Expressions[data.expressions[i].expression] = data.expressions[i].value;
            }

            Emotions = new Dictionary <Affdex2.Emotions, float>();
            for (int i = 0; i < data.emotions.Length; i++)
            {
                Emotions[data.emotions[i].emotion] = data.emotions[i].value;
            }
        }
        /// <summary>
        /// ImageResults callback from native plugin!
        /// </summary>
        /// <param name="faceData">Platform-specific pointer to image results</param>
        public void onImageResults(IntPtr faceData)
        {
            System.Collections.Generic.Dictionary <int, Face> faces = new System.Collections.Generic.Dictionary <int, Face>();
            if (faceData != IntPtr.Zero)
            {
                try
                {
                    //todo: Face ID might not always be zero, or there might be more faces!!!
                    FaceData f = (FaceData)Marshal.PtrToStructure(faceData, typeof(FaceData));
                    faces[0] = new Face(f);
                }
                catch (Exception e)
                {
                    Debug.Log(e.Message + " " + e.StackTrace);
                }
            }

            detector.AddEvent(new NativeEvent(NativeEventType.ImageResults, faces));
        }