Exemple #1
0
        private static async Task IngestionPipeline()
        {
            Console.WriteLine("\n Ingestion Pipeline");

            Console.WriteLine("\n Enter new image url:");
            string img = Console.ReadLine();

            Console.WriteLine("\n Enter Large Face List ID:");
            string faceListID = Console.ReadLine();

            try
            {
                List <Face> detectedFaces = await FaceAPIHelpers.DetectFaces(img, true);

                foreach (Face f in detectedFaces)
                {
                    try
                    {
                        PersistedFace persistedFace = await FaceAPIHelpers.AddFace(img, faceListID, f.faceRectangle);

                        Console.WriteLine("\n Face " + persistedFace.persistedFaceId + " added.");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"\n{e.GetType().Name}: Could not add face to Large Face List.");
                        throw (e);
                    }
                }

                try
                {
                    await FaceAPIHelpers.TrainFaceList(faceListID);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"\n{e.GetType().Name}: Could not train Large Face List.");
                    throw (e);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"\n{e.GetType().Name}: Could not detect faces.");
                throw (e);
            }

            AskUser();
        }
Exemple #2
0
        private static async Task SearchSimilarPipeline()
        {
            Console.WriteLine("\nSearch Similar Pipeline");
            float threshold = 80f;

            Console.WriteLine("\nEnter image url: ");
            string img = Console.ReadLine();

            try
            {
                List <Face> detectedFaces = await FaceAPIHelpers.DetectFaces(img);

                foreach (Face f in detectedFaces)
                {
                    try
                    {
                        List <PersistedFace> similarFaces = await FaceAPIHelpers.SimilarFaces(f, "testfacelistkatia", 5);

                        Console.WriteLine("\n Face ID:" + f.faceId);
                        foreach (PersistedFace simFace in similarFaces)
                        {
                            if (simFace.confidence > threshold)
                            {
                                Console.Write("\n Similar Face ID: " + simFace.persistedFaceId);
                                Console.Write("\n Confidence: " + simFace.confidence + "\n");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"\n{e.GetType().Name}: Could not find Similar Faces.");
                        throw(e);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"\n{e.GetType().Name}: Could not detect faces.");
                throw (e);
            }

            AskUser();
        }