ORB.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. using OpenCVForUnity.CoreModule;
  2. using OpenCVForUnity.UtilsModule;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.InteropServices;
  6. namespace OpenCVForUnity.Features2dModule
  7. {
  8. // C++: class ORB
  9. /**
  10. * Class implementing the ORB (*oriented BRIEF*) keypoint detector and descriptor extractor
  11. *
  12. * described in CITE: RRKB11 . The algorithm uses FAST in pyramids to detect stable keypoints, selects
  13. * the strongest features using FAST or Harris response, finds their orientation using first-order
  14. * moments and computes the descriptors using BRIEF (where the coordinates of random point pairs (or
  15. * k-tuples) are rotated according to the measured orientation).
  16. */
  17. public class ORB : Feature2D
  18. {
  19. protected override void Dispose(bool disposing)
  20. {
  21. try
  22. {
  23. if (disposing)
  24. {
  25. }
  26. if (IsEnabledDispose)
  27. {
  28. if (nativeObj != IntPtr.Zero)
  29. features2d_ORB_delete(nativeObj);
  30. nativeObj = IntPtr.Zero;
  31. }
  32. }
  33. finally
  34. {
  35. base.Dispose(disposing);
  36. }
  37. }
  38. protected internal ORB(IntPtr addr) : base(addr) { }
  39. // internal usage only
  40. public static new ORB __fromPtr__(IntPtr addr) { return new ORB(addr); }
  41. // C++: enum cv.ORB.ScoreType
  42. public const int HARRIS_SCORE = 0;
  43. public const int FAST_SCORE = 1;
  44. //
  45. // C++: static Ptr_ORB cv::ORB::create(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31, int firstLevel = 0, int WTA_K = 2, ORB_ScoreType scoreType = ORB::HARRIS_SCORE, int patchSize = 31, int fastThreshold = 20)
  46. //
  47. /**
  48. * The ORB constructor
  49. *
  50. * param nfeatures The maximum number of features to retain.
  51. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  52. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  53. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  54. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  55. * will suffer.
  56. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  57. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  58. * param edgeThreshold This is size of the border where the features are not detected. It should
  59. * roughly match the patchSize parameter.
  60. * param firstLevel The level of pyramid to put source image to. Previous layers are filled
  61. * with upscaled source image.
  62. * param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The
  63. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  64. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  65. * random points (of course, those point coordinates are random, but they are generated from the
  66. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  67. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  68. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  69. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  70. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  71. * param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features
  72. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  73. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  74. * but it is a little faster to compute.
  75. * param patchSize size of the patch used by the oriented BRIEF descriptor. Of course, on smaller
  76. * pyramid layers the perceived image area covered by a feature will be larger.
  77. * param fastThreshold the fast threshold
  78. * return automatically generated
  79. */
  80. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize, int fastThreshold)
  81. {
  82. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_10(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize, fastThreshold)));
  83. }
  84. /**
  85. * The ORB constructor
  86. *
  87. * param nfeatures The maximum number of features to retain.
  88. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  89. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  90. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  91. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  92. * will suffer.
  93. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  94. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  95. * param edgeThreshold This is size of the border where the features are not detected. It should
  96. * roughly match the patchSize parameter.
  97. * param firstLevel The level of pyramid to put source image to. Previous layers are filled
  98. * with upscaled source image.
  99. * param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The
  100. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  101. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  102. * random points (of course, those point coordinates are random, but they are generated from the
  103. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  104. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  105. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  106. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  107. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  108. * param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features
  109. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  110. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  111. * but it is a little faster to compute.
  112. * param patchSize size of the patch used by the oriented BRIEF descriptor. Of course, on smaller
  113. * pyramid layers the perceived image area covered by a feature will be larger.
  114. * return automatically generated
  115. */
  116. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize)
  117. {
  118. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_11(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType, patchSize)));
  119. }
  120. /**
  121. * The ORB constructor
  122. *
  123. * param nfeatures The maximum number of features to retain.
  124. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  125. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  126. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  127. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  128. * will suffer.
  129. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  130. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  131. * param edgeThreshold This is size of the border where the features are not detected. It should
  132. * roughly match the patchSize parameter.
  133. * param firstLevel The level of pyramid to put source image to. Previous layers are filled
  134. * with upscaled source image.
  135. * param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The
  136. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  137. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  138. * random points (of course, those point coordinates are random, but they are generated from the
  139. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  140. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  141. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  142. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  143. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  144. * param scoreType The default HARRIS_SCORE means that Harris algorithm is used to rank features
  145. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  146. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  147. * but it is a little faster to compute.
  148. * pyramid layers the perceived image area covered by a feature will be larger.
  149. * return automatically generated
  150. */
  151. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType)
  152. {
  153. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_12(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K, scoreType)));
  154. }
  155. /**
  156. * The ORB constructor
  157. *
  158. * param nfeatures The maximum number of features to retain.
  159. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  160. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  161. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  162. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  163. * will suffer.
  164. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  165. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  166. * param edgeThreshold This is size of the border where the features are not detected. It should
  167. * roughly match the patchSize parameter.
  168. * param firstLevel The level of pyramid to put source image to. Previous layers are filled
  169. * with upscaled source image.
  170. * param WTA_K The number of points that produce each element of the oriented BRIEF descriptor. The
  171. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  172. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  173. * random points (of course, those point coordinates are random, but they are generated from the
  174. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  175. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  176. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  177. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  178. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  179. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  180. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  181. * but it is a little faster to compute.
  182. * pyramid layers the perceived image area covered by a feature will be larger.
  183. * return automatically generated
  184. */
  185. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K)
  186. {
  187. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_13(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel, WTA_K)));
  188. }
  189. /**
  190. * The ORB constructor
  191. *
  192. * param nfeatures The maximum number of features to retain.
  193. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  194. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  195. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  196. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  197. * will suffer.
  198. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  199. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  200. * param edgeThreshold This is size of the border where the features are not detected. It should
  201. * roughly match the patchSize parameter.
  202. * param firstLevel The level of pyramid to put source image to. Previous layers are filled
  203. * with upscaled source image.
  204. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  205. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  206. * random points (of course, those point coordinates are random, but they are generated from the
  207. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  208. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  209. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  210. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  211. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  212. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  213. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  214. * but it is a little faster to compute.
  215. * pyramid layers the perceived image area covered by a feature will be larger.
  216. * return automatically generated
  217. */
  218. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel)
  219. {
  220. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_14(nfeatures, scaleFactor, nlevels, edgeThreshold, firstLevel)));
  221. }
  222. /**
  223. * The ORB constructor
  224. *
  225. * param nfeatures The maximum number of features to retain.
  226. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  227. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  228. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  229. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  230. * will suffer.
  231. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  232. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  233. * param edgeThreshold This is size of the border where the features are not detected. It should
  234. * roughly match the patchSize parameter.
  235. * with upscaled source image.
  236. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  237. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  238. * random points (of course, those point coordinates are random, but they are generated from the
  239. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  240. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  241. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  242. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  243. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  244. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  245. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  246. * but it is a little faster to compute.
  247. * pyramid layers the perceived image area covered by a feature will be larger.
  248. * return automatically generated
  249. */
  250. public static ORB create(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold)
  251. {
  252. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_15(nfeatures, scaleFactor, nlevels, edgeThreshold)));
  253. }
  254. /**
  255. * The ORB constructor
  256. *
  257. * param nfeatures The maximum number of features to retain.
  258. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  259. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  260. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  261. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  262. * will suffer.
  263. * param nlevels The number of pyramid levels. The smallest level will have linear size equal to
  264. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  265. * roughly match the patchSize parameter.
  266. * with upscaled source image.
  267. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  268. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  269. * random points (of course, those point coordinates are random, but they are generated from the
  270. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  271. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  272. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  273. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  274. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  275. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  276. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  277. * but it is a little faster to compute.
  278. * pyramid layers the perceived image area covered by a feature will be larger.
  279. * return automatically generated
  280. */
  281. public static ORB create(int nfeatures, float scaleFactor, int nlevels)
  282. {
  283. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_16(nfeatures, scaleFactor, nlevels)));
  284. }
  285. /**
  286. * The ORB constructor
  287. *
  288. * param nfeatures The maximum number of features to retain.
  289. * param scaleFactor Pyramid decimation ratio, greater than 1. scaleFactor==2 means the classical
  290. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  291. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  292. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  293. * will suffer.
  294. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  295. * roughly match the patchSize parameter.
  296. * with upscaled source image.
  297. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  298. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  299. * random points (of course, those point coordinates are random, but they are generated from the
  300. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  301. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  302. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  303. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  304. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  305. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  306. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  307. * but it is a little faster to compute.
  308. * pyramid layers the perceived image area covered by a feature will be larger.
  309. * return automatically generated
  310. */
  311. public static ORB create(int nfeatures, float scaleFactor)
  312. {
  313. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_17(nfeatures, scaleFactor)));
  314. }
  315. /**
  316. * The ORB constructor
  317. *
  318. * param nfeatures The maximum number of features to retain.
  319. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  320. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  321. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  322. * will suffer.
  323. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  324. * roughly match the patchSize parameter.
  325. * with upscaled source image.
  326. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  327. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  328. * random points (of course, those point coordinates are random, but they are generated from the
  329. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  330. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  331. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  332. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  333. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  334. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  335. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  336. * but it is a little faster to compute.
  337. * pyramid layers the perceived image area covered by a feature will be larger.
  338. * return automatically generated
  339. */
  340. public static ORB create(int nfeatures)
  341. {
  342. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_18(nfeatures)));
  343. }
  344. /**
  345. * The ORB constructor
  346. *
  347. * pyramid, where each next level has 4x less pixels than the previous, but such a big scale factor
  348. * will degrade feature matching scores dramatically. On the other hand, too close to 1 scale factor
  349. * will mean that to cover certain scale range you will need more pyramid levels and so the speed
  350. * will suffer.
  351. * input_image_linear_size/pow(scaleFactor, nlevels - firstLevel).
  352. * roughly match the patchSize parameter.
  353. * with upscaled source image.
  354. * default value 2 means the BRIEF where we take a random point pair and compare their brightnesses,
  355. * so we get 0/1 response. Other possible values are 3 and 4. For example, 3 means that we take 3
  356. * random points (of course, those point coordinates are random, but they are generated from the
  357. * pre-defined seed, so each element of BRIEF descriptor is computed deterministically from the pixel
  358. * rectangle), find point of maximum brightness and output index of the winner (0, 1 or 2). Such
  359. * output will occupy 2 bits, and therefore it will need a special variant of Hamming distance,
  360. * denoted as NORM_HAMMING2 (2 bits per bin). When WTA_K=4, we take 4 random points to compute each
  361. * bin (that will also occupy 2 bits with possible values 0, 1, 2 or 3).
  362. * (the score is written to KeyPoint::score and is used to retain best nfeatures features);
  363. * FAST_SCORE is alternative value of the parameter that produces slightly less stable keypoints,
  364. * but it is a little faster to compute.
  365. * pyramid layers the perceived image area covered by a feature will be larger.
  366. * return automatically generated
  367. */
  368. public static ORB create()
  369. {
  370. return ORB.__fromPtr__(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_create_19()));
  371. }
  372. //
  373. // C++: void cv::ORB::setMaxFeatures(int maxFeatures)
  374. //
  375. public void setMaxFeatures(int maxFeatures)
  376. {
  377. ThrowIfDisposed();
  378. features2d_ORB_setMaxFeatures_10(nativeObj, maxFeatures);
  379. }
  380. //
  381. // C++: int cv::ORB::getMaxFeatures()
  382. //
  383. public int getMaxFeatures()
  384. {
  385. ThrowIfDisposed();
  386. return features2d_ORB_getMaxFeatures_10(nativeObj);
  387. }
  388. //
  389. // C++: void cv::ORB::setScaleFactor(double scaleFactor)
  390. //
  391. public void setScaleFactor(double scaleFactor)
  392. {
  393. ThrowIfDisposed();
  394. features2d_ORB_setScaleFactor_10(nativeObj, scaleFactor);
  395. }
  396. //
  397. // C++: double cv::ORB::getScaleFactor()
  398. //
  399. public double getScaleFactor()
  400. {
  401. ThrowIfDisposed();
  402. return features2d_ORB_getScaleFactor_10(nativeObj);
  403. }
  404. //
  405. // C++: void cv::ORB::setNLevels(int nlevels)
  406. //
  407. public void setNLevels(int nlevels)
  408. {
  409. ThrowIfDisposed();
  410. features2d_ORB_setNLevels_10(nativeObj, nlevels);
  411. }
  412. //
  413. // C++: int cv::ORB::getNLevels()
  414. //
  415. public int getNLevels()
  416. {
  417. ThrowIfDisposed();
  418. return features2d_ORB_getNLevels_10(nativeObj);
  419. }
  420. //
  421. // C++: void cv::ORB::setEdgeThreshold(int edgeThreshold)
  422. //
  423. public void setEdgeThreshold(int edgeThreshold)
  424. {
  425. ThrowIfDisposed();
  426. features2d_ORB_setEdgeThreshold_10(nativeObj, edgeThreshold);
  427. }
  428. //
  429. // C++: int cv::ORB::getEdgeThreshold()
  430. //
  431. public int getEdgeThreshold()
  432. {
  433. ThrowIfDisposed();
  434. return features2d_ORB_getEdgeThreshold_10(nativeObj);
  435. }
  436. //
  437. // C++: void cv::ORB::setFirstLevel(int firstLevel)
  438. //
  439. public void setFirstLevel(int firstLevel)
  440. {
  441. ThrowIfDisposed();
  442. features2d_ORB_setFirstLevel_10(nativeObj, firstLevel);
  443. }
  444. //
  445. // C++: int cv::ORB::getFirstLevel()
  446. //
  447. public int getFirstLevel()
  448. {
  449. ThrowIfDisposed();
  450. return features2d_ORB_getFirstLevel_10(nativeObj);
  451. }
  452. //
  453. // C++: void cv::ORB::setWTA_K(int wta_k)
  454. //
  455. public void setWTA_K(int wta_k)
  456. {
  457. ThrowIfDisposed();
  458. features2d_ORB_setWTA_1K_10(nativeObj, wta_k);
  459. }
  460. //
  461. // C++: int cv::ORB::getWTA_K()
  462. //
  463. public int getWTA_K()
  464. {
  465. ThrowIfDisposed();
  466. return features2d_ORB_getWTA_1K_10(nativeObj);
  467. }
  468. //
  469. // C++: void cv::ORB::setScoreType(ORB_ScoreType scoreType)
  470. //
  471. public void setScoreType(int scoreType)
  472. {
  473. ThrowIfDisposed();
  474. features2d_ORB_setScoreType_10(nativeObj, scoreType);
  475. }
  476. //
  477. // C++: ORB_ScoreType cv::ORB::getScoreType()
  478. //
  479. public int getScoreType()
  480. {
  481. ThrowIfDisposed();
  482. return features2d_ORB_getScoreType_10(nativeObj);
  483. }
  484. //
  485. // C++: void cv::ORB::setPatchSize(int patchSize)
  486. //
  487. public void setPatchSize(int patchSize)
  488. {
  489. ThrowIfDisposed();
  490. features2d_ORB_setPatchSize_10(nativeObj, patchSize);
  491. }
  492. //
  493. // C++: int cv::ORB::getPatchSize()
  494. //
  495. public int getPatchSize()
  496. {
  497. ThrowIfDisposed();
  498. return features2d_ORB_getPatchSize_10(nativeObj);
  499. }
  500. //
  501. // C++: void cv::ORB::setFastThreshold(int fastThreshold)
  502. //
  503. public void setFastThreshold(int fastThreshold)
  504. {
  505. ThrowIfDisposed();
  506. features2d_ORB_setFastThreshold_10(nativeObj, fastThreshold);
  507. }
  508. //
  509. // C++: int cv::ORB::getFastThreshold()
  510. //
  511. public int getFastThreshold()
  512. {
  513. ThrowIfDisposed();
  514. return features2d_ORB_getFastThreshold_10(nativeObj);
  515. }
  516. //
  517. // C++: String cv::ORB::getDefaultName()
  518. //
  519. public override string getDefaultName()
  520. {
  521. ThrowIfDisposed();
  522. string retVal = Marshal.PtrToStringAnsi(DisposableObject.ThrowIfNullIntPtr(features2d_ORB_getDefaultName_10(nativeObj)));
  523. return retVal;
  524. }
  525. #if (UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR
  526. const string LIBNAME = "__Internal";
  527. #else
  528. const string LIBNAME = "opencvforunity";
  529. #endif
  530. // C++: static Ptr_ORB cv::ORB::create(int nfeatures = 500, float scaleFactor = 1.2f, int nlevels = 8, int edgeThreshold = 31, int firstLevel = 0, int WTA_K = 2, ORB_ScoreType scoreType = ORB::HARRIS_SCORE, int patchSize = 31, int fastThreshold = 20)
  531. [DllImport(LIBNAME)]
  532. private static extern IntPtr features2d_ORB_create_10(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize, int fastThreshold);
  533. [DllImport(LIBNAME)]
  534. private static extern IntPtr features2d_ORB_create_11(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType, int patchSize);
  535. [DllImport(LIBNAME)]
  536. private static extern IntPtr features2d_ORB_create_12(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K, int scoreType);
  537. [DllImport(LIBNAME)]
  538. private static extern IntPtr features2d_ORB_create_13(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel, int WTA_K);
  539. [DllImport(LIBNAME)]
  540. private static extern IntPtr features2d_ORB_create_14(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold, int firstLevel);
  541. [DllImport(LIBNAME)]
  542. private static extern IntPtr features2d_ORB_create_15(int nfeatures, float scaleFactor, int nlevels, int edgeThreshold);
  543. [DllImport(LIBNAME)]
  544. private static extern IntPtr features2d_ORB_create_16(int nfeatures, float scaleFactor, int nlevels);
  545. [DllImport(LIBNAME)]
  546. private static extern IntPtr features2d_ORB_create_17(int nfeatures, float scaleFactor);
  547. [DllImport(LIBNAME)]
  548. private static extern IntPtr features2d_ORB_create_18(int nfeatures);
  549. [DllImport(LIBNAME)]
  550. private static extern IntPtr features2d_ORB_create_19();
  551. // C++: void cv::ORB::setMaxFeatures(int maxFeatures)
  552. [DllImport(LIBNAME)]
  553. private static extern void features2d_ORB_setMaxFeatures_10(IntPtr nativeObj, int maxFeatures);
  554. // C++: int cv::ORB::getMaxFeatures()
  555. [DllImport(LIBNAME)]
  556. private static extern int features2d_ORB_getMaxFeatures_10(IntPtr nativeObj);
  557. // C++: void cv::ORB::setScaleFactor(double scaleFactor)
  558. [DllImport(LIBNAME)]
  559. private static extern void features2d_ORB_setScaleFactor_10(IntPtr nativeObj, double scaleFactor);
  560. // C++: double cv::ORB::getScaleFactor()
  561. [DllImport(LIBNAME)]
  562. private static extern double features2d_ORB_getScaleFactor_10(IntPtr nativeObj);
  563. // C++: void cv::ORB::setNLevels(int nlevels)
  564. [DllImport(LIBNAME)]
  565. private static extern void features2d_ORB_setNLevels_10(IntPtr nativeObj, int nlevels);
  566. // C++: int cv::ORB::getNLevels()
  567. [DllImport(LIBNAME)]
  568. private static extern int features2d_ORB_getNLevels_10(IntPtr nativeObj);
  569. // C++: void cv::ORB::setEdgeThreshold(int edgeThreshold)
  570. [DllImport(LIBNAME)]
  571. private static extern void features2d_ORB_setEdgeThreshold_10(IntPtr nativeObj, int edgeThreshold);
  572. // C++: int cv::ORB::getEdgeThreshold()
  573. [DllImport(LIBNAME)]
  574. private static extern int features2d_ORB_getEdgeThreshold_10(IntPtr nativeObj);
  575. // C++: void cv::ORB::setFirstLevel(int firstLevel)
  576. [DllImport(LIBNAME)]
  577. private static extern void features2d_ORB_setFirstLevel_10(IntPtr nativeObj, int firstLevel);
  578. // C++: int cv::ORB::getFirstLevel()
  579. [DllImport(LIBNAME)]
  580. private static extern int features2d_ORB_getFirstLevel_10(IntPtr nativeObj);
  581. // C++: void cv::ORB::setWTA_K(int wta_k)
  582. [DllImport(LIBNAME)]
  583. private static extern void features2d_ORB_setWTA_1K_10(IntPtr nativeObj, int wta_k);
  584. // C++: int cv::ORB::getWTA_K()
  585. [DllImport(LIBNAME)]
  586. private static extern int features2d_ORB_getWTA_1K_10(IntPtr nativeObj);
  587. // C++: void cv::ORB::setScoreType(ORB_ScoreType scoreType)
  588. [DllImport(LIBNAME)]
  589. private static extern void features2d_ORB_setScoreType_10(IntPtr nativeObj, int scoreType);
  590. // C++: ORB_ScoreType cv::ORB::getScoreType()
  591. [DllImport(LIBNAME)]
  592. private static extern int features2d_ORB_getScoreType_10(IntPtr nativeObj);
  593. // C++: void cv::ORB::setPatchSize(int patchSize)
  594. [DllImport(LIBNAME)]
  595. private static extern void features2d_ORB_setPatchSize_10(IntPtr nativeObj, int patchSize);
  596. // C++: int cv::ORB::getPatchSize()
  597. [DllImport(LIBNAME)]
  598. private static extern int features2d_ORB_getPatchSize_10(IntPtr nativeObj);
  599. // C++: void cv::ORB::setFastThreshold(int fastThreshold)
  600. [DllImport(LIBNAME)]
  601. private static extern void features2d_ORB_setFastThreshold_10(IntPtr nativeObj, int fastThreshold);
  602. // C++: int cv::ORB::getFastThreshold()
  603. [DllImport(LIBNAME)]
  604. private static extern int features2d_ORB_getFastThreshold_10(IntPtr nativeObj);
  605. // C++: String cv::ORB::getDefaultName()
  606. [DllImport(LIBNAME)]
  607. private static extern IntPtr features2d_ORB_getDefaultName_10(IntPtr nativeObj);
  608. // native support for java finalize()
  609. [DllImport(LIBNAME)]
  610. private static extern void features2d_ORB_delete(IntPtr nativeObj);
  611. }
  612. }