Ccalib.cs 35 KB

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