BlockMeanHash.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 BlockMeanHash
  9. /**
  10. * Image hash based on block mean.
  11. *
  12. * See CITE: zauner2010implementation for details.
  13. */
  14. public class BlockMeanHash : ImgHashBase
  15. {
  16. protected override void Dispose(bool disposing)
  17. {
  18. try
  19. {
  20. if (disposing)
  21. {
  22. }
  23. if (IsEnabledDispose)
  24. {
  25. if (nativeObj != IntPtr.Zero)
  26. img_1hash_BlockMeanHash_delete(nativeObj);
  27. nativeObj = IntPtr.Zero;
  28. }
  29. }
  30. finally
  31. {
  32. base.Dispose(disposing);
  33. }
  34. }
  35. protected internal BlockMeanHash(IntPtr addr) : base(addr) { }
  36. // internal usage only
  37. public static new BlockMeanHash __fromPtr__(IntPtr addr) { return new BlockMeanHash(addr); }
  38. //
  39. // C++: void cv::img_hash::BlockMeanHash::setMode(int mode)
  40. //
  41. /**
  42. * Create BlockMeanHash object
  43. * param mode the mode
  44. */
  45. public void setMode(int mode)
  46. {
  47. ThrowIfDisposed();
  48. img_1hash_BlockMeanHash_setMode_10(nativeObj, mode);
  49. }
  50. //
  51. // C++: vector_double cv::img_hash::BlockMeanHash::getMean()
  52. //
  53. public MatOfDouble getMean()
  54. {
  55. ThrowIfDisposed();
  56. return MatOfDouble.fromNativeAddr(DisposableObject.ThrowIfNullIntPtr(img_1hash_BlockMeanHash_getMean_10(nativeObj)));
  57. }
  58. //
  59. // C++: static Ptr_BlockMeanHash cv::img_hash::BlockMeanHash::create(int mode = BLOCK_MEAN_HASH_MODE_0)
  60. //
  61. public static BlockMeanHash create(int mode)
  62. {
  63. return BlockMeanHash.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(img_1hash_BlockMeanHash_create_10(mode)));
  64. }
  65. public static BlockMeanHash create()
  66. {
  67. return BlockMeanHash.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(img_1hash_BlockMeanHash_create_11()));
  68. }
  69. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  70. const string LIBNAME = "__Internal";
  71. #else
  72. const string LIBNAME = "opencvforunity";
  73. #endif
  74. // C++: void cv::img_hash::BlockMeanHash::setMode(int mode)
  75. [DllImport(LIBNAME)]
  76. private static extern void img_1hash_BlockMeanHash_setMode_10(IntPtr nativeObj, int mode);
  77. // C++: vector_double cv::img_hash::BlockMeanHash::getMean()
  78. [DllImport(LIBNAME)]
  79. private static extern IntPtr img_1hash_BlockMeanHash_getMean_10(IntPtr nativeObj);
  80. // C++: static Ptr_BlockMeanHash cv::img_hash::BlockMeanHash::create(int mode = BLOCK_MEAN_HASH_MODE_0)
  81. [DllImport(LIBNAME)]
  82. private static extern IntPtr img_1hash_BlockMeanHash_create_10(int mode);
  83. [DllImport(LIBNAME)]
  84. private static extern IntPtr img_1hash_BlockMeanHash_create_11();
  85. // native support for java finalize()
  86. [DllImport(LIBNAME)]
  87. private static extern void img_1hash_BlockMeanHash_delete(IntPtr nativeObj);
  88. }
  89. }