private void RecognizeFolder()
    {
        foreach (var file in recoFiles)
        {
            var n            = file.Replace(recFolderPath.text, "");
            var n_2          = n.Remove(0, 1);
            var tex          = CVUtils.LoadImgToTexture($"FR/{recPath.text}/" + n, TextureFormat.RGBA32);
            var input_emb    = faceRecMng.ExtractEmbeddings(tex);
            var dict         = faceRecMng.StoredFaces.serializedDict;
            var matchResults = new Dictionary <string, double>();
            foreach (var key in dict.Keys)
            {
                var dist = faceRecMng.CompareSimilarity(input_emb, dict[key]);
                matchResults.Add(key, dist);
            }

            var matched = (from match in matchResults where match.Value < 0.5 orderby match.Value select match).ToList();
            if (matched.Count == 0)
            {
                Debug.Log("no match");
            }
            else
            {
                Debug.Log(matched[0].Key);
            }
        }
    }
    private void RecognizeBtnListener()
    {
        var tex          = CVUtils.LoadImgToTexture(Utils.getFilePath(recPath.text), TextureFormat.RGB24);
        var input_emb    = faceRecMng.ExtractEmbeddings(tex);
        var dict         = faceRecMng.StoredFaces.serializedDict;
        var matchResults = new Dictionary <string, double>();

        foreach (var key in dict.Keys)
        {
            var dist = faceRecMng.CompareEmbeddings(input_emb, dict[key]);
            matchResults.Add(key, dist);
        }

        //var matched = matchResults.Select(m => m).Where(k => k.Value < 0.99).ToList();
        var matched = (from match in matchResults where match.Value < 0.5 orderby match.Value select match).ToList();

        if (matched.Count == 0)
        {
            text.text = "no match";
        }
        else
        {
            text.text = matched[0].Key;
        }
    }
        protected async Task <Texture2D> GetScreenShot()
        {
            camTex = new Texture2D(0, 0);
            float startCapture = Time.realtimeSinceStartup;
            var   frameBreak   = new WaitForEndOfFrame();

            if (externalCamera)
            {
                camTex = await httpLoader.LoadTextureFromImage()
                ;               while (!textureReceived)
                {
                    await frameBreak;
                }
            }
            else
            {
                //camTex = Resources.Load<Texture2D>("Photos/" + $"debug_{idx}");
                camTex = CVUtils.LoadImgToTexture(photoPath, TextureFormat.RGBA32);
            }
            float endCapture = Time.realtimeSinceStartup;

            captureTime     = GenericUtils.CalculateTimeDifference(startCapture, endCapture);
            textureReceived = true;
            Handheld.Vibrate();
            return(camTex);
        }
Beispiel #4
0
        public Mat GetRep(string path)
        {
            var tex = CVUtils.LoadImgToTexture(path, TextureFormat.RGBA32);
            var rep = ExtractFaceEmbeddings(tex, GetBBs(tex));
            Mat mat = rep.CreateMatFromEmbeddings(rep.Embeddings);

            return(mat);
        }
 private IEnumerator AddFolderToDict()
 {
     foreach (var file in imageFiles)
     {
         var n   = file.Replace(addFolderPath.text, "");
         var n_2 = n.Remove(0, 1);
         var tex = CVUtils.LoadImgToTexture("FR/LFW_Train/" + n, TextureFormat.RGBA32);
         faceRecMng.AddFace(n_2, tex);
         yield return(null);
     }
 }