GeneralizedHough.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.ImgprocModule
  7. {
  8. // C++: class GeneralizedHough
  9. /**
  10. * finds arbitrary template in the grayscale image using Generalized Hough Transform
  11. */
  12. public class GeneralizedHough : Algorithm
  13. {
  14. protected override void Dispose(bool disposing)
  15. {
  16. try
  17. {
  18. if (disposing)
  19. {
  20. }
  21. if (IsEnabledDispose)
  22. {
  23. if (nativeObj != IntPtr.Zero)
  24. imgproc_GeneralizedHough_delete(nativeObj);
  25. nativeObj = IntPtr.Zero;
  26. }
  27. }
  28. finally
  29. {
  30. base.Dispose(disposing);
  31. }
  32. }
  33. protected internal GeneralizedHough(IntPtr addr) : base(addr) { }
  34. // internal usage only
  35. public static new GeneralizedHough __fromPtr__(IntPtr addr) { return new GeneralizedHough(addr); }
  36. //
  37. // C++: void cv::GeneralizedHough::setTemplate(Mat templ, Point templCenter = Point(-1, -1))
  38. //
  39. public void setTemplate(Mat templ, Point templCenter)
  40. {
  41. ThrowIfDisposed();
  42. if (templ != null) templ.ThrowIfDisposed();
  43. imgproc_GeneralizedHough_setTemplate_10(nativeObj, templ.nativeObj, templCenter.x, templCenter.y);
  44. }
  45. public void setTemplate(Mat templ)
  46. {
  47. ThrowIfDisposed();
  48. if (templ != null) templ.ThrowIfDisposed();
  49. imgproc_GeneralizedHough_setTemplate_11(nativeObj, templ.nativeObj);
  50. }
  51. //
  52. // C++: void cv::GeneralizedHough::setTemplate(Mat edges, Mat dx, Mat dy, Point templCenter = Point(-1, -1))
  53. //
  54. public void setTemplate(Mat edges, Mat dx, Mat dy, Point templCenter)
  55. {
  56. ThrowIfDisposed();
  57. if (edges != null) edges.ThrowIfDisposed();
  58. if (dx != null) dx.ThrowIfDisposed();
  59. if (dy != null) dy.ThrowIfDisposed();
  60. imgproc_GeneralizedHough_setTemplate_12(nativeObj, edges.nativeObj, dx.nativeObj, dy.nativeObj, templCenter.x, templCenter.y);
  61. }
  62. public void setTemplate(Mat edges, Mat dx, Mat dy)
  63. {
  64. ThrowIfDisposed();
  65. if (edges != null) edges.ThrowIfDisposed();
  66. if (dx != null) dx.ThrowIfDisposed();
  67. if (dy != null) dy.ThrowIfDisposed();
  68. imgproc_GeneralizedHough_setTemplate_13(nativeObj, edges.nativeObj, dx.nativeObj, dy.nativeObj);
  69. }
  70. //
  71. // C++: void cv::GeneralizedHough::detect(Mat image, Mat& positions, Mat& votes = Mat())
  72. //
  73. public void detect(Mat image, Mat positions, Mat votes)
  74. {
  75. ThrowIfDisposed();
  76. if (image != null) image.ThrowIfDisposed();
  77. if (positions != null) positions.ThrowIfDisposed();
  78. if (votes != null) votes.ThrowIfDisposed();
  79. imgproc_GeneralizedHough_detect_10(nativeObj, image.nativeObj, positions.nativeObj, votes.nativeObj);
  80. }
  81. public void detect(Mat image, Mat positions)
  82. {
  83. ThrowIfDisposed();
  84. if (image != null) image.ThrowIfDisposed();
  85. if (positions != null) positions.ThrowIfDisposed();
  86. imgproc_GeneralizedHough_detect_11(nativeObj, image.nativeObj, positions.nativeObj);
  87. }
  88. //
  89. // C++: void cv::GeneralizedHough::detect(Mat edges, Mat dx, Mat dy, Mat& positions, Mat& votes = Mat())
  90. //
  91. public void detect(Mat edges, Mat dx, Mat dy, Mat positions, Mat votes)
  92. {
  93. ThrowIfDisposed();
  94. if (edges != null) edges.ThrowIfDisposed();
  95. if (dx != null) dx.ThrowIfDisposed();
  96. if (dy != null) dy.ThrowIfDisposed();
  97. if (positions != null) positions.ThrowIfDisposed();
  98. if (votes != null) votes.ThrowIfDisposed();
  99. imgproc_GeneralizedHough_detect_12(nativeObj, edges.nativeObj, dx.nativeObj, dy.nativeObj, positions.nativeObj, votes.nativeObj);
  100. }
  101. public void detect(Mat edges, Mat dx, Mat dy, Mat positions)
  102. {
  103. ThrowIfDisposed();
  104. if (edges != null) edges.ThrowIfDisposed();
  105. if (dx != null) dx.ThrowIfDisposed();
  106. if (dy != null) dy.ThrowIfDisposed();
  107. if (positions != null) positions.ThrowIfDisposed();
  108. imgproc_GeneralizedHough_detect_13(nativeObj, edges.nativeObj, dx.nativeObj, dy.nativeObj, positions.nativeObj);
  109. }
  110. //
  111. // C++: void cv::GeneralizedHough::setCannyLowThresh(int cannyLowThresh)
  112. //
  113. public void setCannyLowThresh(int cannyLowThresh)
  114. {
  115. ThrowIfDisposed();
  116. imgproc_GeneralizedHough_setCannyLowThresh_10(nativeObj, cannyLowThresh);
  117. }
  118. //
  119. // C++: int cv::GeneralizedHough::getCannyLowThresh()
  120. //
  121. public int getCannyLowThresh()
  122. {
  123. ThrowIfDisposed();
  124. return imgproc_GeneralizedHough_getCannyLowThresh_10(nativeObj);
  125. }
  126. //
  127. // C++: void cv::GeneralizedHough::setCannyHighThresh(int cannyHighThresh)
  128. //
  129. public void setCannyHighThresh(int cannyHighThresh)
  130. {
  131. ThrowIfDisposed();
  132. imgproc_GeneralizedHough_setCannyHighThresh_10(nativeObj, cannyHighThresh);
  133. }
  134. //
  135. // C++: int cv::GeneralizedHough::getCannyHighThresh()
  136. //
  137. public int getCannyHighThresh()
  138. {
  139. ThrowIfDisposed();
  140. return imgproc_GeneralizedHough_getCannyHighThresh_10(nativeObj);
  141. }
  142. //
  143. // C++: void cv::GeneralizedHough::setMinDist(double minDist)
  144. //
  145. public void setMinDist(double minDist)
  146. {
  147. ThrowIfDisposed();
  148. imgproc_GeneralizedHough_setMinDist_10(nativeObj, minDist);
  149. }
  150. //
  151. // C++: double cv::GeneralizedHough::getMinDist()
  152. //
  153. public double getMinDist()
  154. {
  155. ThrowIfDisposed();
  156. return imgproc_GeneralizedHough_getMinDist_10(nativeObj);
  157. }
  158. //
  159. // C++: void cv::GeneralizedHough::setDp(double dp)
  160. //
  161. public void setDp(double dp)
  162. {
  163. ThrowIfDisposed();
  164. imgproc_GeneralizedHough_setDp_10(nativeObj, dp);
  165. }
  166. //
  167. // C++: double cv::GeneralizedHough::getDp()
  168. //
  169. public double getDp()
  170. {
  171. ThrowIfDisposed();
  172. return imgproc_GeneralizedHough_getDp_10(nativeObj);
  173. }
  174. //
  175. // C++: void cv::GeneralizedHough::setMaxBufferSize(int maxBufferSize)
  176. //
  177. public void setMaxBufferSize(int maxBufferSize)
  178. {
  179. ThrowIfDisposed();
  180. imgproc_GeneralizedHough_setMaxBufferSize_10(nativeObj, maxBufferSize);
  181. }
  182. //
  183. // C++: int cv::GeneralizedHough::getMaxBufferSize()
  184. //
  185. public int getMaxBufferSize()
  186. {
  187. ThrowIfDisposed();
  188. return imgproc_GeneralizedHough_getMaxBufferSize_10(nativeObj);
  189. }
  190. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  191. const string LIBNAME = "__Internal";
  192. #else
  193. const string LIBNAME = "opencvforunity";
  194. #endif
  195. // C++: void cv::GeneralizedHough::setTemplate(Mat templ, Point templCenter = Point(-1, -1))
  196. [DllImport(LIBNAME)]
  197. private static extern void imgproc_GeneralizedHough_setTemplate_10(IntPtr nativeObj, IntPtr templ_nativeObj, double templCenter_x, double templCenter_y);
  198. [DllImport(LIBNAME)]
  199. private static extern void imgproc_GeneralizedHough_setTemplate_11(IntPtr nativeObj, IntPtr templ_nativeObj);
  200. // C++: void cv::GeneralizedHough::setTemplate(Mat edges, Mat dx, Mat dy, Point templCenter = Point(-1, -1))
  201. [DllImport(LIBNAME)]
  202. private static extern void imgproc_GeneralizedHough_setTemplate_12(IntPtr nativeObj, IntPtr edges_nativeObj, IntPtr dx_nativeObj, IntPtr dy_nativeObj, double templCenter_x, double templCenter_y);
  203. [DllImport(LIBNAME)]
  204. private static extern void imgproc_GeneralizedHough_setTemplate_13(IntPtr nativeObj, IntPtr edges_nativeObj, IntPtr dx_nativeObj, IntPtr dy_nativeObj);
  205. // C++: void cv::GeneralizedHough::detect(Mat image, Mat& positions, Mat& votes = Mat())
  206. [DllImport(LIBNAME)]
  207. private static extern void imgproc_GeneralizedHough_detect_10(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr positions_nativeObj, IntPtr votes_nativeObj);
  208. [DllImport(LIBNAME)]
  209. private static extern void imgproc_GeneralizedHough_detect_11(IntPtr nativeObj, IntPtr image_nativeObj, IntPtr positions_nativeObj);
  210. // C++: void cv::GeneralizedHough::detect(Mat edges, Mat dx, Mat dy, Mat& positions, Mat& votes = Mat())
  211. [DllImport(LIBNAME)]
  212. private static extern void imgproc_GeneralizedHough_detect_12(IntPtr nativeObj, IntPtr edges_nativeObj, IntPtr dx_nativeObj, IntPtr dy_nativeObj, IntPtr positions_nativeObj, IntPtr votes_nativeObj);
  213. [DllImport(LIBNAME)]
  214. private static extern void imgproc_GeneralizedHough_detect_13(IntPtr nativeObj, IntPtr edges_nativeObj, IntPtr dx_nativeObj, IntPtr dy_nativeObj, IntPtr positions_nativeObj);
  215. // C++: void cv::GeneralizedHough::setCannyLowThresh(int cannyLowThresh)
  216. [DllImport(LIBNAME)]
  217. private static extern void imgproc_GeneralizedHough_setCannyLowThresh_10(IntPtr nativeObj, int cannyLowThresh);
  218. // C++: int cv::GeneralizedHough::getCannyLowThresh()
  219. [DllImport(LIBNAME)]
  220. private static extern int imgproc_GeneralizedHough_getCannyLowThresh_10(IntPtr nativeObj);
  221. // C++: void cv::GeneralizedHough::setCannyHighThresh(int cannyHighThresh)
  222. [DllImport(LIBNAME)]
  223. private static extern void imgproc_GeneralizedHough_setCannyHighThresh_10(IntPtr nativeObj, int cannyHighThresh);
  224. // C++: int cv::GeneralizedHough::getCannyHighThresh()
  225. [DllImport(LIBNAME)]
  226. private static extern int imgproc_GeneralizedHough_getCannyHighThresh_10(IntPtr nativeObj);
  227. // C++: void cv::GeneralizedHough::setMinDist(double minDist)
  228. [DllImport(LIBNAME)]
  229. private static extern void imgproc_GeneralizedHough_setMinDist_10(IntPtr nativeObj, double minDist);
  230. // C++: double cv::GeneralizedHough::getMinDist()
  231. [DllImport(LIBNAME)]
  232. private static extern double imgproc_GeneralizedHough_getMinDist_10(IntPtr nativeObj);
  233. // C++: void cv::GeneralizedHough::setDp(double dp)
  234. [DllImport(LIBNAME)]
  235. private static extern void imgproc_GeneralizedHough_setDp_10(IntPtr nativeObj, double dp);
  236. // C++: double cv::GeneralizedHough::getDp()
  237. [DllImport(LIBNAME)]
  238. private static extern double imgproc_GeneralizedHough_getDp_10(IntPtr nativeObj);
  239. // C++: void cv::GeneralizedHough::setMaxBufferSize(int maxBufferSize)
  240. [DllImport(LIBNAME)]
  241. private static extern void imgproc_GeneralizedHough_setMaxBufferSize_10(IntPtr nativeObj, int maxBufferSize);
  242. // C++: int cv::GeneralizedHough::getMaxBufferSize()
  243. [DllImport(LIBNAME)]
  244. private static extern int imgproc_GeneralizedHough_getMaxBufferSize_10(IntPtr nativeObj);
  245. // native support for java finalize()
  246. [DllImport(LIBNAME)]
  247. private static extern void imgproc_GeneralizedHough_delete(IntPtr nativeObj);
  248. }
  249. }