Example #1
0
 public void CreateAndDispose()
 {
     using (var model = AverageHash.Create())
     {
         GC.KeepAlive(model);
     }
 }
Example #2
0
 public void CompareSameImage()
 {
     using (var model = AverageHash.Create())
         using (var img1 = Image("lenna.png", ImreadModes.Grayscale))
         {
             double hash = model.Compare(img1, img1);
             Assert.Equal(0, hash, 6);
         }
 }
Example #3
0
 public void CompareDifferentImage()
 {
     using (var model = AverageHash.Create())
         using (var img1 = Image("lenna.png", ImreadModes.Grayscale))
             using (var img2 = Image("building.jpg", ImreadModes.Grayscale))
             {
                 var size = new Size(256, 256);
                 using (var scaledImg1 = img1.Resize(size))
                     using (var scaledImg2 = img2.Resize(size))
                     {
                         double hash = model.Compare(scaledImg1, scaledImg2);
                         Assert.Equal(264411, hash, 6);
                     }
             }
 }
Example #4
0
        public void Compute()
        {
            using (var model = AverageHash.Create())
                using (var img = Image("lenna.png"))
                    using (var hash = new Mat <byte>())
                    {
                        model.Compute(img, hash);
                        Assert.Equal(1, hash.Rows);
                        Assert.Equal(8, hash.Cols);
                        Assert.Equal(MatType.CV_8UC1, hash.Type());

                        var hashArray = hash.ToArray();
                        Assert.Equal(101, hashArray[0]);
                        Assert.Equal(121, hashArray[1]);
                        Assert.Equal(185, hashArray[2]);
                        Assert.Equal(149, hashArray[3]);
                        Assert.Equal(205, hashArray[4]);
                        Assert.Equal(209, hashArray[5]);
                        Assert.Equal(213, hashArray[6]);
                        Assert.Equal(112, hashArray[7]);
                    }
        }