public void EmbeddingCache(IntPtr pRecognizer)
        {
            List <FaceCache> faceCaches = new List <FaceCache>();

            string[] jpgFiles = Directory.GetFiles("E:\\CUBOX\\Private\\CSharp\\FaceAlgorismTestConsole\\bin\\Debug\\netcoreapp3.1\\cubox");
            foreach (var item in jpgFiles.Select((value, i) => (value, i)))
            {
                byte[] imageBytes = File.ReadAllBytes(item.value);

                byte[] srcEmbed = faceAlgorism.FaceExtract(pRecognizer, imageBytes, false);

                faceCaches.Add(new FaceCache {
                    No = item.i, Value = srcEmbed, Url = item.value
                });
            }
            _cache.Set("Face", faceCaches);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            IMemoryCache       _cache        = new MemoryCache(new MemoryCacheOptions());
            FaceAlgorism       algorism      = new FaceAlgorism(_cache);
            FaceEmbeddingCache faceEmbedding = new FaceEmbeddingCache(_cache, algorism);

            IntPtr pRecognizer = CreateCURecognizer();

            StringBuilder config_file = new StringBuilder();

            config_file.Append("E:\\CUBOX\\Private\\CSharp\\FaceAlgorismTestConsole\\bin\\Debug\\netcoreapp3.1\\cuface_config.json");

            Init(pRecognizer, config_file, false);



            faceEmbedding.EmbeddingCache(pRecognizer);

            Console.WriteLine("-------------------- Matching Test -----------------------");
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            string testImagePath = "E:\\CUBOX\\Private\\CSharp\\FaceAlgorismTestConsole\\bin\\Debug\\netcoreapp3.1\\cubox\\Choi-sehwan.jpg";

            byte[] imageBytes = File.ReadAllBytes(testImagePath);

            byte[] detectionImage = algorism.FaceDetectionTest(pRecognizer, imageBytes);

            byte[] srcEmbed = algorism.FaceExtract(pRecognizer, detectionImage, true);

            List <FaceCache> faceCaches = new List <FaceCache>();

            _cache.TryGetValue("Face", out faceCaches);
            foreach (var item in faceCaches)
            {
                float score = algorism.FaceMatch(pRecognizer, srcEmbed, item.Value);
                if (score > 60)
                {
                    Console.WriteLine("Score : " + score + " User No : " + item.No);
                    Console.WriteLine(item.Url);
                }
            }
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            Console.WriteLine("-------------------- Matching Test -----------------------");

            DisposeCURecognizer(pRecognizer);
        }