TrackerCSRT.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using OpenCVForUnity.VideoModule;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Runtime.InteropServices;
  7. namespace OpenCVForUnity.TrackingModule
  8. {
  9. // C++: class TrackerCSRT
  10. /**
  11. * the CSRT tracker
  12. *
  13. * The implementation is based on CITE: Lukezic_IJCV2018 Discriminative Correlation Filter with Channel and Spatial Reliability
  14. */
  15. public class TrackerCSRT : Tracker
  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. tracking_TrackerCSRT_delete(nativeObj);
  28. nativeObj = IntPtr.Zero;
  29. }
  30. }
  31. finally
  32. {
  33. base.Dispose(disposing);
  34. }
  35. }
  36. protected internal TrackerCSRT(IntPtr addr) : base(addr) { }
  37. // internal usage only
  38. public static new TrackerCSRT __fromPtr__(IntPtr addr) { return new TrackerCSRT(addr); }
  39. //
  40. // C++: static Ptr_TrackerCSRT cv::TrackerCSRT::create(TrackerCSRT_Params parameters = TrackerCSRT::Params())
  41. //
  42. /**
  43. * Create CSRT tracker instance
  44. * param parameters CSRT parameters TrackerCSRT::Params
  45. * return automatically generated
  46. */
  47. public static TrackerCSRT create(TrackerCSRT_Params parameters)
  48. {
  49. if (parameters != null) parameters.ThrowIfDisposed();
  50. return TrackerCSRT.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(tracking_TrackerCSRT_create_10(parameters.nativeObj)));
  51. }
  52. /**
  53. * Create CSRT tracker instance
  54. * return automatically generated
  55. */
  56. public static TrackerCSRT create()
  57. {
  58. return TrackerCSRT.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(tracking_TrackerCSRT_create_11()));
  59. }
  60. //
  61. // C++: void cv::TrackerCSRT::setInitialMask(Mat mask)
  62. //
  63. public void setInitialMask(Mat mask)
  64. {
  65. ThrowIfDisposed();
  66. if (mask != null) mask.ThrowIfDisposed();
  67. tracking_TrackerCSRT_setInitialMask_10(nativeObj, mask.nativeObj);
  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++: static Ptr_TrackerCSRT cv::TrackerCSRT::create(TrackerCSRT_Params parameters = TrackerCSRT::Params())
  75. [DllImport(LIBNAME)]
  76. private static extern IntPtr tracking_TrackerCSRT_create_10(IntPtr parameters_nativeObj);
  77. [DllImport(LIBNAME)]
  78. private static extern IntPtr tracking_TrackerCSRT_create_11();
  79. // C++: void cv::TrackerCSRT::setInitialMask(Mat mask)
  80. [DllImport(LIBNAME)]
  81. private static extern void tracking_TrackerCSRT_setInitialMask_10(IntPtr nativeObj, IntPtr mask_nativeObj);
  82. // native support for java finalize()
  83. [DllImport(LIBNAME)]
  84. private static extern void tracking_TrackerCSRT_delete(IntPtr nativeObj);
  85. }
  86. }