// Start is called before the first frame update void Start() { _DlibDetector = gameObject.GetComponent <DlibFaceDetection>(); LoadNet(); //var img = CVUtils.LoadImgToTexture(Utils.getFilePath(input), TextureFormat.RGB24); //var img_2 = CVUtils.LoadImgToTexture(Utils.getFilePath(input_2), TextureFormat.RGB24); //var cp_1 = GetCroppedFace(img); //var cp_2 = GetCroppedFace(img_2); //var rep1 = ExtractEmbeddings(cp_1); //var rep2 = ExtractEmbeddings(cp_2); //var mat1 = rep1.CreateMatFromEmbeddings(rep1.Embeddings); //var mat2 = rep2.CreateMatFromEmbeddings(rep2.Embeddings); ////var l2_dist = Core.norm(mat1, mat2, 4); ////var l2_norm = Core.norm(mat1, 4) - Core.norm(mat2, 4); ////var diff = mat1 - mat2; ////var result = diff.dot(diff); ////result = Mathf.Sqrt((float)result); ////if (result < 105) ////{ //// Debug.Log(result); //// Debug.Log("similar"); ////} ////if (result > 105) ////{ //// Debug.Log(result); //// Debug.Log("NOT similar"); ////} //for (int i = 0; i < 128; i++) //{ // mat1.put(0, i, mat1.get(0, i)[0] / Core.norm(mat1,4)); //} //for (int i = 0; i < 128; i++) //{ // mat2.put(0, i, mat2.get(0, i)[0] / Core.norm(mat2,4)); //} //var ab = mat1.dot(mat2); //var aMagni = Core.norm(mat1); //var bMagni = Core.norm(mat2); //var cos_sim = ab / (aMagni * bMagni); //Debug.Log(1 - cos_sim); ////Debug.Log(cos_sim); }
// Start is called before the first frame update void Start() { _faceDetector = gameObject.GetComponent <ObjectDetectionInference>(); _DlibDetector = gameObject.GetComponent <DlibFaceDetection>(); if (!string.IsNullOrEmpty(model)) { model_filepath = Utils.getFilePath("dnn/" + model); } if (!string.IsNullOrEmpty(input)) { input_filepath = Utils.getFilePath("dnn/" + input); } //var rep1 = GetRep(input_1); //var rep2 = GetRep(input_2); //double result = Core.norm(rep1, rep2, 5); //Debug.Log(result); //// squared L2 distance. //var diff = mat_1 - mat_2; //var result = diff.dot(diff); }