LineSegmentDetector.cs 7.4 KB

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