ContourFitting.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.XimgprocModule
  8. {
  9. // C++: class ContourFitting
  10. //javadoc: ContourFitting
  11. public class ContourFitting : 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. ximgproc_ContourFitting_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal ContourFitting (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new ContourFitting __fromPtr__ (IntPtr addr) { return new ContourFitting (addr); }
  34. //
  35. // C++: int cv::ximgproc::ContourFitting::getCtrSize()
  36. //
  37. //javadoc: ContourFitting::getCtrSize()
  38. public int getCtrSize ()
  39. {
  40. ThrowIfDisposed ();
  41. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  42. int retVal = ximgproc_ContourFitting_getCtrSize_10(nativeObj);
  43. return retVal;
  44. #else
  45. return -1;
  46. #endif
  47. }
  48. //
  49. // C++: int cv::ximgproc::ContourFitting::getFDSize()
  50. //
  51. //javadoc: ContourFitting::getFDSize()
  52. public int getFDSize ()
  53. {
  54. ThrowIfDisposed ();
  55. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  56. int retVal = ximgproc_ContourFitting_getFDSize_10(nativeObj);
  57. return retVal;
  58. #else
  59. return -1;
  60. #endif
  61. }
  62. //
  63. // C++: void cv::ximgproc::ContourFitting::estimateTransformation(Mat src, Mat dst, Mat& alphaPhiST, double& dist, bool fdContour = false)
  64. //
  65. //javadoc: ContourFitting::estimateTransformation(src, dst, alphaPhiST, dist, fdContour)
  66. public void estimateTransformation (Mat src, Mat dst, Mat alphaPhiST, double[] dist, bool fdContour)
  67. {
  68. ThrowIfDisposed ();
  69. if (src != null) src.ThrowIfDisposed ();
  70. if (dst != null) dst.ThrowIfDisposed ();
  71. if (alphaPhiST != null) alphaPhiST.ThrowIfDisposed ();
  72. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  73. double[] dist_out = new double[1];
  74. ximgproc_ContourFitting_estimateTransformation_10(nativeObj, src.nativeObj, dst.nativeObj, alphaPhiST.nativeObj, dist_out, fdContour);
  75. if(dist!=null) dist[0] = (double)dist_out[0];
  76. return;
  77. #else
  78. return;
  79. #endif
  80. }
  81. //javadoc: ContourFitting::estimateTransformation(src, dst, alphaPhiST, dist)
  82. public void estimateTransformation (Mat src, Mat dst, Mat alphaPhiST, double[] dist)
  83. {
  84. ThrowIfDisposed ();
  85. if (src != null) src.ThrowIfDisposed ();
  86. if (dst != null) dst.ThrowIfDisposed ();
  87. if (alphaPhiST != null) alphaPhiST.ThrowIfDisposed ();
  88. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  89. double[] dist_out = new double[1];
  90. ximgproc_ContourFitting_estimateTransformation_11(nativeObj, src.nativeObj, dst.nativeObj, alphaPhiST.nativeObj, dist_out);
  91. if(dist!=null) dist[0] = (double)dist_out[0];
  92. return;
  93. #else
  94. return;
  95. #endif
  96. }
  97. //
  98. // C++: void cv::ximgproc::ContourFitting::setCtrSize(int n)
  99. //
  100. //javadoc: ContourFitting::setCtrSize(n)
  101. public void setCtrSize (int n)
  102. {
  103. ThrowIfDisposed ();
  104. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  105. ximgproc_ContourFitting_setCtrSize_10(nativeObj, n);
  106. return;
  107. #else
  108. return;
  109. #endif
  110. }
  111. //
  112. // C++: void cv::ximgproc::ContourFitting::setFDSize(int n)
  113. //
  114. //javadoc: ContourFitting::setFDSize(n)
  115. public void setFDSize (int n)
  116. {
  117. ThrowIfDisposed ();
  118. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  119. ximgproc_ContourFitting_setFDSize_10(nativeObj, n);
  120. return;
  121. #else
  122. return;
  123. #endif
  124. }
  125. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  126. const string LIBNAME = "__Internal";
  127. #else
  128. const string LIBNAME = "opencvforunity";
  129. #endif
  130. // C++: int cv::ximgproc::ContourFitting::getCtrSize()
  131. [DllImport (LIBNAME)]
  132. private static extern int ximgproc_ContourFitting_getCtrSize_10 (IntPtr nativeObj);
  133. // C++: int cv::ximgproc::ContourFitting::getFDSize()
  134. [DllImport (LIBNAME)]
  135. private static extern int ximgproc_ContourFitting_getFDSize_10 (IntPtr nativeObj);
  136. // C++: void cv::ximgproc::ContourFitting::estimateTransformation(Mat src, Mat dst, Mat& alphaPhiST, double& dist, bool fdContour = false)
  137. [DllImport (LIBNAME)]
  138. private static extern void ximgproc_ContourFitting_estimateTransformation_10 (IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr alphaPhiST_nativeObj, double[] dist_out, bool fdContour);
  139. [DllImport (LIBNAME)]
  140. private static extern void ximgproc_ContourFitting_estimateTransformation_11 (IntPtr nativeObj, IntPtr src_nativeObj, IntPtr dst_nativeObj, IntPtr alphaPhiST_nativeObj, double[] dist_out);
  141. // C++: void cv::ximgproc::ContourFitting::setCtrSize(int n)
  142. [DllImport (LIBNAME)]
  143. private static extern void ximgproc_ContourFitting_setCtrSize_10 (IntPtr nativeObj, int n);
  144. // C++: void cv::ximgproc::ContourFitting::setFDSize(int n)
  145. [DllImport (LIBNAME)]
  146. private static extern void ximgproc_ContourFitting_setFDSize_10 (IntPtr nativeObj, int n);
  147. // native support for java finalize()
  148. [DllImport (LIBNAME)]
  149. private static extern void ximgproc_ContourFitting_delete (IntPtr nativeObj);
  150. }
  151. }