mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 19:50:38 +08:00
Fixed build issues
This commit is contained in:
parent
e4a9c0f184
commit
c30fef1f9d
@ -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(),
|
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);
|
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:
|
Definitions:
|
||||||
Let P be a point in 3D of coordinates X in the world reference frame (stored in the matrix X)
|
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
|
.. class:: center
|
||||||
.. math::
|
.. math::
|
||||||
@ -1556,13 +1560,13 @@ call x, y and z the 3 coordinates of Xc:
|
|||||||
.. math::
|
.. math::
|
||||||
x = Xc_1 \\
|
x = Xc_1 \\
|
||||||
y = Xc_2 \\
|
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
|
.. class:: center
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
a = x / z \ and \ b = y / z \\
|
a = x / z \ and \ b = y / z \\
|
||||||
r^2 = a^2 + b^2 \\
|
r^2 = a^2 + b^2 \\
|
||||||
\theta = atan(r)
|
\theta = atan(r)
|
||||||
@ -1570,22 +1574,22 @@ The pinehole projection coordinates of P is [a; b] where
|
|||||||
Fisheye distortion:
|
Fisheye distortion:
|
||||||
|
|
||||||
.. class:: center
|
.. class:: center
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
\theta_d = \theta (1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8)
|
\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
|
The distorted point coordinates are [x'; y'] where
|
||||||
|
|
||||||
.. class:: center
|
..class:: center
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
x' = (\theta_d / r) x \\
|
x' = (\theta_d / r) x \\
|
||||||
y' = (\theta_d / r) y
|
y' = (\theta_d / r) y
|
||||||
|
|
||||||
Finally, convertion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
Finally, convertion into pixel coordinates: The final pixel coordinates vector [u; v] where:
|
||||||
|
|
||||||
.. class:: center
|
.. class:: center
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
u = f_x (x' + \alpha y') + c_x \\
|
u = f_x (x' + \alpha y') + c_x \\
|
||||||
v = f_y yy + c_y
|
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, 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,
|
.. ocv:function:: void Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints, InputArray rvec, InputArray tvec, InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray())
|
||||||
InputArray K, InputArray D, double alpha = 0, OutputArray jacobian = noArray())
|
|
||||||
|
|
||||||
:param objectPoints: Array of object points, 1xN/Nx1 3-channel (or ``vector<Point3f>`` ), where N is the number of points in the view.
|
:param objectPoints: Array of object points, 1xN/Nx1 3-channel (or ``vector<Point3f>`` ), 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 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 D: Input vector of distortion coefficients :math:`(k_1, k_2, k_3, k_4)`.
|
||||||
|
|
||||||
:param alpha: The skew coefficient.
|
:param alpha: The skew coefficient.
|
||||||
|
|
||||||
:param imagePoints: Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or ``vector<Point2f>`` .
|
:param imagePoints: Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1 2-channel, or ``vector<Point2f>``.
|
||||||
|
|
||||||
: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.
|
: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
|
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.
|
||||||
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
|
Fisheye::distortPoints
|
||||||
-------------------------
|
-------------------------
|
||||||
Distorts 2D points using fisheye model.
|
Distorts 2D points using fisheye model.
|
||||||
|
|
||||||
.. ocv:function:: void Fisheye::distortPoints(InputArray undistorted, OutputArray distorted, InputArray K, InputArray D, double alpha = 0)
|
.. 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<Point2f>`` ), where N is the number of points in the view.
|
:param undistorted: Array of object points, 1xN/Nx1 2-channel (or ``vector<Point2f>`` ), 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}`.
|
: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
|
Undistorts 2D points using fisheye model
|
||||||
|
|
||||||
.. ocv:function:: void Fisheye::undistortPoints(InputArray distorted, OutputArray undistorted,
|
.. ocv:function:: void Fisheye::undistortPoints(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray())
|
||||||
InputArray K, InputArray D, InputArray R = noArray(), InputArray P = noArray())
|
|
||||||
|
|
||||||
:param distorted: Array of object points, 1xN/Nx1 2-channel (or ``vector<Point2f>`` ), where N is the number of points in the view.
|
:param distorted: Array of object points, 1xN/Nx1 2-channel (or ``vector<Point2f>`` ), 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 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 P: New camera matrix (3x3) or new projection matrix (3x4)
|
||||||
|
|
||||||
:param undistorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector<Point2f>`` .
|
:param undistorted: Output array of image points, 1xN/Nx1 2-channel, or ``vector<Point2f>`` .
|
||||||
|
|
||||||
|
|
||||||
Fisheye::initUndistortRectifyMap
|
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.
|
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,
|
.. ocv:function:: void Fisheye::initUndistortRectifyMap(InputArray K, InputArray D, InputArray R, InputArray P, const cv::Size& size, int m1type, OutputArray map1, OutputArray map2)
|
||||||
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 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 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 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.
|
:param map2: The second output map.
|
||||||
|
|
||||||
Fisheye::undistortImage
|
Fisheye::undistortImage
|
||||||
-------------
|
-----------------------
|
||||||
Transforms an image to compensate for fisheye lens distortion.
|
Transforms an image to compensate for fisheye lens distortion.
|
||||||
|
|
||||||
.. ocv:function:: void Fisheye::undistortImage(InputArray distorted, OutputArray undistorted,
|
.. ocv:function:: void Fisheye::undistortImage(InputArray distorted, OutputArray undistorted, InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size())
|
||||||
InputArray K, InputArray D, InputArray Knew = cv::noArray(), const Size& new_size = Size())
|
|
||||||
|
|
||||||
:param distorted: image with fisheye lens distortion.
|
:param distorted: image with fisheye lens distortion.
|
||||||
|
|
||||||
@ -1706,7 +1701,7 @@ The function is simply a combination of
|
|||||||
|
|
||||||
See below the results of undistortImage.
|
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)
|
* 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
|
* 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.
|
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.
|
Estimates new camera matrix for undistortion or rectification.
|
||||||
|
|
||||||
.. ocv:function:: void Fisheye::estimateNewCameraMatrixForUndistortRectify(InputArray K, InputArray D, const Size &image_size, InputArray R,
|
.. 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)
|
||||||
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 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 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 P: New camera matrix (3x3) or new projection matrix (3x4)
|
||||||
|
|
||||||
@ -1737,9 +1731,7 @@ Fisheye::stereoRectify
|
|||||||
------------------------------
|
------------------------------
|
||||||
Stereo rectification for fisheye camera model
|
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,
|
.. 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)
|
||||||
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.
|
:param K1: First camera matrix.
|
||||||
|
|
||||||
@ -1785,9 +1777,7 @@ Fisheye::calibrate
|
|||||||
----------------------------
|
----------------------------
|
||||||
Performs camera calibaration
|
Performs camera calibaration
|
||||||
|
|
||||||
.. ocv:function:: double Fisheye::calibrate(InputArrayOfArrays objectPoints, InputArrayOfArrays imagePoints, const Size& image_size,
|
.. 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))
|
||||||
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.
|
:param objectPoints: vector of vectors of calibration pattern points in the calibration pattern coordinate space.
|
||||||
|
|
||||||
@ -1820,9 +1810,9 @@ Performs camera calibaration
|
|||||||
|
|
||||||
Fisheye::stereoCalibrate
|
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.
|
:param objectPoints: Vector of vectors of the calibration pattern points.
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ CV_EXPORTS_W int estimateAffine3D(InputArray src, InputArray dst,
|
|||||||
OutputArray out, OutputArray inliers,
|
OutputArray out, OutputArray inliers,
|
||||||
double ransacThreshold=3, double confidence=0.99);
|
double ransacThreshold=3, double confidence=0.99);
|
||||||
|
|
||||||
class Fisheye
|
class CV_EXPORTS Fisheye
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
#include "opencv2/opencv.hpp"
|
|
||||||
#include "opencv2/core/affine.hpp"
|
|
||||||
#include "opencv2/core/affine.hpp"
|
|
||||||
#include "fisheye.hpp"
|
#include "fisheye.hpp"
|
||||||
#include "iomanip"
|
|
||||||
|
|
||||||
namespace cv { namespace
|
namespace cv { namespace
|
||||||
{
|
{
|
||||||
@ -46,6 +42,7 @@ void cv::Fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints
|
|||||||
cv::Vec2d f, c;
|
cv::Vec2d f, c;
|
||||||
if (_K.depth() == CV_32F)
|
if (_K.depth() == CV_32F)
|
||||||
{
|
{
|
||||||
|
|
||||||
Matx33f K = _K.getMat();
|
Matx33f K = _K.getMat();
|
||||||
f = Vec2f(K(0, 0), K(1, 1));
|
f = Vec2f(K(0, 0), K(1, 1));
|
||||||
c = Vec2f(K(0, 2), K(1, 2));
|
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 double thresh_cond = 1e6;
|
||||||
const int check_cond = 1;
|
const int check_cond = 1;
|
||||||
|
|
||||||
size_t n_points = objectPoints.getMat(0).total();
|
int n_points = (int)objectPoints.getMat(0).total();
|
||||||
size_t n_images = objectPoints.total();
|
int n_images = (int)objectPoints.total();
|
||||||
|
|
||||||
double change = 1;
|
double change = 1;
|
||||||
|
|
||||||
@ -856,7 +853,7 @@ double cv::Fisheye::stereoCalibrate(InputArrayOfArrays objectPoints, InputArrayO
|
|||||||
//Init values for rotation and translation between two views
|
//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_list(1, n_images, CV_64FC3), T_list(1, n_images, CV_64FC3);
|
||||||
cv::Mat om_ref, R_ref, T_ref, R1, R2;
|
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(rvecs1[image_idx], R1);
|
||||||
cv::Rodrigues(rvecs2[image_idx], R2);
|
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;
|
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);
|
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
|
//check goodness of sterepair
|
||||||
double abs_max = 0;
|
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<double>(i)) > abs_max)
|
if (fabs(ekk.at<double>(i)) > abs_max)
|
||||||
{
|
{
|
||||||
abs_max = fabs(ekk.at<double>(i));
|
abs_max = fabs(ekk.at<double>(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (abs_max < threshold)
|
|
||||||
{
|
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));
|
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::Vec6d oldTom(Tcur[0], Tcur[1], Tcur[2], omcur[0], omcur[1], omcur[2]);
|
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);
|
intrinsicRight = intrinsicRight + deltas.rowRange(a, a + b);
|
||||||
omcur = omcur + cv::Vec3d(deltas.rowRange(a + b, a + b + 3));
|
omcur = omcur + cv::Vec3d(deltas.rowRange(a + b, a + b + 3));
|
||||||
Tcur = Tcur + cv::Vec3d(deltas.rowRange(a + b + 3, a + b + 6));
|
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));
|
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));
|
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 += 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);
|
rms = sqrt(rms);
|
||||||
|
|
||||||
_K1 = Matx33d(intrinsicLeft.f[0], intrinsicLeft.f[0] * intrinsicLeft.alpha, intrinsicLeft.c[0],
|
_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<int>& cols, const vector<i
|
|||||||
int nonzeros_cols = cv::countNonZero(cols);
|
int nonzeros_cols = cv::countNonZero(cols);
|
||||||
Mat tmp(src.rows, nonzeros_cols, CV_64FC1);
|
Mat tmp(src.rows, nonzeros_cols, CV_64FC1);
|
||||||
|
|
||||||
for (size_t i = 0, j = 0; i < cols.size(); i++)
|
for (int i = 0, j = 0; i < (int)cols.size(); i++)
|
||||||
{
|
{
|
||||||
if (cols[i])
|
if (cols[i])
|
||||||
{
|
{
|
||||||
@ -1021,7 +1014,7 @@ void subMatrix(const Mat& src, Mat& dst, const vector<int>& cols, const vector<i
|
|||||||
|
|
||||||
int nonzeros_rows = cv::countNonZero(rows);
|
int nonzeros_rows = cv::countNonZero(rows);
|
||||||
Mat tmp1(nonzeros_rows, nonzeros_cols, CV_64FC1);
|
Mat tmp1(nonzeros_rows, nonzeros_cols, CV_64FC1);
|
||||||
for (size_t i = 0, j = 0; i < rows.size(); i++)
|
for (int i = 0, j = 0; i < (int)rows.size(); i++)
|
||||||
{
|
{
|
||||||
if (rows[i])
|
if (rows[i])
|
||||||
{
|
{
|
||||||
@ -1328,10 +1321,7 @@ void cv::internal::CalibrateExtrinsics(InputArrayOfArrays objectPoints, InputArr
|
|||||||
if (check_cond)
|
if (check_cond)
|
||||||
{
|
{
|
||||||
SVD svd(JJ_kk, SVD::NO_UV);
|
SVD svd(JJ_kk, SVD::NO_UV);
|
||||||
if (svd.w.at<double>(0) / svd.w.at<double>((int)svd.w.total() - 1) > thresh_cond)
|
CV_Assert(svd.w.at<double>(0) / svd.w.at<double>((int)svd.w.total() - 1) < thresh_cond);
|
||||||
{
|
|
||||||
CV_Assert(!"cond > thresh_cond");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
omckk.reshape(3,1).copyTo(omc.getMat().col(image_idx));
|
omckk.reshape(3,1).copyTo(omc.getMat().col(image_idx));
|
||||||
Tckk.reshape(3,1).copyTo(Tc.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();
|
Mat JJ_kk = B.t();
|
||||||
SVD svd(JJ_kk, SVD::NO_UV);
|
SVD svd(JJ_kk, SVD::NO_UV);
|
||||||
double cond = svd.w.at<double>(0) / svd.w.at<double>(svd.w.rows - 1);
|
CV_Assert(svd.w.at<double>(0) / svd.w.at<double>(svd.w.rows - 1) < thresh_cond);
|
||||||
if (cond > thresh_cond)
|
|
||||||
{
|
|
||||||
CV_Assert(!"cond > 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);
|
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;
|
Mat image, object;
|
||||||
objectPoints.getMat(image_idx).convertTo(object, CV_64FC3);
|
objectPoints.getMat(image_idx).convertTo(object, CV_64FC3);
|
||||||
@ -1435,11 +1421,11 @@ void cv::internal::EstimateUncertainties(InputArrayOfArrays objectPoints, InputA
|
|||||||
}
|
}
|
||||||
|
|
||||||
meanStdDev(ex, noArray(), std_err);
|
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;
|
Mat sigma_x;
|
||||||
meanStdDev(ex.reshape(1, 1), noArray(), 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;
|
Mat _JJ2_inv, ex3;
|
||||||
ComputeJacobians(objectPoints, imagePoints, params, omc, Tc, check_cond, thresh_cond, _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 += 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);
|
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.getMat().cols == B.getMat().rows);
|
||||||
CV_Assert(A.type() == CV_64FC1 && B.type() == CV_64FC1);
|
CV_Assert(A.type() == CV_64FC1 && B.type() == CV_64FC1);
|
||||||
|
|
||||||
size_t p = A.getMat().rows;
|
int p = A.getMat().rows;
|
||||||
size_t n = A.getMat().cols;
|
int n = A.getMat().cols;
|
||||||
size_t q = B.getMat().cols;
|
int q = B.getMat().cols;
|
||||||
|
|
||||||
dABdA.create(p * q, p * n, CV_64FC1);
|
dABdA.create(p * q, p * n, CV_64FC1);
|
||||||
dABdB.create(p * q, q * 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);
|
dABdA.getMat() = Mat::zeros(p * q, p * n, CV_64FC1);
|
||||||
dABdB.getMat() = Mat::zeros(p * q, q * 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;
|
int ij = j + i * p;
|
||||||
for (size_t k = 0; k < n; ++k)
|
for (int k = 0; k < n; ++k)
|
||||||
{
|
{
|
||||||
size_t kj = j + k * p;
|
int kj = j + k * p;
|
||||||
dABdA.getMat().at<double>(ij, kj) = B.getMat().at<double>(k, i);
|
dABdA.getMat().at<double>(ij, kj) = B.getMat().at<double>(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));
|
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);
|
CV_Assert(!row.empty() && row.rows == 1);
|
||||||
Mat tmp = row.clone();
|
Mat tmp = row.clone();
|
||||||
sort(tmp, tmp, 0);
|
sort(tmp, tmp, 0);
|
||||||
if (tmp.total() % 2) return tmp.at<double>(tmp.total() / 2);
|
if ((int)tmp.total() % 2) return tmp.at<double>((int)tmp.total() / 2);
|
||||||
else return 0.5 *(tmp.at<double>(tmp.total() / 2) + tmp.at<double>(tmp.total() / 2 - 1));
|
else return 0.5 *(tmp.at<double>((int)tmp.total() / 2) + tmp.at<double>((int)tmp.total() / 2 - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::Vec3d cv::internal::median3d(InputArray m)
|
cv::Vec3d cv::internal::median3d(InputArray m)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#ifndef FISHEYE_INTERNAL_H
|
#ifndef FISHEYE_INTERNAL_H
|
||||||
#define FISHEYE_INTERNAL_H
|
#define FISHEYE_INTERNAL_H
|
||||||
|
#include "precomp.hpp"
|
||||||
|
|
||||||
namespace cv { namespace internal {
|
namespace cv { namespace internal {
|
||||||
|
|
||||||
struct IntrinsicParams
|
struct CV_EXPORTS IntrinsicParams
|
||||||
{
|
{
|
||||||
Vec2d f;
|
Vec2d f;
|
||||||
Vec2d c;
|
Vec2d c;
|
||||||
@ -25,9 +26,9 @@ void projectPoints(cv::InputArray objectPoints, cv::OutputArray imagePoints,
|
|||||||
void ComputeExtrinsicRefine(const Mat& imagePoints, const Mat& objectPoints, Mat& rvec,
|
void ComputeExtrinsicRefine(const Mat& imagePoints, const Mat& objectPoints, Mat& rvec,
|
||||||
Mat& tvec, Mat& J, const int MaxIter,
|
Mat& tvec, Mat& J, const int MaxIter,
|
||||||
const IntrinsicParams& param, const double thresh_cond);
|
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);
|
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 IntrinsicParams& param, InputArray omc, InputArray Tc,
|
||||||
const int& check_cond, const double& thresh_cond, Mat& JJ2_inv, Mat& ex3);
|
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,
|
const IntrinsicParams& params, InputArray omc, InputArray Tc,
|
||||||
IntrinsicParams& errors, Vec2d& std_err, double thresh_cond, int check_cond, double& rms);
|
IntrinsicParams& errors, Vec2d& std_err, double thresh_cond, int check_cond, double& rms);
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "test_precomp.hpp"
|
#include "test_precomp.hpp"
|
||||||
#include <fstream>
|
|
||||||
#include <opencv2/ts/gpu_test.hpp>
|
#include <opencv2/ts/gpu_test.hpp>
|
||||||
#include "../src/fisheye.hpp"
|
#include "../src/fisheye.hpp"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user