LineSegmentDetector.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.ImgprocModule
  8. {
  9. // C++: class LineSegmentDetector
  10. //javadoc: LineSegmentDetector
  11. public class LineSegmentDetector : 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. imgproc_LineSegmentDetector_delete(nativeObj);
  22. nativeObj = IntPtr.Zero;
  23. }
  24. } finally {
  25. base.Dispose (disposing);
  26. }
  27. #else
  28. return;
  29. #endif
  30. }
  31. protected internal LineSegmentDetector (IntPtr addr) : base (addr) { }
  32. // internal usage only
  33. public static new LineSegmentDetector __fromPtr__ (IntPtr addr) { return new LineSegmentDetector (addr); }
  34. //
  35. // C++: int cv::LineSegmentDetector::compareSegments(Size size, Mat lines1, Mat lines2, Mat& _image = Mat())
  36. //
  37. //javadoc: LineSegmentDetector::compareSegments(size, lines1, lines2, _image)
  38. public int compareSegments (Size size, Mat lines1, Mat lines2, Mat _image)
  39. {
  40. ThrowIfDisposed ();
  41. if (lines1 != null) lines1.ThrowIfDisposed ();
  42. if (lines2 != null) lines2.ThrowIfDisposed ();
  43. if (_image != null) _image.ThrowIfDisposed ();
  44. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  45. int retVal = imgproc_LineSegmentDetector_compareSegments_10(nativeObj, size.width, size.height, lines1.nativeObj, lines2.nativeObj, _image.nativeObj);
  46. return retVal;
  47. #else
  48. return -1;
  49. #endif
  50. }
  51. //javadoc: LineSegmentDetector::compareSegments(size, lines1, lines2)
  52. public int compareSegments (Size size, Mat lines1, Mat lines2)
  53. {
  54. ThrowIfDisposed ();
  55. if (lines1 != null) lines1.ThrowIfDisposed ();
  56. if (lines2 != null) lines2.ThrowIfDisposed ();
  57. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  58. int retVal = imgproc_LineSegmentDetector_compareSegments_11(nativeObj, size.width, size.height, lines1.nativeObj, lines2.nativeObj);
  59. return retVal;
  60. #else
  61. return -1;
  62. #endif
  63. }
  64. //
  65. // C++: void cv::LineSegmentDetector::detect(Mat _image, Mat& _lines, Mat& width = Mat(), Mat& prec = Mat(), Mat& nfa = Mat())
  66. //
  67. //javadoc: LineSegmentDetector::detect(_image, _lines, width, prec, nfa)
  68. public void detect (Mat _image, Mat _lines, Mat width, Mat prec, Mat nfa)
  69. {
  70. ThrowIfDisposed ();
  71. if (_image != null) _image.ThrowIfDisposed ();
  72. if (_lines != null) _lines.ThrowIfDisposed ();
  73. if (width != null) width.ThrowIfDisposed ();
  74. if (prec != null) prec.ThrowIfDisposed ();
  75. if (nfa != null) nfa.ThrowIfDisposed ();
  76. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  77. imgproc_LineSegmentDetector_detect_10(nativeObj, _image.nativeObj, _lines.nativeObj, width.nativeObj, prec.nativeObj, nfa.nativeObj);
  78. return;
  79. #else
  80. return;
  81. #endif
  82. }
  83. //javadoc: LineSegmentDetector::detect(_image, _lines, width, prec)
  84. public void detect (Mat _image, Mat _lines, Mat width, Mat prec)
  85. {
  86. ThrowIfDisposed ();
  87. if (_image != null) _image.ThrowIfDisposed ();
  88. if (_lines != null) _lines.ThrowIfDisposed ();
  89. if (width != null) width.ThrowIfDisposed ();
  90. if (prec != null) prec.ThrowIfDisposed ();
  91. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  92. imgproc_LineSegmentDetector_detect_11(nativeObj, _image.nativeObj, _lines.nativeObj, width.nativeObj, prec.nativeObj);
  93. return;
  94. #else
  95. return;
  96. #endif
  97. }
  98. //javadoc: LineSegmentDetector::detect(_image, _lines, width)
  99. public void detect (Mat _image, Mat _lines, Mat width)
  100. {
  101. ThrowIfDisposed ();
  102. if (_image != null) _image.ThrowIfDisposed ();
  103. if (_lines != null) _lines.ThrowIfDisposed ();
  104. if (width != null) width.ThrowIfDisposed ();
  105. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  106. imgproc_LineSegmentDetector_detect_12(nativeObj, _image.nativeObj, _lines.nativeObj, width.nativeObj);
  107. return;
  108. #else
  109. return;
  110. #endif
  111. }
  112. //javadoc: LineSegmentDetector::detect(_image, _lines)
  113. public void detect (Mat _image, Mat _lines)
  114. {
  115. ThrowIfDisposed ();
  116. if (_image != null) _image.ThrowIfDisposed ();
  117. if (_lines != null) _lines.ThrowIfDisposed ();
  118. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  119. imgproc_LineSegmentDetector_detect_13(nativeObj, _image.nativeObj, _lines.nativeObj);
  120. return;
  121. #else
  122. return;
  123. #endif
  124. }
  125. //
  126. // C++: void cv::LineSegmentDetector::drawSegments(Mat& _image, Mat lines)
  127. //
  128. //javadoc: LineSegmentDetector::drawSegments(_image, lines)
  129. public void drawSegments (Mat _image, Mat lines)
  130. {
  131. ThrowIfDisposed ();
  132. if (_image != null) _image.ThrowIfDisposed ();
  133. if (lines != null) lines.ThrowIfDisposed ();
  134. #if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
  135. imgproc_LineSegmentDetector_drawSegments_10(nativeObj, _image.nativeObj, lines.nativeObj);
  136. return;
  137. #else
  138. return;
  139. #endif
  140. }
  141. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  142. const string LIBNAME = "__Internal";
  143. #else
  144. const string LIBNAME = "opencvforunity";
  145. #endif
  146. // C++: int cv::LineSegmentDetector::compareSegments(Size size, Mat lines1, Mat lines2, Mat& _image = Mat())
  147. [DllImport (LIBNAME)]
  148. private static extern int imgproc_LineSegmentDetector_compareSegments_10 (IntPtr nativeObj, double size_width, double size_height, IntPtr lines1_nativeObj, IntPtr lines2_nativeObj, IntPtr _image_nativeObj);
  149. [DllImport (LIBNAME)]
  150. private static extern int imgproc_LineSegmentDetector_compareSegments_11 (IntPtr nativeObj, double size_width, double size_height, IntPtr lines1_nativeObj, IntPtr lines2_nativeObj);
  151. // C++: void cv::LineSegmentDetector::detect(Mat _image, Mat& _lines, Mat& width = Mat(), Mat& prec = Mat(), Mat& nfa = Mat())
  152. [DllImport (LIBNAME)]
  153. private static extern void imgproc_LineSegmentDetector_detect_10 (IntPtr nativeObj, IntPtr _image_nativeObj, IntPtr _lines_nativeObj, IntPtr width_nativeObj, IntPtr prec_nativeObj, IntPtr nfa_nativeObj);
  154. [DllImport (LIBNAME)]
  155. private static extern void imgproc_LineSegmentDetector_detect_11 (IntPtr nativeObj, IntPtr _image_nativeObj, IntPtr _lines_nativeObj, IntPtr width_nativeObj, IntPtr prec_nativeObj);
  156. [DllImport (LIBNAME)]
  157. private static extern void imgproc_LineSegmentDetector_detect_12 (IntPtr nativeObj, IntPtr _image_nativeObj, IntPtr _lines_nativeObj, IntPtr width_nativeObj);
  158. [DllImport (LIBNAME)]
  159. private static extern void imgproc_LineSegmentDetector_detect_13 (IntPtr nativeObj, IntPtr _image_nativeObj, IntPtr _lines_nativeObj);
  160. // C++: void cv::LineSegmentDetector::drawSegments(Mat& _image, Mat lines)
  161. [DllImport (LIBNAME)]
  162. private static extern void imgproc_LineSegmentDetector_drawSegments_10 (IntPtr nativeObj, IntPtr _image_nativeObj, IntPtr lines_nativeObj);
  163. // native support for java finalize()
  164. [DllImport (LIBNAME)]
  165. private static extern void imgproc_LineSegmentDetector_delete (IntPtr nativeObj);
  166. }
  167. }