Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mode"></param>
 public void SetMode(BlockMeanHashMode mode)
 {
     ThrowIfDisposed();
     NativeMethods.HandleException(
         NativeMethods.img_hash_BlockMeanHash_setMode(ptr, (int)mode));
     GC.KeepAlive(this);
 }
 public void CompareSameImage(BlockMeanHashMode mode)
 {
     using (var model = BlockMeanHash.Create(mode))
         using (var img1 = Image("lenna.png", ImreadModes.GrayScale))
         {
             double hash = model.Compare(img1, img1);
             Assert.Equal(0, hash, 6);
         }
 }
 public void CompareDifferentImage(BlockMeanHashMode mode)
 {
     using (var model = BlockMeanHash.Create(mode))
         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);
                     }
             }
 }
Beispiel #4
0
        /// <summary>
        /// Create BlockMeanHash object
        /// </summary>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static BlockMeanHash Create(BlockMeanHashMode mode = BlockMeanHashMode.Mode0)
        {
            var p = NativeMethods.img_hash_BlockMeanHash_create((int)mode);

            return(new BlockMeanHash(p));
        }
Beispiel #5
0
 /// <summary>
 /// Create BlockMeanHash object
 /// </summary>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static BlockMeanHash Create(BlockMeanHashMode mode = BlockMeanHashMode.Mode0)
 {
     NativeMethods.HandleException(
         NativeMethods.img_hash_BlockMeanHash_create((int)mode, out var p));
     return(new BlockMeanHash(p));
 }