Esempio n. 1
0
        private static InteropFace.DetectedCallback GetCallback(TaskCompletionSource <Rectangle[]> tcs)
        {
            return((IntPtr sourceHandle, IntPtr engineConfig, global::Interop.MediaVision.Rectangle[] facesLocations,
                    int numberOfFaces, IntPtr _) =>
            {
                try
                {
                    Log.Info(MediaVisionLog.Tag, $"Faces detected, count : {numberOfFaces}.");
                    Rectangle[] locations = new Rectangle[numberOfFaces];
                    for (int i = 0; i < numberOfFaces; i++)
                    {
                        locations[i] = facesLocations[i].ToApiStruct();
                        Log.Info(MediaVisionLog.Tag, $"Face {0} detected : {locations}.");
                    }

                    if (!tcs.TrySetResult(locations))
                    {
                        Log.Error(MediaVisionLog.Tag, "Failed to set face detection result.");
                    }
                }
                catch (Exception e)
                {
                    MultimediaLog.Info(MediaVisionLog.Tag, "Failed to handle face detection.", e);
                    tcs.TrySetException(e);
                }
            });
        }