Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FaceRecognizer"/> class.
        /// </summary>
        /// <param name="pipeline">The pipeline to add the component to.</param>
        /// <param name="configuration">The component configuration.</param>
        public FaceRecognizer(Pipeline pipeline, FaceRecognizerConfiguration configuration)
            : base(pipeline)
        {
            this.configuration     = configuration;
            this.RateLimitExceeded = pipeline.CreateEmitter <bool>(this, nameof(this.RateLimitExceeded));

            this.faceServiceClient = new FaceServiceClient(this.configuration.SubscriptionKey, this.configuration.SubscriptionAccessPoint);
            this.persons           = this.faceServiceClient.ListPersonsAsync(configuration.PersonGroupId.ToString());
            this.persons.Wait();
        }
Exemple #2
0
        /// <summary>
        /// Performs face recognition over a stream of images via <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>.
        /// </summary>
        /// <param name="source">The source stream of images.</param>
        /// <param name="configuration">The face recognizer configuration.</param>
        /// <param name="deliveryPolicy">The delivery policy. If not specified, the default delivery policy used is <see cref="DeliveryPolicy.LatestMessage"/></param>
        /// <returns>A stream of messages containing a dictionary that represents the set of identity alternates and their corresponding scores.</returns>
        /// <remarks>
        /// A <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
        /// subscription key is required to use this operators. In addition, a person group needs to be created ahead of time, and the id of the person group
        /// passed to the operator via the configuration. For more information, and to see how to create person groups, see the full direct API for
        /// <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
        /// </remarks>
        public static IProducer <Dictionary <string, double> > RecognizeFace(this IProducer <Shared <Imaging.Image> > source, FaceRecognizerConfiguration configuration, DeliveryPolicy deliveryPolicy = null)
        {
            deliveryPolicy = deliveryPolicy ?? DeliveryPolicy.LatestMessage;
            var faceRecognizer = new FaceRecognizer(source.Out.Pipeline, configuration);

            source.PipeTo(faceRecognizer, deliveryPolicy);
            return(faceRecognizer.Out);
        }
Exemple #3
0
 /// <summary>
 /// Performs face recognition over a stream of images via <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>.
 /// </summary>
 /// <param name="source">The source stream of images.</param>
 /// <param name="configuration">The face recognizer configuration.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>A stream of messages containing detected faces and candidate identities of each person in the image.</returns>
 /// <remarks>
 /// A <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
 /// subscription key is required to use this operators. In addition, a person group needs to be created ahead of time, and the id of the person group
 /// passed to the operator via the configuration. For more information, and to see how to create person groups, see the full direct API for.
 /// <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
 /// </remarks>
 public static IProducer <IList <IList <(string Name, double Confidence)> > > RecognizeFace(
     this IProducer <Shared <Image> > source,
     FaceRecognizerConfiguration configuration,
     DeliveryPolicy <Shared <Image> > deliveryPolicy = null,
     string name = nameof(RecognizeFace))
 => source.PipeTo(new FaceRecognizer(source.Out.Pipeline, configuration, name), deliveryPolicy);
Exemple #4
0
        /// <summary>
        /// Performs face recognition over a stream of images via <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>.
        /// </summary>
        /// <param name="source">The source stream of images.</param>
        /// <param name="configuration">The face recognizer configuration.</param>
        /// <param name="deliveryPolicy">An optional delivery policy.</param>
        /// <returns>A stream of messages containing detected faces and candidate identities of each person in the image.</returns>
        /// <remarks>
        /// A <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
        /// subscription key is required to use this operators. In addition, a person group needs to be created ahead of time, and the id of the person group
        /// passed to the operator via the configuration. For more information, and to see how to create person groups, see the full direct API for.
        /// <a href="https://azure.microsoft.com/en-us/services/cognitive-services/face/">Microsoft Cognitive Services Face API</a>
        /// </remarks>
        public static IProducer <IList <IList <(string Name, double Confidence)> > > RecognizeFace(this IProducer <Shared <Image> > source, FaceRecognizerConfiguration configuration, DeliveryPolicy <Shared <Image> > deliveryPolicy = null)
        {
            var faceRecognizer = new FaceRecognizer(source.Out.Pipeline, configuration);

            source.PipeTo(faceRecognizer, deliveryPolicy);
            return(faceRecognizer.Out);
        }