From c30fef1f9ded38817e8280a27c8a67db4e2bea0d Mon Sep 17 00:00:00 2001 From: Ilya Krylov Date: Tue, 13 May 2014 13:34:46 +0400 Subject: [PATCH] Fixed build issues --- .../camera_calibration_and_3d_reconstruction.rst | 80 ++++++++++------------ .../calib3d/include/opencv2/calib3d/calib3d.hpp | 2 +- modules/calib3d/src/fisheye.cpp | 78 +++++++++------------ modules/calib3d/src/fisheye.hpp | 9 +-- modules/calib3d/test/test_fisheye.cpp | 1 - 5 files changed, 73 insertions(+), 97 deletions(-) diff --git a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst index 2f1bc69..5f64125 100644 --- a/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst +++ b/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst @@ -1536,13 +1536,17 @@ The methods in this class use a so-called fisheye camera model. :: OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0); - ... + //! performs stereo calibration + static double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, + InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, + OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)); }; Definitions: Let P be a point in 3D of coordinates X in the world reference frame (stored in the matrix X) -The coordinate vector of P in the camera reference frame is: +The coordinate vector of P in the camera reference frame is: .. class:: center .. math:: @@ -1556,13 +1560,13 @@ call x, y and z the 3 coordinates of Xc: .. math:: x = Xc_1 \\ y = Xc_2 \\ - z = Xc_3 + z = Xc_3 -The pinehole projection coordinates of P is [a; b] where +The pinehole projection coordinates of P is [a; b] where .. class:: center .. math:: - + a = x / z \ and \ b = y / z \\ r^2 = a^2 + b^2 \\ \theta = atan(r) @@ -1570,22 +1574,22 @@ The pinehole projection coordinates of P is [a; b] where Fisheye distortion: .. class:: center -.. math:: - +.. math:: + \theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8) The distorted point coordinates are [x'; y'] where -.. class:: center -.. math:: - +..class:: center +.. math:: + x' = (\theta_d / r) x \\ y' = (\theta_d / r) y Finally, convertion into pixel coordinates: The final pixel coordinates vector [u; v] where: .. class:: center -.. math:: +.. math:: u = f_x (x' + \alpha y') + c_x \\ v = f_y yy + c_y @@ -1596,38 +1600,32 @@ Projects points using fisheye model .. ocv:function:: void Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, const Affine3d& affine, InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()) -.. ocv:function:: void Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, - InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()) +.. ocv:function:: void Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray()) :param objectPoints: Array of object points, 1xN/Nx1 3-channel (or ``vector`` ), where N is the number of points in the view. - :param rvec: Rotation vector. See :ocv:func:`Rodrigues` for details. + :param rvec: Rotation vector. See :ocv:func:`Rodrigues` for details. :param tvec: Translation vector. - :param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}` . + :param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`. :param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`. :param alpha: The skew coefficient. - :param imagePoints: Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or ``vector`` . + :param imagePoints: Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or ``vector``. :param jacobian: Optional output 2Nx15 jacobian matrix of derivatives of image points with respect to components of the focal lengths, coordinates of the principal point, distortion coefficients, rotation vector, translation vector, and the skew. In the old interface different components of the jacobian are returned via different output parameters. -The function computes projections of 3D -points to the image plane given intrinsic and extrinsic camera -parameters. Optionally, the function computes Jacobians - matrices -of partial derivatives of image points coordinates (as functions of all the -input parameters) with respect to the particular parameters, intrinsic and/or -extrinsic. +The function computes projections of 3D points to the image plane given intrinsic and extrinsic camera parameters. Optionally, the function computes Jacobians - matrices of partial derivatives of image points coordinates (as functions of all the input parameters) with respect to the particular parameters, intrinsic and/or extrinsic. Fisheye::distortPoints ------------------------- Distorts 2D points using fisheye model. .. ocv:function:: void Fisheye::distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0) - + :param undistorted: Array of object points, 1xN/Nx1 2-channel (or ``vector`` ), where N is the number of points in the view. :param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`. @@ -1642,8 +1640,7 @@ Fisheye::undistortPoints ----------------------------- Undistorts 2D points using fisheye model -.. ocv:function:: void Fisheye::undistortPoints(InputArray distorted, OutputArray undistorted, - InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray()) +.. ocv:function:: void Fisheye::undistortPoints(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray()) :param distorted: Array of object points, 1xN/Nx1 2-channel (or ``vector`` ), where N is the number of points in the view. @@ -1651,25 +1648,24 @@ Undistorts 2D points using fisheye model :param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`. - :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel + :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel :param P: New camera matrix (3x3) or new projection matrix (3x4) - :param undistorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector`` . + :param undistorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector`` . Fisheye::initUndistortRectifyMap ------------------------------------- Computes undistortion and rectification maps for image transform by cv::remap(). If D is empty zero distortion is used, if R or P is empty identity matrixes are used. -.. ocv:function:: void Fisheye::initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, - const cv::Size& size, int m1type, OutputArray map1, OutputArray map2) +.. ocv:function:: void Fisheye::initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, const cv::Size& size, int m1type, OutputArray map1, OutputArray map2) :param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`. :param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`. - :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel + :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel :param P: New camera matrix (3x3) or new projection matrix (3x4) @@ -1682,11 +1678,10 @@ Computes undistortion and rectification maps for image transform by cv::remap(). :param map2: The second output map. Fisheye::undistortImage -------------- +----------------------- Transforms an image to compensate for fisheye lens distortion. -.. ocv:function:: void Fisheye::undistortImage(InputArray distorted, OutputArray undistorted, - InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size()) +.. ocv:function:: void Fisheye::undistortImage(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size()) :param distorted: image with fisheye lens distortion. @@ -1706,7 +1701,7 @@ The function is simply a combination of See below the results of undistortImage. * a\) result of :ocv:func:`undistort` of perspective camera model (all possible coefficients (k_1, k_2, k_3, k_4, k_5, k_6) of distortion were optimized under calibration) - * b\) result of :ocv:func:`Fisheye::undistrortImage` of fisheye camera model (all possible coefficients (k_1, k_2, k_3, k_4) of fisheye distortion were optimized under calibration) + * b\) result of :ocv:func:`Fisheye::undistortImage` of fisheye camera model (all possible coefficients (k_1, k_2, k_3, k_4) of fisheye distortion were optimized under calibration) * c\) original image was captured with fisheye lens Pictures a) and b) almost the same. But if we consider points of image located far from the center of image, we can notice that on image a) these points are distorted. @@ -1718,14 +1713,13 @@ Fisheye::estimateNewCameraMatrixForUndistortRectify ---------------------------------------------------------- Estimates new camera matrix for undistortion or rectification. -.. ocv:function:: void Fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R, - OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0); +.. ocv:function:: void Fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R, OutputArray P, double balance = 0.0, const Size& new_size = Size(), double fov_scale = 1.0) :param K: Camera matrix :math:`K = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{_1}`. :param D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`. - :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel + :param R: Rectification transformation in the object space: 3x3 1-channel, or vector: 3x1/1x3 1-channel or 1x1 3-channel :param P: New camera matrix (3x3) or new projection matrix (3x4) @@ -1737,9 +1731,7 @@ Fisheye::stereoRectify ------------------------------ Stereo rectification for fisheye camera model -.. ocv:function:: void Fisheye::stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec, - OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), - double balance = 0.0, double fov_scale = 1.0) +.. ocv:function:: void Fisheye::stereoRectify(InputArray K1, InputArray D1, InputArray K2, InputArray D2, const Size &imageSize, InputArray R, InputArray tvec, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags, const Size &newImageSize = Size(), double balance = 0.0, double fov_scale = 1.0) :param K1: First camera matrix. @@ -1785,9 +1777,7 @@ Fisheye::calibrate ---------------------------- Performs camera calibaration -.. ocv:function:: double Fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size, - InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0, - TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)) +.. ocv:function:: double Fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size, InputOutputArray K, InputOutputArray D, OutputArrayOfArrays rvecs, OutputArrayOfArrays tvecs, int flags = 0, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)) :param objectPoints: vector of vectors of calibration pattern points in the calibration pattern coordinate space. @@ -1820,9 +1810,9 @@ Performs camera calibaration Fisheye::stereoCalibrate ---------------------------- -Performs stereo calibration calibaration +Performs stereo calibration -.. ocv:function:: double stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)) +.. ocv:function:: double Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints1, InputArrayOfArrays imagePoints2, InputOutputArray K1, InputOutputArray D1, InputOutputArray K2, InputOutputArray D2, Size imageSize, OutputArray R, OutputArray T, int flags = CALIB_FIX_INTRINSIC, TermCriteria criteria = TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, DBL_EPSILON)) :param objectPoints: Vector of vectors of the calibration pattern points. diff --git a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp index 67cf568..0b048fe 100644 --- a/modules/calib3d/include/opencv2/calib3d/calib3d.hpp +++ b/modules/calib3d/include/opencv2/calib3d/calib3d.hpp @@ -745,7 +745,7 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst, OutputArray out, OutputArray inliers, double ransacThreshold=3, double confidence=0.99); -class Fisheye +class CV_EXPORTS Fisheye { public: diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index 50dd045..da7a839 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -1,8 +1,4 @@ -#include "opencv2/opencv.hpp" -#include "opencv2/core/affine.hpp" -#include "opencv2/core/affine.hpp" #include "fisheye.hpp" -#include "iomanip" namespace cv { namespace { @@ -46,6 +42,7 @@ void cv::Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints cv::Vec2d f, c; if (_K.depth() == CV_32F) { + Matx33f K = _K.getMat(); f = Vec2f(K(0, 0), K(1, 1)); c = Vec2f(K(0, 2), K(1, 2)); @@ -786,8 +783,8 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO const double thresh_cond = 1e6; const int check_cond = 1; - size_t n_points = objectPoints.getMat(0).total(); - size_t n_images = objectPoints.total(); + int n_points = (int)objectPoints.getMat(0).total(); + int n_images = (int)objectPoints.total(); double change = 1; @@ -856,7 +853,7 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO //Init values for rotation and translation between two views cv::Mat om_list(1, n_images, CV_64FC3), T_list(1, n_images, CV_64FC3); cv::Mat om_ref, R_ref, T_ref, R1, R2; - for (size_t image_idx = 0; image_idx < n_images; ++image_idx) + for (int image_idx = 0; image_idx < n_images; ++image_idx) { cv::Rodrigues(rvecs1[image_idx], R1); cv::Rodrigues(rvecs2[image_idx], R2); @@ -887,7 +884,7 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO cv::Mat omr, Tr, domrdomckk, domrdTckk, domrdom, domrdT, dTrdomckk, dTrdTckk, dTrdom, dTrdT; - for (size_t image_idx = 0; image_idx < n_images; ++image_idx) + for (int image_idx = 0; image_idx < n_images; ++image_idx) { Jkk = cv::Mat::zeros(4 * n_points, 18 + 6 * (n_images + 1), CV_64FC1); @@ -931,22 +928,18 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO //check goodness of sterepair double abs_max = 0; - for (size_t i = 0; i < 4 * n_points; i++) + for (int i = 0; i < 4 * n_points; i++) { if (fabs(ekk.at(i)) > abs_max) { abs_max = fabs(ekk.at(i)); } } - if (abs_max < threshold) - { - Jkk.copyTo(J.rowRange(image_idx * 4 * n_points, (image_idx + 1) * 4 * n_points)); - ekk.copyTo(e.rowRange(image_idx * 4 * n_points, (image_idx + 1) * 4 * n_points)); - } - else - { - CV_Assert(!"Bad stereo pair"); - } + + CV_Assert(abs_max < threshold); // bad stereo pair + + Jkk.copyTo(J.rowRange(image_idx * 4 * n_points, (image_idx + 1) * 4 * n_points)); + ekk.copyTo(e.rowRange(image_idx * 4 * n_points, (image_idx + 1) * 4 * n_points)); } cv::Vec6d oldTom(Tcur[0], Tcur[1], Tcur[2], omcur[0], omcur[1], omcur[2]); @@ -962,7 +955,7 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO intrinsicRight = intrinsicRight + deltas.rowRange(a, a + b); omcur = omcur + cv::Vec3d(deltas.rowRange(a + b, a + b + 3)); Tcur = Tcur + cv::Vec3d(deltas.rowRange(a + b + 3, a + b + 6)); - for (size_t image_idx = 0; image_idx < n_images; ++image_idx) + for (int image_idx = 0; image_idx < n_images; ++image_idx) { rvecs1[image_idx] = cv::Mat(cv::Mat(rvecs1[image_idx]) + deltas.rowRange(a + b + 6 + image_idx * 6, a + b + 9 + image_idx * 6)); tvecs1[image_idx] = cv::Mat(cv::Mat(tvecs1[image_idx]) + deltas.rowRange(a + b + 9 + image_idx * 6, a + b + 12 + image_idx * 6)); @@ -979,7 +972,7 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO rms += ptr_e[i][0] * ptr_e[i][0] + ptr_e[i][1] * ptr_e[i][1]; } - rms /= (e.total() / 2); + rms /= ((double)e.total() / 2.0); rms = sqrt(rms); _K1 = Matx33d(intrinsicLeft.f[0], intrinsicLeft.f[0] * intrinsicLeft.alpha, intrinsicLeft.c[0], @@ -1011,7 +1004,7 @@ void subMatrix(const Mat& src, Mat& dst, const vector& cols, const vector& cols, const vector(0) / svd.w.at((int)svd.w.total() - 1) > thresh_cond) - { - CV_Assert(!"cond > thresh_cond"); - } + CV_Assert(svd.w.at(0) / svd.w.at((int)svd.w.total() - 1) < thresh_cond); } omckk.reshape(3,1).copyTo(omc.getMat().col(image_idx)); Tckk.reshape(3,1).copyTo(Tc.getMat().col(image_idx)); @@ -1392,11 +1382,7 @@ void cv::internal::ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayO { Mat JJ_kk = B.t(); SVD svd(JJ_kk, SVD::NO_UV); - double cond = svd.w.at(0) / svd.w.at(svd.w.rows - 1); - if (cond > thresh_cond) - { - CV_Assert(!"cond > thresh_cond"); - } + CV_Assert(svd.w.at(0) / svd.w.at(svd.w.rows - 1) < thresh_cond); } } @@ -1420,7 +1406,7 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA Mat ex((int)(objectPoints.getMat(0).total() * objectPoints.total()), 1, CV_64FC2); - for (size_t image_idx = 0; image_idx < objectPoints.total(); ++image_idx) + for (int image_idx = 0; image_idx < (int)objectPoints.total(); ++image_idx) { Mat image, object; objectPoints.getMat(image_idx).convertTo(object, CV_64FC3); @@ -1435,11 +1421,11 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA } meanStdDev(ex, noArray(), std_err); - std_err *= sqrt(ex.total()/(ex.total() - 1.0)); + std_err *= sqrt((double)ex.total()/((double)ex.total() - 1.0)); Mat sigma_x; meanStdDev(ex.reshape(1, 1), noArray(), sigma_x); - sigma_x *= sqrt(2 * ex.total()/(2 * ex.total() - 1.0)); + sigma_x *= sqrt(2.0 * (double)ex.total()/(2.0 * (double)ex.total() - 1.0)); Mat _JJ2_inv, ex3; ComputeJacobians(objectPoints, imagePoints, params, omc, Tc, check_cond, thresh_cond, _JJ2_inv, ex3); @@ -1459,7 +1445,7 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA rms += ptr_ex[i][0] * ptr_ex[i][0] + ptr_ex[i][1] * ptr_ex[i][1]; } - rms /= ex.total(); + rms /= (double)ex.total(); rms = sqrt(rms); } @@ -1468,9 +1454,9 @@ void cv::internal::dAB(InputArray A, InputArray B, OutputArray dABdA, OutputArra CV_Assert(A.getMat().cols == B.getMat().rows); CV_Assert(A.type() == CV_64FC1 && B.type() == CV_64FC1); - size_t p = A.getMat().rows; - size_t n = A.getMat().cols; - size_t q = B.getMat().cols; + int p = A.getMat().rows; + int n = A.getMat().cols; + int q = B.getMat().cols; dABdA.create(p * q, p * n, CV_64FC1); dABdB.create(p * q, q * n, CV_64FC1); @@ -1478,20 +1464,20 @@ void cv::internal::dAB(InputArray A, InputArray B, OutputArray dABdA, OutputArra dABdA.getMat() = Mat::zeros(p * q, p * n, CV_64FC1); dABdB.getMat() = Mat::zeros(p * q, q * n, CV_64FC1); - for (size_t i = 0; i < q; ++i) + for (int i = 0; i < q; ++i) { - for (size_t j = 0; j < p; ++j) + for (int j = 0; j < p; ++j) { - size_t ij = j + i * p; - for (size_t k = 0; k < n; ++k) + int ij = j + i * p; + for (int k = 0; k < n; ++k) { - size_t kj = j + k * p; + int kj = j + k * p; dABdA.getMat().at(ij, kj) = B.getMat().at(k, i); } } } - for (size_t i = 0; i < q; ++i) + for (int i = 0; i < q; ++i) { A.getMat().copyTo(dABdB.getMat().rowRange(i * p, i * p + p).colRange(i * n, i * n + n)); } @@ -1571,8 +1557,8 @@ double cv::internal::median(const Mat& row) CV_Assert(!row.empty() && row.rows == 1); Mat tmp = row.clone(); sort(tmp, tmp, 0); - if (tmp.total() % 2) return tmp.at(tmp.total() / 2); - else return 0.5 *(tmp.at(tmp.total() / 2) + tmp.at(tmp.total() / 2 - 1)); + if ((int)tmp.total() % 2) return tmp.at((int)tmp.total() / 2); + else return 0.5 *(tmp.at((int)tmp.total() / 2) + tmp.at((int)tmp.total() / 2 - 1)); } cv::Vec3d cv::internal::median3d(InputArray m) diff --git a/modules/calib3d/src/fisheye.hpp b/modules/calib3d/src/fisheye.hpp index fa4bfdb..82c9f34 100644 --- a/modules/calib3d/src/fisheye.hpp +++ b/modules/calib3d/src/fisheye.hpp @@ -1,9 +1,10 @@ #ifndef FISHEYE_INTERNAL_H #define FISHEYE_INTERNAL_H +#include "precomp.hpp" namespace cv { namespace internal { -struct IntrinsicParams +struct CV_EXPORTS IntrinsicParams { Vec2d f; Vec2d c; @@ -25,9 +26,9 @@ void projectPoints(cv::InputArray objectPoints, cv::OutputArray imagePoints, void ComputeExtrinsicRefine(const Mat& imagePoints, const Mat& objectPoints, Mat& rvec, Mat& tvec, Mat& J, const int MaxIter, const IntrinsicParams& param, const double thresh_cond); -Mat ComputeHomography(Mat m, Mat M); +CV_EXPORTS Mat ComputeHomography(Mat m, Mat M); -Mat NormalizePixels(const Mat& imagePoints, const IntrinsicParams& param); +CV_EXPORTS Mat NormalizePixels(const Mat& imagePoints, const IntrinsicParams& param); void InitExtrinsics(const Mat& _imagePoints, const Mat& _objectPoints, const IntrinsicParams& param, Mat& omckk, Mat& Tckk); @@ -39,7 +40,7 @@ void ComputeJacobians(InputArrayOfArrays objectPoints, InputArrayOfArrays imageP const IntrinsicParams& param, InputArray omc, InputArray Tc, const int& check_cond, const double& thresh_cond, Mat& JJ2_inv, Mat& ex3); -void EstimateUncertainties(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, +CV_EXPORTS void EstimateUncertainties(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const IntrinsicParams& params, InputArray omc, InputArray Tc, IntrinsicParams& errors, Vec2d& std_err, double thresh_cond, int check_cond, double& rms); diff --git a/modules/calib3d/test/test_fisheye.cpp b/modules/calib3d/test/test_fisheye.cpp index dfdba98..7457a94 100644 --- a/modules/calib3d/test/test_fisheye.cpp +++ b/modules/calib3d/test/test_fisheye.cpp @@ -1,5 +1,4 @@ #include "test_precomp.hpp" -#include #include #include "../src/fisheye.hpp" -- 2.7.4