Ejemplo n.º 1
0
        private static async Task <FaceRecognitionResult> InvokeRecognizeAsync(MediaVisionSource source,
                                                                               FaceRecognitionModel recognitionModel, Rectangle?area,
                                                                               FaceRecognitionConfiguration config)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (recognitionModel == null)
            {
                throw new ArgumentNullException(nameof(recognitionModel));
            }

            TaskCompletionSource <FaceRecognitionResult> tcs = new TaskCompletionSource <FaceRecognitionResult>();

            using (var cb = ObjectKeeper.Get(GetRecognizedCallback(tcs)))
            {
                InvokeRecognize(source.Handle, recognitionModel.Handle, EngineConfiguration.GetHandle(config),
                                cb.Target, area).Validate("Failed to perform face recognition.");

                return(await tcs.Task);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Performs face recognition on the source with <see cref="FaceRecognitionModel"/> and <see cref="FaceRecognitionConfiguration"/>.
 /// </summary>
 /// <param name="source">The <see cref="MediaVisionSource"/> of the media to recognize faces for.</param>
 /// <param name="recognitionModel">The <see cref="FaceRecognitionModel"/> to be used for recognition.</param>
 /// <param name="config">The configuration used for recognition. This value can be null.</param>
 /// <returns>A task that represents the asynchronous recognition operation.</returns>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="source"/> is null.<br/>
 ///     -or-<br/>
 ///     <paramref name="recognitionModel"/> is null.
 /// </exception>
 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
 /// <exception cref="ObjectDisposedException">
 ///     <paramref name="source"/> has already been disposed of.<br/>
 ///     -or-<br/>
 ///     <paramref name="config"/> has already been disposed of.
 /// </exception>
 /// <exception cref="InvalidOperationException"><paramref name="recognitionModel"/> is untrained model.</exception>
 /// <feature>http://tizen.org/feature/vision.face_recognition</feature>
 /// <since_tizen> 4 </since_tizen>
 public static async Task <FaceRecognitionResult> RecognizeAsync(MediaVisionSource source,
                                                                 FaceRecognitionModel recognitionModel, FaceRecognitionConfiguration config)
 {
     return(await InvokeRecognizeAsync(source, recognitionModel, null, config));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Performs face recognition on the source with <see cref="FaceRecognitionModel"/> and a bounding box.
 /// </summary>
 /// <param name="source">The <see cref="MediaVisionSource"/> of the media to recognize faces for.</param>
 /// <param name="recognitionModel">The <see cref="FaceRecognitionModel"/> to be used for recognition.</param>
 /// <param name="bound">Rectangular box bounding face image on the source.</param>
 /// <returns>A task that represents the asynchronous recognition operation.</returns>
 /// <exception cref="ArgumentNullException">
 ///     <paramref name="source"/> is null.<br/>
 ///     -or-<br/>
 ///     <paramref name="recognitionModel"/> is null.
 /// </exception>
 /// <exception cref="NotSupportedException">The feature is not supported.</exception>
 /// <exception cref="ObjectDisposedException"><paramref name="source"/> has already been disposed of.</exception>
 /// <exception cref="InvalidOperationException"><paramref name="recognitionModel"/> is untrained model.</exception>
 /// <feature>http://tizen.org/feature/vision.face_recognition</feature>
 /// <since_tizen> 4 </since_tizen>
 public static async Task <FaceRecognitionResult> RecognizeAsync(MediaVisionSource source,
                                                                 FaceRecognitionModel recognitionModel, Rectangle bound)
 {
     return(await InvokeRecognizeAsync(source, recognitionModel, bound, null));
 }