Saliency.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.SaliencyModule
  8. {
  9. // C++: class Saliency
  10. //javadoc: Saliency
  11. public class Saliency : 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. saliency_Saliency_delete (nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal Saliency (IntPtr addr)
  32. : base (addr)
  33. {
  34. }
  35. // internal usage only
  36. public static new Saliency __fromPtr__ (IntPtr addr)
  37. {
  38. return new Saliency (addr);
  39. }
  40. //
  41. // C++: bool cv::saliency::Saliency::computeSaliency(Mat image, Mat& saliencyMap)
  42. //
  43. //javadoc: Saliency::computeSaliency(image, saliencyMap)
  44. public virtual bool computeSaliency (Mat image, Mat saliencyMap)
  45. {
  46. ThrowIfDisposed ();
  47. if (image != null)
  48. image.ThrowIfDisposed ();
  49. if (saliencyMap != null)
  50. saliencyMap.ThrowIfDisposed ();
  51. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  52. bool retVal = saliency_Saliency_computeSaliency_10 (nativeObj, image.nativeObj, saliencyMap.nativeObj);
  53. return retVal;
  54. #else
  55. return false;
  56. #endif
  57. }
  58. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  59. const string LIBNAME = "__Internal";
  60. #else
  61. const string LIBNAME = "opencvforunity";
  62. #endif
  63. // C++: bool cv::saliency::Saliency::computeSaliency(Mat image, Mat& saliencyMap)
  64. [DllImport (LIBNAME)]
  65. private static extern bool saliency_Saliency_computeSaliency_10 (IntPtr nativeObj, IntPtr image_nativeObj, IntPtr saliencyMap_nativeObj);
  66. // native support for java finalize()
  67. [DllImport (LIBNAME)]
  68. private static extern void saliency_Saliency_delete (IntPtr nativeObj);
  69. }
  70. }