AverageHash.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.Img_hashModule
  7. {
  8. // C++: class AverageHash
  9. /**
  10. * Computes average hash value of the input image
  11. *
  12. * This is a fast image hashing algorithm, but only work on simple case. For more details, please
  13. * refer to CITE: lookslikeit
  14. */
  15. public class AverageHash : ImgHashBase
  16. {
  17. protected override void Dispose(bool disposing)
  18. {
  19. try
  20. {
  21. if (disposing)
  22. {
  23. }
  24. if (IsEnabledDispose)
  25. {
  26. if (nativeObj != IntPtr.Zero)
  27. img_1hash_AverageHash_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal AverageHash(IntPtr addr) : base(addr) { }
  37. // internal usage only
  38. public static new AverageHash __fromPtr__(IntPtr addr) { return new AverageHash(addr); }
  39. //
  40. // C++: static Ptr_AverageHash cv::img_hash::AverageHash::create()
  41. //
  42. public static AverageHash create()
  43. {
  44. return AverageHash.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(img_1hash_AverageHash_create_10()));
  45. }
  46. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  47. const string LIBNAME = "__Internal";
  48. #else
  49. const string LIBNAME = "opencvforunity";
  50. #endif
  51. // C++: static Ptr_AverageHash cv::img_hash::AverageHash::create()
  52. [DllImport(LIBNAME)]
  53. private static extern IntPtr img_1hash_AverageHash_create_10();
  54. // native support for java finalize()
  55. [DllImport(LIBNAME)]
  56. private static extern void img_1hash_AverageHash_delete(IntPtr nativeObj);
  57. }
  58. }