Ccalib.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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.CcalibModule {
  8. // C++: class Ccalib
  9. //javadoc: Ccalib
  10. public class Ccalib {
  11. // C++: enum <unnamed>
  12. public const int CALIB_USE_GUESS = 1;
  13. public const int CALIB_FIX_SKEW = 2;
  14. public const int CALIB_FIX_K1 = 4;
  15. public const int CALIB_FIX_K2 = 8;
  16. public const int CALIB_FIX_P1 = 16;
  17. public const int CALIB_FIX_P2 = 32;
  18. public const int CALIB_FIX_XI = 64;
  19. public const int CALIB_FIX_GAMMA = 128;
  20. public const int CALIB_FIX_CENTER = 256;
  21. public const int RECTIFY_PERSPECTIVE = 1;
  22. public const int RECTIFY_CYLINDRICAL = 2;
  23. public const int RECTIFY_LONGLATI = 3;
  24. public const int RECTIFY_STEREOGRAPHIC = 4;
  25. public const int XYZRGB = 1;
  26. public const int XYZ = 2;
  27. //
  28. // C++: double cv::omnidir::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size size, Mat& K, Mat& xi, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags, TermCriteria criteria, Mat& idx = Mat())
  29. //
  30. //javadoc: calibrate(objectPoints, imagePoints, size, K, xi, D, rvecs, tvecs, flags, criteria, idx)
  31. public static double calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size size, Mat K, Mat xi, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria, Mat idx) {
  32. if (K != null) K.ThrowIfDisposed();
  33. if (xi != null) xi.ThrowIfDisposed();
  34. if (D != null) D.ThrowIfDisposed();
  35. if (idx != null) idx.ThrowIfDisposed();
  36. #if (UNITY_ANDROID && !UNITY_EDITOR)
  37. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  38. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  39. Mat rvecs_mat = new Mat();
  40. Mat tvecs_mat = new Mat();
  41. double retVal = ccalib_Ccalib_calibrate_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, size.width, size.height, K.nativeObj, xi.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon, idx.nativeObj);
  42. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  43. rvecs_mat.release();
  44. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  45. tvecs_mat.release();
  46. return retVal;
  47. #else
  48. return -1;
  49. #endif
  50. }
  51. //javadoc: calibrate(objectPoints, imagePoints, size, K, xi, D, rvecs, tvecs, flags, criteria)
  52. public static double calibrate(List<Mat> objectPoints, List<Mat> imagePoints, Size size, Mat K, Mat xi, Mat D, List<Mat> rvecs, List<Mat> tvecs, int flags, TermCriteria criteria) {
  53. if (K != null) K.ThrowIfDisposed();
  54. if (xi != null) xi.ThrowIfDisposed();
  55. if (D != null) D.ThrowIfDisposed();
  56. #if (UNITY_ANDROID && !UNITY_EDITOR)
  57. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  58. Mat imagePoints_mat = Converters.vector_Mat_to_Mat(imagePoints);
  59. Mat rvecs_mat = new Mat();
  60. Mat tvecs_mat = new Mat();
  61. double retVal = ccalib_Ccalib_calibrate_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, size.width, size.height, K.nativeObj, xi.nativeObj, D.nativeObj, rvecs_mat.nativeObj, tvecs_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  62. Converters.Mat_to_vector_Mat(rvecs_mat, rvecs);
  63. rvecs_mat.release();
  64. Converters.Mat_to_vector_Mat(tvecs_mat, tvecs);
  65. tvecs_mat.release();
  66. return retVal;
  67. #else
  68. return -1;
  69. #endif
  70. }
  71. //
  72. // C++: double cv::omnidir::stereoCalibrate(vector_Mat& objectPoints, vector_Mat& imagePoints1, vector_Mat& imagePoints2, Size imageSize1, Size imageSize2, Mat& K1, Mat& xi1, Mat& D1, Mat& K2, Mat& xi2, Mat& D2, Mat& rvec, Mat& tvec, vector_Mat& rvecsL, vector_Mat& tvecsL, int flags, TermCriteria criteria, Mat& idx = Mat())
  73. //
  74. //javadoc: stereoCalibrate(objectPoints, imagePoints1, imagePoints2, imageSize1, imageSize2, K1, xi1, D1, K2, xi2, D2, rvec, tvec, rvecsL, tvecsL, flags, criteria, idx)
  75. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Size imageSize1, Size imageSize2, Mat K1, Mat xi1, Mat D1, Mat K2, Mat xi2, Mat D2, Mat rvec, Mat tvec, List<Mat> rvecsL, List<Mat> tvecsL, int flags, TermCriteria criteria, Mat idx) {
  76. if (K1 != null) K1.ThrowIfDisposed();
  77. if (xi1 != null) xi1.ThrowIfDisposed();
  78. if (D1 != null) D1.ThrowIfDisposed();
  79. if (K2 != null) K2.ThrowIfDisposed();
  80. if (xi2 != null) xi2.ThrowIfDisposed();
  81. if (D2 != null) D2.ThrowIfDisposed();
  82. if (rvec != null) rvec.ThrowIfDisposed();
  83. if (tvec != null) tvec.ThrowIfDisposed();
  84. if (idx != null) idx.ThrowIfDisposed();
  85. #if (UNITY_ANDROID && !UNITY_EDITOR)
  86. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  87. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  88. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  89. Mat rvecsL_mat = new Mat();
  90. Mat tvecsL_mat = new Mat();
  91. double retVal = ccalib_Ccalib_stereoCalibrate_10(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, imageSize1.width, imageSize1.height, imageSize2.width, imageSize2.height, K1.nativeObj, xi1.nativeObj, D1.nativeObj, K2.nativeObj, xi2.nativeObj, D2.nativeObj, rvec.nativeObj, tvec.nativeObj, rvecsL_mat.nativeObj, tvecsL_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon, idx.nativeObj);
  92. Converters.Mat_to_vector_Mat(objectPoints_mat, objectPoints);
  93. objectPoints_mat.release();
  94. Converters.Mat_to_vector_Mat(imagePoints1_mat, imagePoints1);
  95. imagePoints1_mat.release();
  96. Converters.Mat_to_vector_Mat(imagePoints2_mat, imagePoints2);
  97. imagePoints2_mat.release();
  98. Converters.Mat_to_vector_Mat(rvecsL_mat, rvecsL);
  99. rvecsL_mat.release();
  100. Converters.Mat_to_vector_Mat(tvecsL_mat, tvecsL);
  101. tvecsL_mat.release();
  102. return retVal;
  103. #else
  104. return -1;
  105. #endif
  106. }
  107. //javadoc: stereoCalibrate(objectPoints, imagePoints1, imagePoints2, imageSize1, imageSize2, K1, xi1, D1, K2, xi2, D2, rvec, tvec, rvecsL, tvecsL, flags, criteria)
  108. public static double stereoCalibrate(List<Mat> objectPoints, List<Mat> imagePoints1, List<Mat> imagePoints2, Size imageSize1, Size imageSize2, Mat K1, Mat xi1, Mat D1, Mat K2, Mat xi2, Mat D2, Mat rvec, Mat tvec, List<Mat> rvecsL, List<Mat> tvecsL, int flags, TermCriteria criteria) {
  109. if (K1 != null) K1.ThrowIfDisposed();
  110. if (xi1 != null) xi1.ThrowIfDisposed();
  111. if (D1 != null) D1.ThrowIfDisposed();
  112. if (K2 != null) K2.ThrowIfDisposed();
  113. if (xi2 != null) xi2.ThrowIfDisposed();
  114. if (D2 != null) D2.ThrowIfDisposed();
  115. if (rvec != null) rvec.ThrowIfDisposed();
  116. if (tvec != null) tvec.ThrowIfDisposed();
  117. #if (UNITY_ANDROID && !UNITY_EDITOR)
  118. Mat objectPoints_mat = Converters.vector_Mat_to_Mat(objectPoints);
  119. Mat imagePoints1_mat = Converters.vector_Mat_to_Mat(imagePoints1);
  120. Mat imagePoints2_mat = Converters.vector_Mat_to_Mat(imagePoints2);
  121. Mat rvecsL_mat = new Mat();
  122. Mat tvecsL_mat = new Mat();
  123. double retVal = ccalib_Ccalib_stereoCalibrate_11(objectPoints_mat.nativeObj, imagePoints1_mat.nativeObj, imagePoints2_mat.nativeObj, imageSize1.width, imageSize1.height, imageSize2.width, imageSize2.height, K1.nativeObj, xi1.nativeObj, D1.nativeObj, K2.nativeObj, xi2.nativeObj, D2.nativeObj, rvec.nativeObj, tvec.nativeObj, rvecsL_mat.nativeObj, tvecsL_mat.nativeObj, flags, criteria.type, criteria.maxCount, criteria.epsilon);
  124. Converters.Mat_to_vector_Mat(objectPoints_mat, objectPoints);
  125. objectPoints_mat.release();
  126. Converters.Mat_to_vector_Mat(imagePoints1_mat, imagePoints1);
  127. imagePoints1_mat.release();
  128. Converters.Mat_to_vector_Mat(imagePoints2_mat, imagePoints2);
  129. imagePoints2_mat.release();
  130. Converters.Mat_to_vector_Mat(rvecsL_mat, rvecsL);
  131. rvecsL_mat.release();
  132. Converters.Mat_to_vector_Mat(tvecsL_mat, tvecsL);
  133. tvecsL_mat.release();
  134. return retVal;
  135. #else
  136. return -1;
  137. #endif
  138. }
  139. //
  140. // C++: void cv::omnidir::initUndistortRectifyMap(Mat K, Mat D, Mat xi, Mat R, Mat P, Size size, int mltype, Mat& map1, Mat& map2, int flags)
  141. //
  142. //javadoc: initUndistortRectifyMap(K, D, xi, R, P, size, mltype, map1, map2, flags)
  143. public static void initUndistortRectifyMap(Mat K, Mat D, Mat xi, Mat R, Mat P, Size size, int mltype, Mat map1, Mat map2, int flags) {
  144. if (K != null) K.ThrowIfDisposed();
  145. if (D != null) D.ThrowIfDisposed();
  146. if (xi != null) xi.ThrowIfDisposed();
  147. if (R != null) R.ThrowIfDisposed();
  148. if (P != null) P.ThrowIfDisposed();
  149. if (map1 != null) map1.ThrowIfDisposed();
  150. if (map2 != null) map2.ThrowIfDisposed();
  151. #if (UNITY_ANDROID && !UNITY_EDITOR)
  152. ccalib_Ccalib_initUndistortRectifyMap_10(K.nativeObj, D.nativeObj, xi.nativeObj, R.nativeObj, P.nativeObj, size.width, size.height, mltype, map1.nativeObj, map2.nativeObj, flags);
  153. return;
  154. #else
  155. return;
  156. #endif
  157. }
  158. //
  159. // C++: void cv::omnidir::projectPoints(vector_Point3f objectPoints, vector_Point2f& imagePoints, Mat rvec, Mat tvec, Mat K, double xi, Mat D, Mat& jacobian = Mat())
  160. //
  161. //javadoc: projectPoints(objectPoints, imagePoints, rvec, tvec, K, xi, D, jacobian)
  162. public static void projectPoints(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat rvec, Mat tvec, Mat K, double xi, Mat D, Mat jacobian) {
  163. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  164. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  165. if (rvec != null) rvec.ThrowIfDisposed();
  166. if (tvec != null) tvec.ThrowIfDisposed();
  167. if (K != null) K.ThrowIfDisposed();
  168. if (D != null) D.ThrowIfDisposed();
  169. if (jacobian != null) jacobian.ThrowIfDisposed();
  170. #if (UNITY_ANDROID && !UNITY_EDITOR)
  171. Mat objectPoints_mat = objectPoints;
  172. Mat imagePoints_mat = imagePoints;
  173. ccalib_Ccalib_projectPoints_10(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, xi, D.nativeObj, jacobian.nativeObj);
  174. return;
  175. #else
  176. return;
  177. #endif
  178. }
  179. //javadoc: projectPoints(objectPoints, imagePoints, rvec, tvec, K, xi, D)
  180. public static void projectPoints(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat rvec, Mat tvec, Mat K, double xi, Mat D) {
  181. if (objectPoints != null) objectPoints.ThrowIfDisposed();
  182. if (imagePoints != null) imagePoints.ThrowIfDisposed();
  183. if (rvec != null) rvec.ThrowIfDisposed();
  184. if (tvec != null) tvec.ThrowIfDisposed();
  185. if (K != null) K.ThrowIfDisposed();
  186. if (D != null) D.ThrowIfDisposed();
  187. #if (UNITY_ANDROID && !UNITY_EDITOR)
  188. Mat objectPoints_mat = objectPoints;
  189. Mat imagePoints_mat = imagePoints;
  190. ccalib_Ccalib_projectPoints_11(objectPoints_mat.nativeObj, imagePoints_mat.nativeObj, rvec.nativeObj, tvec.nativeObj, K.nativeObj, xi, D.nativeObj);
  191. return;
  192. #else
  193. return;
  194. #endif
  195. }
  196. //
  197. // C++: void cv::omnidir::stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat& disparity, Mat& image1Rec, Mat& image2Rec, Size newSize = Size(), Mat Knew = cv::Mat(), Mat& pointCloud = cv::Mat(), int pointType = XYZRGB)
  198. //
  199. //javadoc: stereoReconstruct(image1, image2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disparity, image1Rec, image2Rec, newSize, Knew, pointCloud, pointType)
  200. public static void stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat disparity, Mat image1Rec, Mat image2Rec, Size newSize, Mat Knew, Mat pointCloud, int pointType) {
  201. if (image1 != null) image1.ThrowIfDisposed();
  202. if (image2 != null) image2.ThrowIfDisposed();
  203. if (K1 != null) K1.ThrowIfDisposed();
  204. if (D1 != null) D1.ThrowIfDisposed();
  205. if (xi1 != null) xi1.ThrowIfDisposed();
  206. if (K2 != null) K2.ThrowIfDisposed();
  207. if (D2 != null) D2.ThrowIfDisposed();
  208. if (xi2 != null) xi2.ThrowIfDisposed();
  209. if (R != null) R.ThrowIfDisposed();
  210. if (T != null) T.ThrowIfDisposed();
  211. if (disparity != null) disparity.ThrowIfDisposed();
  212. if (image1Rec != null) image1Rec.ThrowIfDisposed();
  213. if (image2Rec != null) image2Rec.ThrowIfDisposed();
  214. if (Knew != null) Knew.ThrowIfDisposed();
  215. if (pointCloud != null) pointCloud.ThrowIfDisposed();
  216. #if (UNITY_ANDROID && !UNITY_EDITOR)
  217. ccalib_Ccalib_stereoReconstruct_10(image1.nativeObj, image2.nativeObj, K1.nativeObj, D1.nativeObj, xi1.nativeObj, K2.nativeObj, D2.nativeObj, xi2.nativeObj, R.nativeObj, T.nativeObj, flag, numDisparities, SADWindowSize, disparity.nativeObj, image1Rec.nativeObj, image2Rec.nativeObj, newSize.width, newSize.height, Knew.nativeObj, pointCloud.nativeObj, pointType);
  218. return;
  219. #else
  220. return;
  221. #endif
  222. }
  223. //javadoc: stereoReconstruct(image1, image2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disparity, image1Rec, image2Rec, newSize, Knew, pointCloud)
  224. public static void stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat disparity, Mat image1Rec, Mat image2Rec, Size newSize, Mat Knew, Mat pointCloud) {
  225. if (image1 != null) image1.ThrowIfDisposed();
  226. if (image2 != null) image2.ThrowIfDisposed();
  227. if (K1 != null) K1.ThrowIfDisposed();
  228. if (D1 != null) D1.ThrowIfDisposed();
  229. if (xi1 != null) xi1.ThrowIfDisposed();
  230. if (K2 != null) K2.ThrowIfDisposed();
  231. if (D2 != null) D2.ThrowIfDisposed();
  232. if (xi2 != null) xi2.ThrowIfDisposed();
  233. if (R != null) R.ThrowIfDisposed();
  234. if (T != null) T.ThrowIfDisposed();
  235. if (disparity != null) disparity.ThrowIfDisposed();
  236. if (image1Rec != null) image1Rec.ThrowIfDisposed();
  237. if (image2Rec != null) image2Rec.ThrowIfDisposed();
  238. if (Knew != null) Knew.ThrowIfDisposed();
  239. if (pointCloud != null) pointCloud.ThrowIfDisposed();
  240. #if (UNITY_ANDROID && !UNITY_EDITOR)
  241. ccalib_Ccalib_stereoReconstruct_11(image1.nativeObj, image2.nativeObj, K1.nativeObj, D1.nativeObj, xi1.nativeObj, K2.nativeObj, D2.nativeObj, xi2.nativeObj, R.nativeObj, T.nativeObj, flag, numDisparities, SADWindowSize, disparity.nativeObj, image1Rec.nativeObj, image2Rec.nativeObj, newSize.width, newSize.height, Knew.nativeObj, pointCloud.nativeObj);
  242. return;
  243. #else
  244. return;
  245. #endif
  246. }
  247. //javadoc: stereoReconstruct(image1, image2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disparity, image1Rec, image2Rec, newSize, Knew)
  248. public static void stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat disparity, Mat image1Rec, Mat image2Rec, Size newSize, Mat Knew) {
  249. if (image1 != null) image1.ThrowIfDisposed();
  250. if (image2 != null) image2.ThrowIfDisposed();
  251. if (K1 != null) K1.ThrowIfDisposed();
  252. if (D1 != null) D1.ThrowIfDisposed();
  253. if (xi1 != null) xi1.ThrowIfDisposed();
  254. if (K2 != null) K2.ThrowIfDisposed();
  255. if (D2 != null) D2.ThrowIfDisposed();
  256. if (xi2 != null) xi2.ThrowIfDisposed();
  257. if (R != null) R.ThrowIfDisposed();
  258. if (T != null) T.ThrowIfDisposed();
  259. if (disparity != null) disparity.ThrowIfDisposed();
  260. if (image1Rec != null) image1Rec.ThrowIfDisposed();
  261. if (image2Rec != null) image2Rec.ThrowIfDisposed();
  262. if (Knew != null) Knew.ThrowIfDisposed();
  263. #if (UNITY_ANDROID && !UNITY_EDITOR)
  264. ccalib_Ccalib_stereoReconstruct_12(image1.nativeObj, image2.nativeObj, K1.nativeObj, D1.nativeObj, xi1.nativeObj, K2.nativeObj, D2.nativeObj, xi2.nativeObj, R.nativeObj, T.nativeObj, flag, numDisparities, SADWindowSize, disparity.nativeObj, image1Rec.nativeObj, image2Rec.nativeObj, newSize.width, newSize.height, Knew.nativeObj);
  265. return;
  266. #else
  267. return;
  268. #endif
  269. }
  270. //javadoc: stereoReconstruct(image1, image2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disparity, image1Rec, image2Rec, newSize)
  271. public static void stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat disparity, Mat image1Rec, Mat image2Rec, Size newSize) {
  272. if (image1 != null) image1.ThrowIfDisposed();
  273. if (image2 != null) image2.ThrowIfDisposed();
  274. if (K1 != null) K1.ThrowIfDisposed();
  275. if (D1 != null) D1.ThrowIfDisposed();
  276. if (xi1 != null) xi1.ThrowIfDisposed();
  277. if (K2 != null) K2.ThrowIfDisposed();
  278. if (D2 != null) D2.ThrowIfDisposed();
  279. if (xi2 != null) xi2.ThrowIfDisposed();
  280. if (R != null) R.ThrowIfDisposed();
  281. if (T != null) T.ThrowIfDisposed();
  282. if (disparity != null) disparity.ThrowIfDisposed();
  283. if (image1Rec != null) image1Rec.ThrowIfDisposed();
  284. if (image2Rec != null) image2Rec.ThrowIfDisposed();
  285. #if (UNITY_ANDROID && !UNITY_EDITOR)
  286. ccalib_Ccalib_stereoReconstruct_13(image1.nativeObj, image2.nativeObj, K1.nativeObj, D1.nativeObj, xi1.nativeObj, K2.nativeObj, D2.nativeObj, xi2.nativeObj, R.nativeObj, T.nativeObj, flag, numDisparities, SADWindowSize, disparity.nativeObj, image1Rec.nativeObj, image2Rec.nativeObj, newSize.width, newSize.height);
  287. return;
  288. #else
  289. return;
  290. #endif
  291. }
  292. //javadoc: stereoReconstruct(image1, image2, K1, D1, xi1, K2, D2, xi2, R, T, flag, numDisparities, SADWindowSize, disparity, image1Rec, image2Rec)
  293. public static void stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat disparity, Mat image1Rec, Mat image2Rec) {
  294. if (image1 != null) image1.ThrowIfDisposed();
  295. if (image2 != null) image2.ThrowIfDisposed();
  296. if (K1 != null) K1.ThrowIfDisposed();
  297. if (D1 != null) D1.ThrowIfDisposed();
  298. if (xi1 != null) xi1.ThrowIfDisposed();
  299. if (K2 != null) K2.ThrowIfDisposed();
  300. if (D2 != null) D2.ThrowIfDisposed();
  301. if (xi2 != null) xi2.ThrowIfDisposed();
  302. if (R != null) R.ThrowIfDisposed();
  303. if (T != null) T.ThrowIfDisposed();
  304. if (disparity != null) disparity.ThrowIfDisposed();
  305. if (image1Rec != null) image1Rec.ThrowIfDisposed();
  306. if (image2Rec != null) image2Rec.ThrowIfDisposed();
  307. #if (UNITY_ANDROID && !UNITY_EDITOR)
  308. ccalib_Ccalib_stereoReconstruct_14(image1.nativeObj, image2.nativeObj, K1.nativeObj, D1.nativeObj, xi1.nativeObj, K2.nativeObj, D2.nativeObj, xi2.nativeObj, R.nativeObj, T.nativeObj, flag, numDisparities, SADWindowSize, disparity.nativeObj, image1Rec.nativeObj, image2Rec.nativeObj);
  309. return;
  310. #else
  311. return;
  312. #endif
  313. }
  314. //
  315. // C++: void cv::omnidir::stereoRectify(Mat R, Mat T, Mat& R1, Mat& R2)
  316. //
  317. //javadoc: stereoRectify(R, T, R1, R2)
  318. public static void stereoRectify(Mat R, Mat T, Mat R1, Mat R2) {
  319. if (R != null) R.ThrowIfDisposed();
  320. if (T != null) T.ThrowIfDisposed();
  321. if (R1 != null) R1.ThrowIfDisposed();
  322. if (R2 != null) R2.ThrowIfDisposed();
  323. #if (UNITY_ANDROID && !UNITY_EDITOR)
  324. ccalib_Ccalib_stereoRectify_10(R.nativeObj, T.nativeObj, R1.nativeObj, R2.nativeObj);
  325. return;
  326. #else
  327. return;
  328. #endif
  329. }
  330. //
  331. // C++: void cv::omnidir::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat xi, int flags, Mat Knew = cv::Mat(), Size new_size = Size(), Mat R = Mat::eye(3, 3, CV_64F))
  332. //
  333. //javadoc: undistortImage(distorted, undistorted, K, D, xi, flags, Knew, new_size, R)
  334. public static void undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat xi, int flags, Mat Knew, Size new_size, Mat R) {
  335. if (distorted != null) distorted.ThrowIfDisposed();
  336. if (undistorted != null) undistorted.ThrowIfDisposed();
  337. if (K != null) K.ThrowIfDisposed();
  338. if (D != null) D.ThrowIfDisposed();
  339. if (xi != null) xi.ThrowIfDisposed();
  340. if (Knew != null) Knew.ThrowIfDisposed();
  341. if (R != null) R.ThrowIfDisposed();
  342. #if (UNITY_ANDROID && !UNITY_EDITOR)
  343. ccalib_Ccalib_undistortImage_10(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, xi.nativeObj, flags, Knew.nativeObj, new_size.width, new_size.height, R.nativeObj);
  344. return;
  345. #else
  346. return;
  347. #endif
  348. }
  349. //javadoc: undistortImage(distorted, undistorted, K, D, xi, flags, Knew, new_size)
  350. public static void undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat xi, int flags, Mat Knew, Size new_size) {
  351. if (distorted != null) distorted.ThrowIfDisposed();
  352. if (undistorted != null) undistorted.ThrowIfDisposed();
  353. if (K != null) K.ThrowIfDisposed();
  354. if (D != null) D.ThrowIfDisposed();
  355. if (xi != null) xi.ThrowIfDisposed();
  356. if (Knew != null) Knew.ThrowIfDisposed();
  357. #if (UNITY_ANDROID && !UNITY_EDITOR)
  358. ccalib_Ccalib_undistortImage_11(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, xi.nativeObj, flags, Knew.nativeObj, new_size.width, new_size.height);
  359. return;
  360. #else
  361. return;
  362. #endif
  363. }
  364. //javadoc: undistortImage(distorted, undistorted, K, D, xi, flags, Knew)
  365. public static void undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat xi, int flags, Mat Knew) {
  366. if (distorted != null) distorted.ThrowIfDisposed();
  367. if (undistorted != null) undistorted.ThrowIfDisposed();
  368. if (K != null) K.ThrowIfDisposed();
  369. if (D != null) D.ThrowIfDisposed();
  370. if (xi != null) xi.ThrowIfDisposed();
  371. if (Knew != null) Knew.ThrowIfDisposed();
  372. #if (UNITY_ANDROID && !UNITY_EDITOR)
  373. ccalib_Ccalib_undistortImage_12(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, xi.nativeObj, flags, Knew.nativeObj);
  374. return;
  375. #else
  376. return;
  377. #endif
  378. }
  379. //javadoc: undistortImage(distorted, undistorted, K, D, xi, flags)
  380. public static void undistortImage(Mat distorted, Mat undistorted, Mat K, Mat D, Mat xi, int flags) {
  381. if (distorted != null) distorted.ThrowIfDisposed();
  382. if (undistorted != null) undistorted.ThrowIfDisposed();
  383. if (K != null) K.ThrowIfDisposed();
  384. if (D != null) D.ThrowIfDisposed();
  385. if (xi != null) xi.ThrowIfDisposed();
  386. #if (UNITY_ANDROID && !UNITY_EDITOR)
  387. ccalib_Ccalib_undistortImage_13(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, xi.nativeObj, flags);
  388. return;
  389. #else
  390. return;
  391. #endif
  392. }
  393. //
  394. // C++: void cv::omnidir::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat xi, Mat R)
  395. //
  396. //javadoc: undistortPoints(distorted, undistorted, K, D, xi, R)
  397. public static void undistortPoints(Mat distorted, Mat undistorted, Mat K, Mat D, Mat xi, Mat R) {
  398. if (distorted != null) distorted.ThrowIfDisposed();
  399. if (undistorted != null) undistorted.ThrowIfDisposed();
  400. if (K != null) K.ThrowIfDisposed();
  401. if (D != null) D.ThrowIfDisposed();
  402. if (xi != null) xi.ThrowIfDisposed();
  403. if (R != null) R.ThrowIfDisposed();
  404. #if (UNITY_ANDROID && !UNITY_EDITOR)
  405. ccalib_Ccalib_undistortPoints_10(distorted.nativeObj, undistorted.nativeObj, K.nativeObj, D.nativeObj, xi.nativeObj, R.nativeObj);
  406. return;
  407. #else
  408. return;
  409. #endif
  410. }
  411. #if (UNITY_ANDROID && !UNITY_EDITOR)
  412. const string LIBNAME = "opencvforunity";
  413. // C++: double cv::omnidir::calibrate(vector_Mat objectPoints, vector_Mat imagePoints, Size size, Mat& K, Mat& xi, Mat& D, vector_Mat& rvecs, vector_Mat& tvecs, int flags, TermCriteria criteria, Mat& idx = Mat())
  414. [DllImport(LIBNAME)]
  415. private static extern double ccalib_Ccalib_calibrate_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double size_width, double size_height, IntPtr K_nativeObj, IntPtr xi_nativeObj, IntPtr D_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon, IntPtr idx_nativeObj);
  416. [DllImport(LIBNAME)]
  417. private static extern double ccalib_Ccalib_calibrate_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, double size_width, double size_height, IntPtr K_nativeObj, IntPtr xi_nativeObj, IntPtr D_nativeObj, IntPtr rvecs_mat_nativeObj, IntPtr tvecs_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  418. // C++: double cv::omnidir::stereoCalibrate(vector_Mat& objectPoints, vector_Mat& imagePoints1, vector_Mat& imagePoints2, Size imageSize1, Size imageSize2, Mat& K1, Mat& xi1, Mat& D1, Mat& K2, Mat& xi2, Mat& D2, Mat& rvec, Mat& tvec, vector_Mat& rvecsL, vector_Mat& tvecsL, int flags, TermCriteria criteria, Mat& idx = Mat())
  419. [DllImport(LIBNAME)]
  420. private static extern double ccalib_Ccalib_stereoCalibrate_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, double imageSize1_width, double imageSize1_height, double imageSize2_width, double imageSize2_height, IntPtr K1_nativeObj, IntPtr xi1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr xi2_nativeObj, IntPtr D2_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr rvecsL_mat_nativeObj, IntPtr tvecsL_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon, IntPtr idx_nativeObj);
  421. [DllImport(LIBNAME)]
  422. private static extern double ccalib_Ccalib_stereoCalibrate_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints1_mat_nativeObj, IntPtr imagePoints2_mat_nativeObj, double imageSize1_width, double imageSize1_height, double imageSize2_width, double imageSize2_height, IntPtr K1_nativeObj, IntPtr xi1_nativeObj, IntPtr D1_nativeObj, IntPtr K2_nativeObj, IntPtr xi2_nativeObj, IntPtr D2_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr rvecsL_mat_nativeObj, IntPtr tvecsL_mat_nativeObj, int flags, int criteria_type, int criteria_maxCount, double criteria_epsilon);
  423. // C++: void cv::omnidir::initUndistortRectifyMap(Mat K, Mat D, Mat xi, Mat R, Mat P, Size size, int mltype, Mat& map1, Mat& map2, int flags)
  424. [DllImport(LIBNAME)]
  425. private static extern void ccalib_Ccalib_initUndistortRectifyMap_10(IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, IntPtr R_nativeObj, IntPtr P_nativeObj, double size_width, double size_height, int mltype, IntPtr map1_nativeObj, IntPtr map2_nativeObj, int flags);
  426. // C++: void cv::omnidir::projectPoints(vector_Point3f objectPoints, vector_Point2f& imagePoints, Mat rvec, Mat tvec, Mat K, double xi, Mat D, Mat& jacobian = Mat())
  427. [DllImport(LIBNAME)]
  428. private static extern void ccalib_Ccalib_projectPoints_10(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr K_nativeObj, double xi, IntPtr D_nativeObj, IntPtr jacobian_nativeObj);
  429. [DllImport(LIBNAME)]
  430. private static extern void ccalib_Ccalib_projectPoints_11(IntPtr objectPoints_mat_nativeObj, IntPtr imagePoints_mat_nativeObj, IntPtr rvec_nativeObj, IntPtr tvec_nativeObj, IntPtr K_nativeObj, double xi, IntPtr D_nativeObj);
  431. // C++: void cv::omnidir::stereoReconstruct(Mat image1, Mat image2, Mat K1, Mat D1, Mat xi1, Mat K2, Mat D2, Mat xi2, Mat R, Mat T, int flag, int numDisparities, int SADWindowSize, Mat& disparity, Mat& image1Rec, Mat& image2Rec, Size newSize = Size(), Mat Knew = cv::Mat(), Mat& pointCloud = cv::Mat(), int pointType = XYZRGB)
  432. [DllImport(LIBNAME)]
  433. private static extern void ccalib_Ccalib_stereoReconstruct_10(IntPtr image1_nativeObj, IntPtr image2_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr xi1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, IntPtr xi2_nativeObj, IntPtr R_nativeObj, IntPtr T_nativeObj, int flag, int numDisparities, int SADWindowSize, IntPtr disparity_nativeObj, IntPtr image1Rec_nativeObj, IntPtr image2Rec_nativeObj, double newSize_width, double newSize_height, IntPtr Knew_nativeObj, IntPtr pointCloud_nativeObj, int pointType);
  434. [DllImport(LIBNAME)]
  435. private static extern void ccalib_Ccalib_stereoReconstruct_11(IntPtr image1_nativeObj, IntPtr image2_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr xi1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, IntPtr xi2_nativeObj, IntPtr R_nativeObj, IntPtr T_nativeObj, int flag, int numDisparities, int SADWindowSize, IntPtr disparity_nativeObj, IntPtr image1Rec_nativeObj, IntPtr image2Rec_nativeObj, double newSize_width, double newSize_height, IntPtr Knew_nativeObj, IntPtr pointCloud_nativeObj);
  436. [DllImport(LIBNAME)]
  437. private static extern void ccalib_Ccalib_stereoReconstruct_12(IntPtr image1_nativeObj, IntPtr image2_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr xi1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, IntPtr xi2_nativeObj, IntPtr R_nativeObj, IntPtr T_nativeObj, int flag, int numDisparities, int SADWindowSize, IntPtr disparity_nativeObj, IntPtr image1Rec_nativeObj, IntPtr image2Rec_nativeObj, double newSize_width, double newSize_height, IntPtr Knew_nativeObj);
  438. [DllImport(LIBNAME)]
  439. private static extern void ccalib_Ccalib_stereoReconstruct_13(IntPtr image1_nativeObj, IntPtr image2_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr xi1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, IntPtr xi2_nativeObj, IntPtr R_nativeObj, IntPtr T_nativeObj, int flag, int numDisparities, int SADWindowSize, IntPtr disparity_nativeObj, IntPtr image1Rec_nativeObj, IntPtr image2Rec_nativeObj, double newSize_width, double newSize_height);
  440. [DllImport(LIBNAME)]
  441. private static extern void ccalib_Ccalib_stereoReconstruct_14(IntPtr image1_nativeObj, IntPtr image2_nativeObj, IntPtr K1_nativeObj, IntPtr D1_nativeObj, IntPtr xi1_nativeObj, IntPtr K2_nativeObj, IntPtr D2_nativeObj, IntPtr xi2_nativeObj, IntPtr R_nativeObj, IntPtr T_nativeObj, int flag, int numDisparities, int SADWindowSize, IntPtr disparity_nativeObj, IntPtr image1Rec_nativeObj, IntPtr image2Rec_nativeObj);
  442. // C++: void cv::omnidir::stereoRectify(Mat R, Mat T, Mat& R1, Mat& R2)
  443. [DllImport(LIBNAME)]
  444. private static extern void ccalib_Ccalib_stereoRectify_10(IntPtr R_nativeObj, IntPtr T_nativeObj, IntPtr R1_nativeObj, IntPtr R2_nativeObj);
  445. // C++: void cv::omnidir::undistortImage(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat xi, int flags, Mat Knew = cv::Mat(), Size new_size = Size(), Mat R = Mat::eye(3, 3, CV_64F))
  446. [DllImport(LIBNAME)]
  447. private static extern void ccalib_Ccalib_undistortImage_10(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, int flags, IntPtr Knew_nativeObj, double new_size_width, double new_size_height, IntPtr R_nativeObj);
  448. [DllImport(LIBNAME)]
  449. private static extern void ccalib_Ccalib_undistortImage_11(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, int flags, IntPtr Knew_nativeObj, double new_size_width, double new_size_height);
  450. [DllImport(LIBNAME)]
  451. private static extern void ccalib_Ccalib_undistortImage_12(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, int flags, IntPtr Knew_nativeObj);
  452. [DllImport(LIBNAME)]
  453. private static extern void ccalib_Ccalib_undistortImage_13(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, int flags);
  454. // C++: void cv::omnidir::undistortPoints(Mat distorted, Mat& undistorted, Mat K, Mat D, Mat xi, Mat R)
  455. [DllImport(LIBNAME)]
  456. private static extern void ccalib_Ccalib_undistortPoints_10(IntPtr distorted_nativeObj, IntPtr undistorted_nativeObj, IntPtr K_nativeObj, IntPtr D_nativeObj, IntPtr xi_nativeObj, IntPtr R_nativeObj);
  457. #endif
  458. }
  459. }