ImgHashBase.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. 
  2. using OpenCVForUnity.CoreModule;
  3. using OpenCVForUnity.UtilsModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.Img_hashModule
  8. {
  9. // C++: class ImgHashBase
  10. //javadoc: ImgHashBase
  11. public class ImgHashBase : Algorithm
  12. {
  13. protected override void Dispose (bool disposing)
  14. {
  15. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  16. try {
  17. if (disposing) {
  18. }
  19. if (IsEnabledDispose) {
  20. if (nativeObj != IntPtr.Zero)
  21. img_1hash_ImgHashBase_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal ImgHashBase (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new ImgHashBase __fromPtr__ (IntPtr addr) { return new ImgHashBase (addr); }
  34. //
  35. // C++: double cv::img_hash::ImgHashBase::compare(Mat hashOne, Mat hashTwo)
  36. //
  37. //javadoc: ImgHashBase::compare(hashOne, hashTwo)
  38. public double compare (Mat hashOne, Mat hashTwo)
  39. {
  40. ThrowIfDisposed ();
  41. if (hashOne != null) hashOne.ThrowIfDisposed ();
  42. if (hashTwo != null) hashTwo.ThrowIfDisposed ();
  43. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  44. double retVal = img_1hash_ImgHashBase_compare_10(nativeObj, hashOne.nativeObj, hashTwo.nativeObj);
  45. return retVal;
  46. #else
  47. return -1;
  48. #endif
  49. }
  50. //
  51. // C++: void cv::img_hash::ImgHashBase::compute(Mat inputArr, Mat& outputArr)
  52. //
  53. //javadoc: ImgHashBase::compute(inputArr, outputArr)
  54. public void compute (Mat inputArr, Mat outputArr)
  55. {
  56. ThrowIfDisposed ();
  57. if (inputArr != null) inputArr.ThrowIfDisposed ();
  58. if (outputArr != null) outputArr.ThrowIfDisposed ();
  59. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  60. img_1hash_ImgHashBase_compute_10(nativeObj, inputArr.nativeObj, outputArr.nativeObj);
  61. return;
  62. #else
  63. return;
  64. #endif
  65. }
  66. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  67. const string LIBNAME = "__Internal";
  68. #else
  69. const string LIBNAME = "opencvforunity";
  70. #endif
  71. // C++: double cv::img_hash::ImgHashBase::compare(Mat hashOne, Mat hashTwo)
  72. [DllImport (LIBNAME)]
  73. private static extern double img_1hash_ImgHashBase_compare_10 (IntPtr nativeObj, IntPtr hashOne_nativeObj, IntPtr hashTwo_nativeObj);
  74. // C++: void cv::img_hash::ImgHashBase::compute(Mat inputArr, Mat& outputArr)
  75. [DllImport (LIBNAME)]
  76. private static extern void img_1hash_ImgHashBase_compute_10 (IntPtr nativeObj, IntPtr inputArr_nativeObj, IntPtr outputArr_nativeObj);
  77. // native support for java finalize()
  78. [DllImport (LIBNAME)]
  79. private static extern void img_1hash_ImgHashBase_delete (IntPtr nativeObj);
  80. }
  81. }