LBPHFaceRecognizer.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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.FaceModule {
  8. // C++: class LBPHFaceRecognizer
  9. //javadoc: LBPHFaceRecognizer
  10. public class LBPHFaceRecognizer : FaceRecognizer {
  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. face_LBPHFaceRecognizer_delete(nativeObj);
  19. nativeObj = IntPtr.Zero;
  20. }
  21. } finally {
  22. base.Dispose(disposing);
  23. }
  24. #else
  25. return;
  26. #endif
  27. }
  28. protected internal LBPHFaceRecognizer(IntPtr addr) : base(addr) { }
  29. // internal usage only
  30. public static new LBPHFaceRecognizer __fromPtr__(IntPtr addr) { return new LBPHFaceRecognizer(addr); }
  31. //
  32. // C++: Mat cv::face::LBPHFaceRecognizer::getLabels()
  33. //
  34. //javadoc: LBPHFaceRecognizer::getLabels()
  35. public Mat getLabels() {
  36. ThrowIfDisposed();
  37. #if (UNITY_ANDROID && !UNITY_EDITOR)
  38. Mat retVal = new Mat(face_LBPHFaceRecognizer_getLabels_10(nativeObj));
  39. return retVal;
  40. #else
  41. return null;
  42. #endif
  43. }
  44. //
  45. // C++: static Ptr_LBPHFaceRecognizer cv::face::LBPHFaceRecognizer::create(int radius = 1, int neighbors = 8, int grid_x = 8, int grid_y = 8, double threshold = DBL_MAX)
  46. //
  47. //javadoc: LBPHFaceRecognizer::create(radius, neighbors, grid_x, grid_y, threshold)
  48. public static LBPHFaceRecognizer create(int radius, int neighbors, int grid_x, int grid_y, double threshold) {
  49. #if (UNITY_ANDROID && !UNITY_EDITOR)
  50. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_10(radius, neighbors, grid_x, grid_y, threshold));
  51. return retVal;
  52. #else
  53. return null;
  54. #endif
  55. }
  56. //javadoc: LBPHFaceRecognizer::create(radius, neighbors, grid_x, grid_y)
  57. public static LBPHFaceRecognizer create(int radius, int neighbors, int grid_x, int grid_y) {
  58. #if (UNITY_ANDROID && !UNITY_EDITOR)
  59. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_11(radius, neighbors, grid_x, grid_y));
  60. return retVal;
  61. #else
  62. return null;
  63. #endif
  64. }
  65. //javadoc: LBPHFaceRecognizer::create(radius, neighbors, grid_x)
  66. public static LBPHFaceRecognizer create(int radius, int neighbors, int grid_x) {
  67. #if (UNITY_ANDROID && !UNITY_EDITOR)
  68. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_12(radius, neighbors, grid_x));
  69. return retVal;
  70. #else
  71. return null;
  72. #endif
  73. }
  74. //javadoc: LBPHFaceRecognizer::create(radius, neighbors)
  75. public static LBPHFaceRecognizer create(int radius, int neighbors) {
  76. #if (UNITY_ANDROID && !UNITY_EDITOR)
  77. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_13(radius, neighbors));
  78. return retVal;
  79. #else
  80. return null;
  81. #endif
  82. }
  83. //javadoc: LBPHFaceRecognizer::create(radius)
  84. public static LBPHFaceRecognizer create(int radius) {
  85. #if (UNITY_ANDROID && !UNITY_EDITOR)
  86. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_14(radius));
  87. return retVal;
  88. #else
  89. return null;
  90. #endif
  91. }
  92. //javadoc: LBPHFaceRecognizer::create()
  93. public static LBPHFaceRecognizer create() {
  94. #if (UNITY_ANDROID && !UNITY_EDITOR)
  95. LBPHFaceRecognizer retVal = LBPHFaceRecognizer.__fromPtr__(face_LBPHFaceRecognizer_create_15());
  96. return retVal;
  97. #else
  98. return null;
  99. #endif
  100. }
  101. //
  102. // C++: double cv::face::LBPHFaceRecognizer::getThreshold()
  103. //
  104. //javadoc: LBPHFaceRecognizer::getThreshold()
  105. public double getThreshold() {
  106. ThrowIfDisposed();
  107. #if (UNITY_ANDROID && !UNITY_EDITOR)
  108. double retVal = face_LBPHFaceRecognizer_getThreshold_10(nativeObj);
  109. return retVal;
  110. #else
  111. return -1;
  112. #endif
  113. }
  114. //
  115. // C++: int cv::face::LBPHFaceRecognizer::getGridX()
  116. //
  117. //javadoc: LBPHFaceRecognizer::getGridX()
  118. public int getGridX() {
  119. ThrowIfDisposed();
  120. #if (UNITY_ANDROID && !UNITY_EDITOR)
  121. int retVal = face_LBPHFaceRecognizer_getGridX_10(nativeObj);
  122. return retVal;
  123. #else
  124. return -1;
  125. #endif
  126. }
  127. //
  128. // C++: int cv::face::LBPHFaceRecognizer::getGridY()
  129. //
  130. //javadoc: LBPHFaceRecognizer::getGridY()
  131. public int getGridY() {
  132. ThrowIfDisposed();
  133. #if (UNITY_ANDROID && !UNITY_EDITOR)
  134. int retVal = face_LBPHFaceRecognizer_getGridY_10(nativeObj);
  135. return retVal;
  136. #else
  137. return -1;
  138. #endif
  139. }
  140. //
  141. // C++: int cv::face::LBPHFaceRecognizer::getNeighbors()
  142. //
  143. //javadoc: LBPHFaceRecognizer::getNeighbors()
  144. public int getNeighbors() {
  145. ThrowIfDisposed();
  146. #if (UNITY_ANDROID && !UNITY_EDITOR)
  147. int retVal = face_LBPHFaceRecognizer_getNeighbors_10(nativeObj);
  148. return retVal;
  149. #else
  150. return -1;
  151. #endif
  152. }
  153. //
  154. // C++: int cv::face::LBPHFaceRecognizer::getRadius()
  155. //
  156. //javadoc: LBPHFaceRecognizer::getRadius()
  157. public int getRadius() {
  158. ThrowIfDisposed();
  159. #if (UNITY_ANDROID && !UNITY_EDITOR)
  160. int retVal = face_LBPHFaceRecognizer_getRadius_10(nativeObj);
  161. return retVal;
  162. #else
  163. return -1;
  164. #endif
  165. }
  166. //
  167. // C++: vector_Mat cv::face::LBPHFaceRecognizer::getHistograms()
  168. //
  169. //javadoc: LBPHFaceRecognizer::getHistograms()
  170. public List<Mat> getHistograms() {
  171. ThrowIfDisposed();
  172. #if (UNITY_ANDROID && !UNITY_EDITOR)
  173. List<Mat> retVal = new List<Mat>();
  174. Mat retValMat = new Mat(face_LBPHFaceRecognizer_getHistograms_10(nativeObj));
  175. Converters.Mat_to_vector_Mat(retValMat, retVal);
  176. return retVal;
  177. #else
  178. return null;
  179. #endif
  180. }
  181. //
  182. // C++: void cv::face::LBPHFaceRecognizer::setGridX(int val)
  183. //
  184. //javadoc: LBPHFaceRecognizer::setGridX(val)
  185. public void setGridX(int val) {
  186. ThrowIfDisposed();
  187. #if (UNITY_ANDROID && !UNITY_EDITOR)
  188. face_LBPHFaceRecognizer_setGridX_10(nativeObj, val);
  189. return;
  190. #else
  191. return;
  192. #endif
  193. }
  194. //
  195. // C++: void cv::face::LBPHFaceRecognizer::setGridY(int val)
  196. //
  197. //javadoc: LBPHFaceRecognizer::setGridY(val)
  198. public void setGridY(int val) {
  199. ThrowIfDisposed();
  200. #if (UNITY_ANDROID && !UNITY_EDITOR)
  201. face_LBPHFaceRecognizer_setGridY_10(nativeObj, val);
  202. return;
  203. #else
  204. return;
  205. #endif
  206. }
  207. //
  208. // C++: void cv::face::LBPHFaceRecognizer::setNeighbors(int val)
  209. //
  210. //javadoc: LBPHFaceRecognizer::setNeighbors(val)
  211. public void setNeighbors(int val) {
  212. ThrowIfDisposed();
  213. #if (UNITY_ANDROID && !UNITY_EDITOR)
  214. face_LBPHFaceRecognizer_setNeighbors_10(nativeObj, val);
  215. return;
  216. #else
  217. return;
  218. #endif
  219. }
  220. //
  221. // C++: void cv::face::LBPHFaceRecognizer::setRadius(int val)
  222. //
  223. //javadoc: LBPHFaceRecognizer::setRadius(val)
  224. public void setRadius(int val) {
  225. ThrowIfDisposed();
  226. #if (UNITY_ANDROID && !UNITY_EDITOR)
  227. face_LBPHFaceRecognizer_setRadius_10(nativeObj, val);
  228. return;
  229. #else
  230. return;
  231. #endif
  232. }
  233. //
  234. // C++: void cv::face::LBPHFaceRecognizer::setThreshold(double val)
  235. //
  236. //javadoc: LBPHFaceRecognizer::setThreshold(val)
  237. public void setThreshold(double val) {
  238. ThrowIfDisposed();
  239. #if (UNITY_ANDROID && !UNITY_EDITOR)
  240. face_LBPHFaceRecognizer_setThreshold_10(nativeObj, val);
  241. return;
  242. #else
  243. return;
  244. #endif
  245. }
  246. #if (UNITY_ANDROID && !UNITY_EDITOR)
  247. const string LIBNAME = "opencvforunity";
  248. // C++: Mat cv::face::LBPHFaceRecognizer::getLabels()
  249. [DllImport(LIBNAME)]
  250. private static extern IntPtr face_LBPHFaceRecognizer_getLabels_10(IntPtr nativeObj);
  251. // C++: static Ptr_LBPHFaceRecognizer cv::face::LBPHFaceRecognizer::create(int radius = 1, int neighbors = 8, int grid_x = 8, int grid_y = 8, double threshold = DBL_MAX)
  252. [DllImport(LIBNAME)]
  253. private static extern IntPtr face_LBPHFaceRecognizer_create_10(int radius, int neighbors, int grid_x, int grid_y, double threshold);
  254. [DllImport(LIBNAME)]
  255. private static extern IntPtr face_LBPHFaceRecognizer_create_11(int radius, int neighbors, int grid_x, int grid_y);
  256. [DllImport(LIBNAME)]
  257. private static extern IntPtr face_LBPHFaceRecognizer_create_12(int radius, int neighbors, int grid_x);
  258. [DllImport(LIBNAME)]
  259. private static extern IntPtr face_LBPHFaceRecognizer_create_13(int radius, int neighbors);
  260. [DllImport(LIBNAME)]
  261. private static extern IntPtr face_LBPHFaceRecognizer_create_14(int radius);
  262. [DllImport(LIBNAME)]
  263. private static extern IntPtr face_LBPHFaceRecognizer_create_15();
  264. // C++: double cv::face::LBPHFaceRecognizer::getThreshold()
  265. [DllImport(LIBNAME)]
  266. private static extern double face_LBPHFaceRecognizer_getThreshold_10(IntPtr nativeObj);
  267. // C++: int cv::face::LBPHFaceRecognizer::getGridX()
  268. [DllImport(LIBNAME)]
  269. private static extern int face_LBPHFaceRecognizer_getGridX_10(IntPtr nativeObj);
  270. // C++: int cv::face::LBPHFaceRecognizer::getGridY()
  271. [DllImport(LIBNAME)]
  272. private static extern int face_LBPHFaceRecognizer_getGridY_10(IntPtr nativeObj);
  273. // C++: int cv::face::LBPHFaceRecognizer::getNeighbors()
  274. [DllImport(LIBNAME)]
  275. private static extern int face_LBPHFaceRecognizer_getNeighbors_10(IntPtr nativeObj);
  276. // C++: int cv::face::LBPHFaceRecognizer::getRadius()
  277. [DllImport(LIBNAME)]
  278. private static extern int face_LBPHFaceRecognizer_getRadius_10(IntPtr nativeObj);
  279. // C++: vector_Mat cv::face::LBPHFaceRecognizer::getHistograms()
  280. [DllImport(LIBNAME)]
  281. private static extern IntPtr face_LBPHFaceRecognizer_getHistograms_10(IntPtr nativeObj);
  282. // C++: void cv::face::LBPHFaceRecognizer::setGridX(int val)
  283. [DllImport(LIBNAME)]
  284. private static extern void face_LBPHFaceRecognizer_setGridX_10(IntPtr nativeObj, int val);
  285. // C++: void cv::face::LBPHFaceRecognizer::setGridY(int val)
  286. [DllImport(LIBNAME)]
  287. private static extern void face_LBPHFaceRecognizer_setGridY_10(IntPtr nativeObj, int val);
  288. // C++: void cv::face::LBPHFaceRecognizer::setNeighbors(int val)
  289. [DllImport(LIBNAME)]
  290. private static extern void face_LBPHFaceRecognizer_setNeighbors_10(IntPtr nativeObj, int val);
  291. // C++: void cv::face::LBPHFaceRecognizer::setRadius(int val)
  292. [DllImport(LIBNAME)]
  293. private static extern void face_LBPHFaceRecognizer_setRadius_10(IntPtr nativeObj, int val);
  294. // C++: void cv::face::LBPHFaceRecognizer::setThreshold(double val)
  295. [DllImport(LIBNAME)]
  296. private static extern void face_LBPHFaceRecognizer_setThreshold_10(IntPtr nativeObj, double val);
  297. // native support for java finalize()
  298. [DllImport(LIBNAME)]
  299. private static extern void face_LBPHFaceRecognizer_delete(IntPtr nativeObj);
  300. #endif
  301. }
  302. }