|
OpenCV 2.4.2 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.opencv.calib3d.Calib3d
public class Calib3d
Field Summary | |
---|---|
static int |
CALIB_CB_ADAPTIVE_THRESH
|
static int |
CALIB_CB_ASYMMETRIC_GRID
|
static int |
CALIB_CB_CLUSTERING
|
static int |
CALIB_CB_FAST_CHECK
|
static int |
CALIB_CB_FILTER_QUADS
|
static int |
CALIB_CB_NORMALIZE_IMAGE
|
static int |
CALIB_CB_SYMMETRIC_GRID
|
static int |
CALIB_FIX_ASPECT_RATIO
|
static int |
CALIB_FIX_FOCAL_LENGTH
|
static int |
CALIB_FIX_INTRINSIC
|
static int |
CALIB_FIX_K1
|
static int |
CALIB_FIX_K2
|
static int |
CALIB_FIX_K3
|
static int |
CALIB_FIX_K4
|
static int |
CALIB_FIX_K5
|
static int |
CALIB_FIX_K6
|
static int |
CALIB_FIX_PRINCIPAL_POINT
|
static int |
CALIB_RATIONAL_MODEL
|
static int |
CALIB_SAME_FOCAL_LENGTH
|
static int |
CALIB_USE_INTRINSIC_GUESS
|
static int |
CALIB_ZERO_DISPARITY
|
static int |
CALIB_ZERO_TANGENT_DIST
|
static int |
CV_EPNP
|
static int |
CV_ITERATIVE
|
static int |
CV_P3P
|
static int |
EPNP
|
static int |
FM_7POINT
|
static int |
FM_8POINT
|
static int |
FM_LMEDS
|
static int |
FM_RANSAC
|
static int |
ITERATIVE
|
static int |
LMEDS
|
static int |
P3P
|
static int |
RANSAC
|
Constructor Summary | |
---|---|
Calib3d()
|
Method Summary | |
---|---|
static double |
calibrateCamera(java.util.List<Mat> objectPoints,
java.util.List<Mat> imagePoints,
Size imageSize,
Mat cameraMatrix,
Mat distCoeffs,
java.util.List<Mat> rvecs,
java.util.List<Mat> tvecs)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. |
static double |
calibrateCamera(java.util.List<Mat> objectPoints,
java.util.List<Mat> imagePoints,
Size imageSize,
Mat cameraMatrix,
Mat distCoeffs,
java.util.List<Mat> rvecs,
java.util.List<Mat> tvecs,
int flags)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. |
static double |
calibrateCamera(java.util.List<Mat> objectPoints,
java.util.List<Mat> imagePoints,
Size imageSize,
Mat cameraMatrix,
Mat distCoeffs,
java.util.List<Mat> rvecs,
java.util.List<Mat> tvecs,
int flags,
TermCriteria criteria)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern. |
static void |
calibrationMatrixValues(Mat cameraMatrix,
Size imageSize,
double apertureWidth,
double apertureHeight,
double[] fovx,
double[] fovy,
double[] focalLength,
Point principalPoint,
double[] aspectRatio)
Computes useful camera characteristics from the camera matrix. |
static void |
composeRT(Mat rvec1,
Mat tvec1,
Mat rvec2,
Mat tvec2,
Mat rvec3,
Mat tvec3)
Combines two rotation-and-shift transformations. |
static void |
composeRT(Mat rvec1,
Mat tvec1,
Mat rvec2,
Mat tvec2,
Mat rvec3,
Mat tvec3,
Mat dr3dr1,
Mat dr3dt1,
Mat dr3dr2,
Mat dr3dt2,
Mat dt3dr1,
Mat dt3dt1,
Mat dt3dr2,
Mat dt3dt2)
Combines two rotation-and-shift transformations. |
static void |
convertPointsFromHomogeneous(Mat src,
Mat dst)
Converts points from homogeneous to Euclidean space. |
static void |
convertPointsToHomogeneous(Mat src,
Mat dst)
Converts points from Euclidean to homogeneous space. |
static void |
correctMatches(Mat F,
Mat points1,
Mat points2,
Mat newPoints1,
Mat newPoints2)
Refines coordinates of corresponding points. |
static void |
decomposeProjectionMatrix(Mat projMatrix,
Mat cameraMatrix,
Mat rotMatrix,
Mat transVect)
Decomposes a projection matrix into a rotation matrix and a camera matrix. |
static void |
decomposeProjectionMatrix(Mat projMatrix,
Mat cameraMatrix,
Mat rotMatrix,
Mat transVect,
Mat rotMatrixX,
Mat rotMatrixY,
Mat rotMatrixZ,
Mat eulerAngles)
Decomposes a projection matrix into a rotation matrix and a camera matrix. |
static void |
drawChessboardCorners(Mat image,
Size patternSize,
MatOfPoint2f corners,
boolean patternWasFound)
Renders the detected chessboard corners. |
static int |
estimateAffine3D(Mat src,
Mat dst,
Mat out,
Mat inliers)
Computes an optimal affine transformation between two 3D point sets. |
static int |
estimateAffine3D(Mat src,
Mat dst,
Mat out,
Mat inliers,
double ransacThreshold,
double confidence)
Computes an optimal affine transformation between two 3D point sets. |
static void |
filterSpeckles(Mat img,
double newVal,
int maxSpeckleSize,
double maxDiff)
Filters off small noise blobs (speckles) in the disparity map |
static void |
filterSpeckles(Mat img,
double newVal,
int maxSpeckleSize,
double maxDiff,
Mat buf)
Filters off small noise blobs (speckles) in the disparity map |
static boolean |
findChessboardCorners(Mat image,
Size patternSize,
MatOfPoint2f corners)
Finds the positions of internal corners of the chessboard. |
static boolean |
findChessboardCorners(Mat image,
Size patternSize,
MatOfPoint2f corners,
int flags)
Finds the positions of internal corners of the chessboard. |
static boolean |
findCirclesGridDefault(Mat image,
Size patternSize,
Mat centers)
|
static boolean |
findCirclesGridDefault(Mat image,
Size patternSize,
Mat centers,
int flags)
|
static Mat |
findFundamentalMat(MatOfPoint2f points1,
MatOfPoint2f points2)
Calculates a fundamental matrix from the corresponding points in two images. |
static Mat |
findFundamentalMat(MatOfPoint2f points1,
MatOfPoint2f points2,
int method,
double param1,
double param2)
Calculates a fundamental matrix from the corresponding points in two images. |
static Mat |
findFundamentalMat(MatOfPoint2f points1,
MatOfPoint2f points2,
int method,
double param1,
double param2,
Mat mask)
Calculates a fundamental matrix from the corresponding points in two images. |
static Mat |
findHomography(MatOfPoint2f srcPoints,
MatOfPoint2f dstPoints)
Finds a perspective transformation between two planes. |
static Mat |
findHomography(MatOfPoint2f srcPoints,
MatOfPoint2f dstPoints,
int method,
double ransacReprojThreshold)
Finds a perspective transformation between two planes. |
static Mat |
findHomography(MatOfPoint2f srcPoints,
MatOfPoint2f dstPoints,
int method,
double ransacReprojThreshold,
Mat mask)
Finds a perspective transformation between two planes. |
static Mat |
getOptimalNewCameraMatrix(Mat cameraMatrix,
Mat distCoeffs,
Size imageSize,
double alpha)
Returns the new camera matrix based on the free scaling parameter. |
static Mat |
getOptimalNewCameraMatrix(Mat cameraMatrix,
Mat distCoeffs,
Size imageSize,
double alpha,
Size newImgSize,
Rect validPixROI,
boolean centerPrincipalPoint)
Returns the new camera matrix based on the free scaling parameter. |
static Rect |
getValidDisparityROI(Rect roi1,
Rect roi2,
int minDisparity,
int numberOfDisparities,
int SADWindowSize)
|
static Mat |
initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints,
java.util.List<MatOfPoint2f> imagePoints,
Size imageSize)
Finds an initial camera matrix from 3D-2D point correspondences. |
static Mat |
initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints,
java.util.List<MatOfPoint2f> imagePoints,
Size imageSize,
double aspectRatio)
Finds an initial camera matrix from 3D-2D point correspondences. |
static void |
matMulDeriv(Mat A,
Mat B,
Mat dABdA,
Mat dABdB)
Computes partial derivatives of the matrix product for each multiplied matrix. |
static void |
projectPoints(MatOfPoint3f objectPoints,
Mat rvec,
Mat tvec,
Mat cameraMatrix,
MatOfDouble distCoeffs,
MatOfPoint2f imagePoints)
Projects 3D points to an image plane. |
static void |
projectPoints(MatOfPoint3f objectPoints,
Mat rvec,
Mat tvec,
Mat cameraMatrix,
MatOfDouble distCoeffs,
MatOfPoint2f imagePoints,
Mat jacobian,
double aspectRatio)
Projects 3D points to an image plane. |
static float |
rectify3Collinear(Mat cameraMatrix1,
Mat distCoeffs1,
Mat cameraMatrix2,
Mat distCoeffs2,
Mat cameraMatrix3,
Mat distCoeffs3,
java.util.List<Mat> imgpt1,
java.util.List<Mat> imgpt3,
Size imageSize,
Mat R12,
Mat T12,
Mat R13,
Mat T13,
Mat R1,
Mat R2,
Mat R3,
Mat P1,
Mat P2,
Mat P3,
Mat Q,
double alpha,
Size newImgSize,
Rect roi1,
Rect roi2,
int flags)
|
static void |
reprojectImageTo3D(Mat disparity,
Mat _3dImage,
Mat Q)
Reprojects a disparity image to 3D space. |
static void |
reprojectImageTo3D(Mat disparity,
Mat _3dImage,
Mat Q,
boolean handleMissingValues)
Reprojects a disparity image to 3D space. |
static void |
reprojectImageTo3D(Mat disparity,
Mat _3dImage,
Mat Q,
boolean handleMissingValues,
int ddepth)
Reprojects a disparity image to 3D space. |
static void |
Rodrigues(Mat src,
Mat dst)
Converts a rotation matrix to a rotation vector or vice versa. |
static void |
Rodrigues(Mat src,
Mat dst,
Mat jacobian)
Converts a rotation matrix to a rotation vector or vice versa. |
static double[] |
RQDecomp3x3(Mat src,
Mat mtxR,
Mat mtxQ)
Computes an RQ decomposition of 3x3 matrices. |
static double[] |
RQDecomp3x3(Mat src,
Mat mtxR,
Mat mtxQ,
Mat Qx,
Mat Qy,
Mat Qz)
Computes an RQ decomposition of 3x3 matrices. |
static boolean |
solvePnP(MatOfPoint3f objectPoints,
MatOfPoint2f imagePoints,
Mat cameraMatrix,
MatOfDouble distCoeffs,
Mat rvec,
Mat tvec)
Finds an object pose from 3D-2D point correspondences. |
static boolean |
solvePnP(MatOfPoint3f objectPoints,
MatOfPoint2f imagePoints,
Mat cameraMatrix,
MatOfDouble distCoeffs,
Mat rvec,
Mat tvec,
boolean useExtrinsicGuess,
int flags)
Finds an object pose from 3D-2D point correspondences. |
static void |
solvePnPRansac(MatOfPoint3f objectPoints,
MatOfPoint2f imagePoints,
Mat cameraMatrix,
MatOfDouble distCoeffs,
Mat rvec,
Mat tvec)
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme. |
static void |
solvePnPRansac(MatOfPoint3f objectPoints,
MatOfPoint2f imagePoints,
Mat cameraMatrix,
MatOfDouble distCoeffs,
Mat rvec,
Mat tvec,
boolean useExtrinsicGuess,
int iterationsCount,
float reprojectionError,
int minInliersCount,
Mat inliers,
int flags)
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme. |
static double |
stereoCalibrate(java.util.List<Mat> objectPoints,
java.util.List<Mat> imagePoints1,
java.util.List<Mat> imagePoints2,
Mat cameraMatrix1,
Mat distCoeffs1,
Mat cameraMatrix2,
Mat distCoeffs2,
Size imageSize,
Mat R,
Mat T,
Mat E,
Mat F)
Calibrates the stereo camera. |
static double |
stereoCalibrate(java.util.List<Mat> objectPoints,
java.util.List<Mat> imagePoints1,
java.util.List<Mat> imagePoints2,
Mat cameraMatrix1,
Mat distCoeffs1,
Mat cameraMatrix2,
Mat distCoeffs2,
Size imageSize,
Mat R,
Mat T,
Mat E,
Mat F,
TermCriteria criteria,
int flags)
Calibrates the stereo camera. |
static void |
stereoRectify(Mat cameraMatrix1,
Mat distCoeffs1,
Mat cameraMatrix2,
Mat distCoeffs2,
Size imageSize,
Mat R,
Mat T,
Mat R1,
Mat R2,
Mat P1,
Mat P2,
Mat Q)
Computes rectification transforms for each head of a calibrated stereo camera. |
static void |
stereoRectify(Mat cameraMatrix1,
Mat distCoeffs1,
Mat cameraMatrix2,
Mat distCoeffs2,
Size imageSize,
Mat R,
Mat T,
Mat R1,
Mat R2,
Mat P1,
Mat P2,
Mat Q,
int flags,
double alpha,
Size newImageSize,
Rect validPixROI1,
Rect validPixROI2)
Computes rectification transforms for each head of a calibrated stereo camera. |
static boolean |
stereoRectifyUncalibrated(Mat points1,
Mat points2,
Mat F,
Size imgSize,
Mat H1,
Mat H2)
Computes a rectification transform for an uncalibrated stereo camera. |
static boolean |
stereoRectifyUncalibrated(Mat points1,
Mat points2,
Mat F,
Size imgSize,
Mat H1,
Mat H2,
double threshold)
Computes a rectification transform for an uncalibrated stereo camera. |
static void |
triangulatePoints(Mat projMatr1,
Mat projMatr2,
Mat projPoints1,
Mat projPoints2,
Mat points4D)
Reconstructs points by triangulation. |
static void |
validateDisparity(Mat disparity,
Mat cost,
int minDisparity,
int numberOfDisparities)
|
static void |
validateDisparity(Mat disparity,
Mat cost,
int minDisparity,
int numberOfDisparities,
int disp12MaxDisp)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CALIB_CB_ADAPTIVE_THRESH
public static final int CALIB_CB_ASYMMETRIC_GRID
public static final int CALIB_CB_CLUSTERING
public static final int CALIB_CB_FAST_CHECK
public static final int CALIB_CB_FILTER_QUADS
public static final int CALIB_CB_NORMALIZE_IMAGE
public static final int CALIB_CB_SYMMETRIC_GRID
public static final int CALIB_FIX_ASPECT_RATIO
public static final int CALIB_FIX_FOCAL_LENGTH
public static final int CALIB_FIX_INTRINSIC
public static final int CALIB_FIX_K1
public static final int CALIB_FIX_K2
public static final int CALIB_FIX_K3
public static final int CALIB_FIX_K4
public static final int CALIB_FIX_K5
public static final int CALIB_FIX_K6
public static final int CALIB_FIX_PRINCIPAL_POINT
public static final int CALIB_RATIONAL_MODEL
public static final int CALIB_SAME_FOCAL_LENGTH
public static final int CALIB_USE_INTRINSIC_GUESS
public static final int CALIB_ZERO_DISPARITY
public static final int CALIB_ZERO_TANGENT_DIST
public static final int CV_EPNP
public static final int CV_ITERATIVE
public static final int CV_P3P
public static final int EPNP
public static final int FM_7POINT
public static final int FM_8POINT
public static final int FM_LMEDS
public static final int FM_RANSAC
public static final int ITERATIVE
public static final int LMEDS
public static final int P3P
public static final int RANSAC
Constructor Detail |
---|
public Calib3d()
Method Detail |
---|
public static double calibrateCamera(java.util.List<Mat> objectPoints, java.util.List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, java.util.List<Mat> rvecs, java.util.List<Mat> tvecs)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
The function estimates the intrinsic camera parameters and extrinsic
parameters for each of the views. The algorithm is based on [Zhang2000] and
[BouguetMCT]. The coordinates of 3D object points and their corresponding 2D
projections in each view must be specified. That may be achieved by using an
object with a known geometry and easily detectable feature points.
Such an object is called a calibration rig or calibration pattern, and OpenCV
has built-in support for a chessboard as a calibration rig (see
"findChessboardCorners"). Currently, initialization of intrinsic parameters
(when CV_CALIB_USE_INTRINSIC_GUESS
is not set) is only
implemented for planar calibration patterns (where Z-coordinates of the
object points must be all zeros). 3D calibration rigs can also be used as
long as initial cameraMatrix
is provided.
The algorithm performs the following steps:
CV_CALIB_FIX_K?
are specified.
imagePoints
and the projected (using
the current estimates for camera parameters and the poses) object points
objectPoints
. See "projectPoints" for details.
The function returns the final re-projection error.
Note:
If you use a non-square (=non-NxN) grid and "findChessboardCorners" for
calibration, and calibrateCamera
returns bad values (zero
distortion coefficients, an image center very far from (w/2-0.5,h/2-0.5)
,
and/or large differences between f_x and f_y (ratios of
10:1 or more)), then you have probably used patternSize=cvSize(rows,cols)
instead of using patternSize=cvSize(cols,rows)
in
"findChessboardCorners".
objectPoints
- In the new interface it is a vector of vectors of
calibration pattern points in the calibration pattern coordinate space. The
outer vector contains as many elements as the number of the pattern views. If
the same calibration pattern is shown in each view and it is fully visible,
all the vectors will be the same. Although, it is possible to use partially
occluded patterns, or even different patterns in different views. Then, the
vectors will be different. The points are 3D, but since they are in a pattern
coordinate system, then, if the rig is planar, it may make sense to put the
model to a XY coordinate plane so that Z-coordinate of each input object
point is 0.
In the old interface all the vectors of object points from different views are concatenated together.
imagePoints
- In the new interface it is a vector of vectors of the
projections of calibration pattern points. imagePoints.size()
and objectPoints.size()
and imagePoints[i].size()
must be equal to objectPoints[i].size()
for each i
.
In the old interface all the vectors of object points from different views are concatenated together.
imageSize
- Size of the image used only to initialize the intrinsic
camera matrix.cameraMatrix
- Output 3x3 floating-point camera matrix A =
|f_x 0 c_x| |0 f_y c_y| |0 0 1|
. IfCV_CALIB_USE_INTRINSIC_GUESS
and/or CV_CALIB_FIX_ASPECT_RATIO
are specified, some or all of fx, fy, cx, cy
must be initialized
before calling the function.distCoeffs
- Output vector of distortion coefficients (k_1, k_2,
p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.rvecs
- Output vector of rotation vectors (see "Rodrigues") estimated
for each pattern view. That is, each k-th rotation vector together with the
corresponding k-th translation vector (see the next output parameter
description) brings the calibration pattern from the model coordinate space
(in which object points are specified) to the world coordinate space, that
is, a real position of the calibration pattern in the k-th pattern view
(k=0.. *M* -1).tvecs
- Output vector of translation vectors estimated for each pattern
view.initCameraMatrix2D(java.util.List, java.util.List, org.opencv.core.Size, double)
,
stereoCalibrate(java.util.List, java.util.List, java.util.List, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.TermCriteria, int)
,
findChessboardCorners(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.MatOfPoint2f, int)
,
solvePnP(org.opencv.core.MatOfPoint3f, org.opencv.core.MatOfPoint2f, org.opencv.core.Mat, org.opencv.core.MatOfDouble, org.opencv.core.Mat, org.opencv.core.Mat, boolean, int)
,
Imgproc.undistort(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static double calibrateCamera(java.util.List<Mat> objectPoints, java.util.List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, java.util.List<Mat> rvecs, java.util.List<Mat> tvecs, int flags)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
The function estimates the intrinsic camera parameters and extrinsic
parameters for each of the views. The algorithm is based on [Zhang2000] and
[BouguetMCT]. The coordinates of 3D object points and their corresponding 2D
projections in each view must be specified. That may be achieved by using an
object with a known geometry and easily detectable feature points.
Such an object is called a calibration rig or calibration pattern, and OpenCV
has built-in support for a chessboard as a calibration rig (see
"findChessboardCorners"). Currently, initialization of intrinsic parameters
(when CV_CALIB_USE_INTRINSIC_GUESS
is not set) is only
implemented for planar calibration patterns (where Z-coordinates of the
object points must be all zeros). 3D calibration rigs can also be used as
long as initial cameraMatrix
is provided.
The algorithm performs the following steps:
CV_CALIB_FIX_K?
are specified.
imagePoints
and the projected (using
the current estimates for camera parameters and the poses) object points
objectPoints
. See "projectPoints" for details.
The function returns the final re-projection error.
Note:
If you use a non-square (=non-NxN) grid and "findChessboardCorners" for
calibration, and calibrateCamera
returns bad values (zero
distortion coefficients, an image center very far from (w/2-0.5,h/2-0.5)
,
and/or large differences between f_x and f_y (ratios of
10:1 or more)), then you have probably used patternSize=cvSize(rows,cols)
instead of using patternSize=cvSize(cols,rows)
in
"findChessboardCorners".
objectPoints
- In the new interface it is a vector of vectors of
calibration pattern points in the calibration pattern coordinate space. The
outer vector contains as many elements as the number of the pattern views. If
the same calibration pattern is shown in each view and it is fully visible,
all the vectors will be the same. Although, it is possible to use partially
occluded patterns, or even different patterns in different views. Then, the
vectors will be different. The points are 3D, but since they are in a pattern
coordinate system, then, if the rig is planar, it may make sense to put the
model to a XY coordinate plane so that Z-coordinate of each input object
point is 0.
In the old interface all the vectors of object points from different views are concatenated together.
imagePoints
- In the new interface it is a vector of vectors of the
projections of calibration pattern points. imagePoints.size()
and objectPoints.size()
and imagePoints[i].size()
must be equal to objectPoints[i].size()
for each i
.
In the old interface all the vectors of object points from different views are concatenated together.
imageSize
- Size of the image used only to initialize the intrinsic
camera matrix.cameraMatrix
- Output 3x3 floating-point camera matrix A =
|f_x 0 c_x| |0 f_y c_y| |0 0 1|
. IfCV_CALIB_USE_INTRINSIC_GUESS
and/or CV_CALIB_FIX_ASPECT_RATIO
are specified, some or all of fx, fy, cx, cy
must be initialized
before calling the function.distCoeffs
- Output vector of distortion coefficients (k_1, k_2,
p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.rvecs
- Output vector of rotation vectors (see "Rodrigues") estimated
for each pattern view. That is, each k-th rotation vector together with the
corresponding k-th translation vector (see the next output parameter
description) brings the calibration pattern from the model coordinate space
(in which object points are specified) to the world coordinate space, that
is, a real position of the calibration pattern in the k-th pattern view
(k=0.. *M* -1).tvecs
- Output vector of translation vectors estimated for each pattern
view.flags
- Different flags that may be zero or a combination of the
following values:
cameraMatrix
contains valid
initial values of fx, fy, cx, cy
that are optimized further.
Otherwise, (cx, cy)
is initially set to the image center
(imageSize
is used), and focal distances are computed in a
least-squares fashion. Note, that if intrinsic parameters are known, there is
no need to use this function just to estimate extrinsic parameters. Use
"solvePnP" instead.
CV_CALIB_USE_INTRINSIC_GUESS
is set too.
fy
as a free parameter. The ratio fx/fy
stays the same as in the
input cameraMatrix
. When CV_CALIB_USE_INTRINSIC_GUESS
is not set, the actual input values of fx
and fy
are ignored, only their ratio is computed and used further.
CV_CALIB_USE_INTRINSIC_GUESS
is set, the coefficient from the
supplied distCoeffs
matrix is used. Otherwise, it is set to 0.
initCameraMatrix2D(java.util.List, java.util.List, org.opencv.core.Size, double)
,
stereoCalibrate(java.util.List, java.util.List, java.util.List, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.TermCriteria, int)
,
findChessboardCorners(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.MatOfPoint2f, int)
,
solvePnP(org.opencv.core.MatOfPoint3f, org.opencv.core.MatOfPoint2f, org.opencv.core.Mat, org.opencv.core.MatOfDouble, org.opencv.core.Mat, org.opencv.core.Mat, boolean, int)
,
Imgproc.undistort(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static double calibrateCamera(java.util.List<Mat> objectPoints, java.util.List<Mat> imagePoints, Size imageSize, Mat cameraMatrix, Mat distCoeffs, java.util.List<Mat> rvecs, java.util.List<Mat> tvecs, int flags, TermCriteria criteria)
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
The function estimates the intrinsic camera parameters and extrinsic
parameters for each of the views. The algorithm is based on [Zhang2000] and
[BouguetMCT]. The coordinates of 3D object points and their corresponding 2D
projections in each view must be specified. That may be achieved by using an
object with a known geometry and easily detectable feature points.
Such an object is called a calibration rig or calibration pattern, and OpenCV
has built-in support for a chessboard as a calibration rig (see
"findChessboardCorners"). Currently, initialization of intrinsic parameters
(when CV_CALIB_USE_INTRINSIC_GUESS
is not set) is only
implemented for planar calibration patterns (where Z-coordinates of the
object points must be all zeros). 3D calibration rigs can also be used as
long as initial cameraMatrix
is provided.
The algorithm performs the following steps:
CV_CALIB_FIX_K?
are specified.
imagePoints
and the projected (using
the current estimates for camera parameters and the poses) object points
objectPoints
. See "projectPoints" for details.
The function returns the final re-projection error.
Note:
If you use a non-square (=non-NxN) grid and "findChessboardCorners" for
calibration, and calibrateCamera
returns bad values (zero
distortion coefficients, an image center very far from (w/2-0.5,h/2-0.5)
,
and/or large differences between f_x and f_y (ratios of
10:1 or more)), then you have probably used patternSize=cvSize(rows,cols)
instead of using patternSize=cvSize(cols,rows)
in
"findChessboardCorners".
objectPoints
- In the new interface it is a vector of vectors of
calibration pattern points in the calibration pattern coordinate space. The
outer vector contains as many elements as the number of the pattern views. If
the same calibration pattern is shown in each view and it is fully visible,
all the vectors will be the same. Although, it is possible to use partially
occluded patterns, or even different patterns in different views. Then, the
vectors will be different. The points are 3D, but since they are in a pattern
coordinate system, then, if the rig is planar, it may make sense to put the
model to a XY coordinate plane so that Z-coordinate of each input object
point is 0.
In the old interface all the vectors of object points from different views are concatenated together.
imagePoints
- In the new interface it is a vector of vectors of the
projections of calibration pattern points. imagePoints.size()
and objectPoints.size()
and imagePoints[i].size()
must be equal to objectPoints[i].size()
for each i
.
In the old interface all the vectors of object points from different views are concatenated together.
imageSize
- Size of the image used only to initialize the intrinsic
camera matrix.cameraMatrix
- Output 3x3 floating-point camera matrix A =
|f_x 0 c_x| |0 f_y c_y| |0 0 1|
. IfCV_CALIB_USE_INTRINSIC_GUESS
and/or CV_CALIB_FIX_ASPECT_RATIO
are specified, some or all of fx, fy, cx, cy
must be initialized
before calling the function.distCoeffs
- Output vector of distortion coefficients (k_1, k_2,
p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements.rvecs
- Output vector of rotation vectors (see "Rodrigues") estimated
for each pattern view. That is, each k-th rotation vector together with the
corresponding k-th translation vector (see the next output parameter
description) brings the calibration pattern from the model coordinate space
(in which object points are specified) to the world coordinate space, that
is, a real position of the calibration pattern in the k-th pattern view
(k=0.. *M* -1).tvecs
- Output vector of translation vectors estimated for each pattern
view.flags
- Different flags that may be zero or a combination of the
following values:
cameraMatrix
contains valid
initial values of fx, fy, cx, cy
that are optimized further.
Otherwise, (cx, cy)
is initially set to the image center
(imageSize
is used), and focal distances are computed in a
least-squares fashion. Note, that if intrinsic parameters are known, there is
no need to use this function just to estimate extrinsic parameters. Use
"solvePnP" instead.
CV_CALIB_USE_INTRINSIC_GUESS
is set too.
fy
as a free parameter. The ratio fx/fy
stays the same as in the
input cameraMatrix
. When CV_CALIB_USE_INTRINSIC_GUESS
is not set, the actual input values of fx
and fy
are ignored, only their ratio is computed and used further.
CV_CALIB_USE_INTRINSIC_GUESS
is set, the coefficient from the
supplied distCoeffs
matrix is used. Otherwise, it is set to 0.
criteria
- Termination criteria for the iterative optimization
algorithm.initCameraMatrix2D(java.util.List, java.util.List, org.opencv.core.Size, double)
,
stereoCalibrate(java.util.List, java.util.List, java.util.List, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.TermCriteria, int)
,
findChessboardCorners(org.opencv.core.Mat, org.opencv.core.Size, org.opencv.core.MatOfPoint2f, int)
,
solvePnP(org.opencv.core.MatOfPoint3f, org.opencv.core.MatOfPoint2f, org.opencv.core.Mat, org.opencv.core.MatOfDouble, org.opencv.core.Mat, org.opencv.core.Mat, boolean, int)
,
Imgproc.undistort(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
public static void calibrationMatrixValues(Mat cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, double[] fovx, double[] fovy, double[] focalLength, Point principalPoint, double[] aspectRatio)
Computes useful camera characteristics from the camera matrix.
The function computes various useful camera characteristics from the previously estimated camera matrix.
cameraMatrix
- Input camera matrix that can be estimated by
"calibrateCamera" or "stereoCalibrate".imageSize
- Input image size in pixels.apertureWidth
- Physical width of the sensor.apertureHeight
- Physical height of the sensor.fovx
- Output field of view in degrees along the horizontal sensor axis.fovy
- Output field of view in degrees along the vertical sensor axis.focalLength
- Focal length of the lens in mm.principalPoint
- Principal point in pixels.aspectRatio
- f_y/f_xpublic static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3)
Combines two rotation-and-shift transformations.
The functions compute:
rvec3 = rodrigues ^(-1)(rodrigues(rvec2) * rodrigues(rvec1)) tvec3 = rodrigues(rvec2) * tvec1 + tvec2,
where rodrigues denotes a rotation vector to a rotation matrix transformation, and rodrigues^(-1) denotes the inverse transformation. See "Rodrigues" for details.
Also, the functions can compute the derivatives of the output vectors with regards to the input vectors (see "matMulDeriv"). The functions are used inside "stereoCalibrate" but can also be used in your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a function that contains a matrix multiplication.
rvec1
- First rotation vector.tvec1
- First translation vector.rvec2
- Second rotation vector.tvec2
- Second translation vector.rvec3
- Output rotation vector of the superposition.tvec3
- Output translation vector of the superposition.public static void composeRT(Mat rvec1, Mat tvec1, Mat rvec2, Mat tvec2, Mat rvec3, Mat tvec3, Mat dr3dr1, Mat dr3dt1, Mat dr3dr2, Mat dr3dt2, Mat dt3dr1, Mat dt3dt1, Mat dt3dr2, Mat dt3dt2)
Combines two rotation-and-shift transformations.
The functions compute:
rvec3 = rodrigues ^(-1)(rodrigues(rvec2) * rodrigues(rvec1)) tvec3 = rodrigues(rvec2) * tvec1 + tvec2,
where rodrigues denotes a rotation vector to a rotation matrix transformation, and rodrigues^(-1) denotes the inverse transformation. See "Rodrigues" for details.
Also, the functions can compute the derivatives of the output vectors with regards to the input vectors (see "matMulDeriv"). The functions are used inside "stereoCalibrate" but can also be used in your own code where Levenberg-Marquardt or another gradient-based solver is used to optimize a function that contains a matrix multiplication.
rvec1
- First rotation vector.tvec1
- First translation vector.rvec2
- Second rotation vector.tvec2
- Second translation vector.rvec3
- Output rotation vector of the superposition.tvec3
- Output translation vector of the superposition.dr3dr1
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dr3dt1
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dr3dr2
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dr3dt2
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dt3dr1
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dt3dt1
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dt3dr2
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.dt3dt2
- Optional output derivatives of rvec3
or
tvec3
with regard to rvec1
, rvec2
,
tvec1
and tvec2
, respectively.public static void convertPointsFromHomogeneous(Mat src, Mat dst)
Converts points from homogeneous to Euclidean space.
The function converts points homogeneous to Euclidean space using perspective
projection. That is, each point (x1, x2,... x(n-1), xn)
is
converted to (x1/xn, x2/xn,..., x(n-1)/xn)
. When
xn=0
, the output point coordinates will be (0,0,0,...)
.
src
- Input vector of N
-dimensional points.dst
- Output vector of N-1
-dimensional points.public static void convertPointsToHomogeneous(Mat src, Mat dst)
Converts points from Euclidean to homogeneous space.
The function converts points from Euclidean to homogeneous space by appending
1's to the tuple of point coordinates. That is, each point (x1, x2,...,
xn)
is converted to (x1, x2,..., xn, 1)
.
src
- Input vector of N
-dimensional points.dst
- Output vector of N+1
-dimensional points.public static void correctMatches(Mat F, Mat points1, Mat points2, Mat newPoints1, Mat newPoints2)
Refines coordinates of corresponding points.
The function implements the Optimal Triangulation Method (see Multiple View Geometry for details). For each given point correspondence points1[i] <-> points2[i], and a fundamental matrix F, it computes the corrected correspondences newPoints1[i] <-> newPoints2[i] that minimize the geometric error d(points1[i], newPoints1[i])^2 + d(points2[i],newPoints2[i])^2 (where d(a,b) is the geometric distance between points a and b) subject to the epipolar constraint newPoints2^T * F * newPoints1 = 0.
F
- 3x3 fundamental matrix.points1
- 1xN array containing the first set of points.points2
- 1xN array containing the second set of points.newPoints1
- The optimized points1.newPoints2
- The optimized points2.public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect)
Decomposes a projection matrix into a rotation matrix and a camera matrix.
The function computes a decomposition of a projection matrix into a calibration and a rotation matrix and the position of a camera.
It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL.
The function is based on "RQDecomp3x3".
projMatrix
- 3x4 input projection matrix P.cameraMatrix
- Output 3x3 camera matrix K.rotMatrix
- Output 3x3 external rotation matrix R.transVect
- Output 4x1 translation vector T.public static void decomposeProjectionMatrix(Mat projMatrix, Mat cameraMatrix, Mat rotMatrix, Mat transVect, Mat rotMatrixX, Mat rotMatrixY, Mat rotMatrixZ, Mat eulerAngles)
Decomposes a projection matrix into a rotation matrix and a camera matrix.
The function computes a decomposition of a projection matrix into a calibration and a rotation matrix and the position of a camera.
It optionally returns three rotation matrices, one for each axis, and three Euler angles that could be used in OpenGL.
The function is based on "RQDecomp3x3".
projMatrix
- 3x4 input projection matrix P.cameraMatrix
- Output 3x3 camera matrix K.rotMatrix
- Output 3x3 external rotation matrix R.transVect
- Output 4x1 translation vector T.rotMatrixX
- a rotMatrixXrotMatrixY
- a rotMatrixYrotMatrixZ
- a rotMatrixZeulerAngles
- Optional three-element vector containing three Euler
angles of rotation.public static void drawChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, boolean patternWasFound)
Renders the detected chessboard corners.
The function draws individual chessboard corners detected either as red circles if the board was not found, or as colored corners connected with lines if the board was found.
image
- Destination image. It must be an 8-bit color image.patternSize
- Number of inner corners per a chessboard row and column
(patternSize = cv.Size(points_per_row,points_per_column))
.corners
- Array of detected corners, the output of findChessboardCorners
.patternWasFound
- Parameter indicating whether the complete board was
found or not. The return value of "findChessboardCorners" should be passed
here.public static int estimateAffine3D(Mat src, Mat dst, Mat out, Mat inliers)
Computes an optimal affine transformation between two 3D point sets.
The function estimates an optimal 3D affine transformation between two 3D point sets using the RANSAC algorithm.
src
- First input 3D point set.dst
- Second input 3D point set.out
- Output 3D affine transformation matrix 3 x 4.inliers
- Output vector indicating which points are inliers.public static int estimateAffine3D(Mat src, Mat dst, Mat out, Mat inliers, double ransacThreshold, double confidence)
Computes an optimal affine transformation between two 3D point sets.
The function estimates an optimal 3D affine transformation between two 3D point sets using the RANSAC algorithm.
src
- First input 3D point set.dst
- Second input 3D point set.out
- Output 3D affine transformation matrix 3 x 4.inliers
- Output vector indicating which points are inliers.ransacThreshold
- Maximum reprojection error in the RANSAC algorithm to
consider a point as an inlier.confidence
- Confidence level, between 0 and 1, for the estimated
transformation. Anything between 0.95 and 0.99 is usually good enough. Values
too close to 1 can slow down the estimation significantly. Values lower than
0.8-0.9 can result in an incorrectly estimated transformation.public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff)
Filters off small noise blobs (speckles) in the disparity map
img
- The input 16-bit signed disparity imagenewVal
- The disparity value used to paint-off the specklesmaxSpeckleSize
- The maximum speckle size to consider it a speckle.
Larger blobs are not affected by the algorithmmaxDiff
- Maximum difference between neighbor disparity pixels to put
them into the same blob. Note that since StereoBM, StereoSGBM and may be
other algorithms return a fixed-point disparity map, where disparity values
are multiplied by 16, this scale factor should be taken into account when
specifying this parameter value.public static void filterSpeckles(Mat img, double newVal, int maxSpeckleSize, double maxDiff, Mat buf)
Filters off small noise blobs (speckles) in the disparity map
img
- The input 16-bit signed disparity imagenewVal
- The disparity value used to paint-off the specklesmaxSpeckleSize
- The maximum speckle size to consider it a speckle.
Larger blobs are not affected by the algorithmmaxDiff
- Maximum difference between neighbor disparity pixels to put
them into the same blob. Note that since StereoBM, StereoSGBM and may be
other algorithms return a fixed-point disparity map, where disparity values
are multiplied by 16, this scale factor should be taken into account when
specifying this parameter value.buf
- The optional temporary buffer to avoid memory allocation within
the function.public static boolean findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners)
Finds the positions of internal corners of the chessboard.
The function attempts to determine whether the input image is a view of the chessboard pattern and locate the internal chessboard corners. The function returns a non-zero value if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black squares touch each other. The detected coordinates are approximate, and to determine their positions more accurately, the function calls "cornerSubPix". You also may use the function "cornerSubPix" with different parameters if returned coordinates are not accurate enough.
Sample usage of detecting and drawing chessboard corners:
Note: The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails.
image
- Source chessboard view. It must be an 8-bit grayscale or color
image.patternSize
- Number of inner corners per a chessboard row and column
(patternSize = cvSize(points_per_row,points_per_colum) =
cvSize(columns,rows))
.corners
- Output array of detected corners.public static boolean findChessboardCorners(Mat image, Size patternSize, MatOfPoint2f corners, int flags)
Finds the positions of internal corners of the chessboard.
The function attempts to determine whether the input image is a view of the chessboard pattern and locate the internal chessboard corners. The function returns a non-zero value if all of the corners are found and they are placed in a certain order (row by row, left to right in every row). Otherwise, if the function fails to find all the corners or reorder them, it returns 0. For example, a regular chessboard has 8 x 8 squares and 7 x 7 internal corners, that is, points where the black squares touch each other. The detected coordinates are approximate, and to determine their positions more accurately, the function calls "cornerSubPix". You also may use the function "cornerSubPix" with different parameters if returned coordinates are not accurate enough.
Sample usage of detecting and drawing chessboard corners:
Note: The function requires white space (like a square-thick border, the wider the better) around the board to make the detection more robust in various environments. Otherwise, if there is no border and the background is dark, the outer black squares cannot be segmented properly and so the square grouping and ordering algorithm fails.
image
- Source chessboard view. It must be an 8-bit grayscale or color
image.patternSize
- Number of inner corners per a chessboard row and column
(patternSize = cvSize(points_per_row,points_per_colum) =
cvSize(columns,rows))
.corners
- Output array of detected corners.flags
- Various operation flags that can be zero or a combination of the
following values:
public static boolean findCirclesGridDefault(Mat image, Size patternSize, Mat centers)
public static boolean findCirclesGridDefault(Mat image, Size patternSize, Mat centers, int flags)
public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2)
Calculates a fundamental matrix from the corresponding points in two images.
The epipolar geometry is described by the following equation:
[p_2; 1]^T F [p_1; 1] = 0
where F is a fundamental matrix, p_1 and p_2 are corresponding points in the first and the second images, respectively.
The function calculates the fundamental matrix using one of four methods listed above and returns the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point algorithm, the function may return up to 3 solutions (9 x 3 matrix that stores all 3 matrices sequentially).
The calculated fundamental matrix may be passed further to "computeCorrespondEpilines" that finds the epipolar lines corresponding to the specified points. It can also be passed to "stereoRectifyUncalibrated" to compute the rectification transformation.
points1
- Array of N
points from the first image. The point
coordinates should be floating-point (single or double precision).points2
- Array of the second image points of the same size and format
as points1
.public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double param1, double param2)
Calculates a fundamental matrix from the corresponding points in two images.
The epipolar geometry is described by the following equation:
[p_2; 1]^T F [p_1; 1] = 0
where F is a fundamental matrix, p_1 and p_2 are corresponding points in the first and the second images, respectively.
The function calculates the fundamental matrix using one of four methods listed above and returns the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point algorithm, the function may return up to 3 solutions (9 x 3 matrix that stores all 3 matrices sequentially).
The calculated fundamental matrix may be passed further to "computeCorrespondEpilines" that finds the epipolar lines corresponding to the specified points. It can also be passed to "stereoRectifyUncalibrated" to compute the rectification transformation.
points1
- Array of N
points from the first image. The point
coordinates should be floating-point (single or double precision).points2
- Array of the second image points of the same size and format
as points1
.method
- Method for computing a fundamental matrix.
param1
- Parameter used for RANSAC. It is the maximum distance from a
point to an epipolar line in pixels, beyond which the point is considered an
outlier and is not used for computing the final fundamental matrix. It can be
set to something like 1-3, depending on the accuracy of the point
localization, image resolution, and the image noise.param2
- Parameter used for the RANSAC or LMedS methods only. It
specifies a desirable level of confidence (probability) that the estimated
matrix is correct.public static Mat findFundamentalMat(MatOfPoint2f points1, MatOfPoint2f points2, int method, double param1, double param2, Mat mask)
Calculates a fundamental matrix from the corresponding points in two images.
The epipolar geometry is described by the following equation:
[p_2; 1]^T F [p_1; 1] = 0
where F is a fundamental matrix, p_1 and p_2 are corresponding points in the first and the second images, respectively.
The function calculates the fundamental matrix using one of four methods listed above and returns the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point algorithm, the function may return up to 3 solutions (9 x 3 matrix that stores all 3 matrices sequentially).
The calculated fundamental matrix may be passed further to "computeCorrespondEpilines" that finds the epipolar lines corresponding to the specified points. It can also be passed to "stereoRectifyUncalibrated" to compute the rectification transformation.
points1
- Array of N
points from the first image. The point
coordinates should be floating-point (single or double precision).points2
- Array of the second image points of the same size and format
as points1
.method
- Method for computing a fundamental matrix.
param1
- Parameter used for RANSAC. It is the maximum distance from a
point to an epipolar line in pixels, beyond which the point is considered an
outlier and is not used for computing the final fundamental matrix. It can be
set to something like 1-3, depending on the accuracy of the point
localization, image resolution, and the image noise.param2
- Parameter used for the RANSAC or LMedS methods only. It
specifies a desirable level of confidence (probability) that the estimated
matrix is correct.mask
- a maskpublic static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints)
Finds a perspective transformation between two planes.
The functions find and return the perspective transformation H between the source and the destination planes:
s_i [x'_i y'_i 1] ~ H [x_i y_i 1]
so that the back-projection error
sum _i(x'_i- (h_11 x_i + h_12 y_i + h_13)/(h_(31) x_i + h_32 y_i + h_33))^2+ (y'_i- (h_21 x_i + h_22 y_i + h_23)/(h_(31) x_i + h_32 y_i + h_33))^2
is minimized. If the parameter method
is set to the default
value 0, the function uses all the point pairs to compute an initial
homography estimate with a simple least-squares scheme.
However, if not all of the point pairs (srcPoints_i,dstPoints_i)
fit the rigid perspective transformation (that is, there are some outliers),
this initial estimate will be poor.
In this case, you can use one of the two robust methods. Both methods,
RANSAC
and LMeDS
, try many different random subsets
of the corresponding point pairs (of four pairs each), estimate the
homography matrix using this subset and a simple least-square algorithm, and
then compute the quality/goodness of the computed homography (which is the
number of inliers for RANSAC or the median re-projection error for LMeDs).
The best subset is then used to produce the initial estimate of the
homography matrix and the mask of inliers/outliers.
Regardless of the method, robust or not, the computed homography matrix is refined further (using inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the re-projection error even more.
The method RANSAC
can handle practically any ratio of outliers
but it needs a threshold to distinguish inliers from outliers.
The method LMeDS
does not need any threshold but it works
correctly only when there are more than 50% of inliers. Finally, if there are
no outliers and the noise is rather small, use the default method
(method=0
).
The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is determined up to a scale. Thus, it is normalized so that h_33=1.
srcPoints
- Coordinates of the points in the original plane, a matrix of
the type CV_32FC2
or vector
.dstPoints
- Coordinates of the points in the target plane, a matrix of
the type CV_32FC2
or a vector
.Imgproc.warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)
,
Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
Video.estimateRigidTransform(org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
Imgproc.getAffineTransform(org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f)
,
Imgproc.getPerspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat)
public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold)
Finds a perspective transformation between two planes.
The functions find and return the perspective transformation H between the source and the destination planes:
s_i [x'_i y'_i 1] ~ H [x_i y_i 1]
so that the back-projection error
sum _i(x'_i- (h_11 x_i + h_12 y_i + h_13)/(h_(31) x_i + h_32 y_i + h_33))^2+ (y'_i- (h_21 x_i + h_22 y_i + h_23)/(h_(31) x_i + h_32 y_i + h_33))^2
is minimized. If the parameter method
is set to the default
value 0, the function uses all the point pairs to compute an initial
homography estimate with a simple least-squares scheme.
However, if not all of the point pairs (srcPoints_i,dstPoints_i)
fit the rigid perspective transformation (that is, there are some outliers),
this initial estimate will be poor.
In this case, you can use one of the two robust methods. Both methods,
RANSAC
and LMeDS
, try many different random subsets
of the corresponding point pairs (of four pairs each), estimate the
homography matrix using this subset and a simple least-square algorithm, and
then compute the quality/goodness of the computed homography (which is the
number of inliers for RANSAC or the median re-projection error for LMeDs).
The best subset is then used to produce the initial estimate of the
homography matrix and the mask of inliers/outliers.
Regardless of the method, robust or not, the computed homography matrix is refined further (using inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the re-projection error even more.
The method RANSAC
can handle practically any ratio of outliers
but it needs a threshold to distinguish inliers from outliers.
The method LMeDS
does not need any threshold but it works
correctly only when there are more than 50% of inliers. Finally, if there are
no outliers and the noise is rather small, use the default method
(method=0
).
The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is determined up to a scale. Thus, it is normalized so that h_33=1.
srcPoints
- Coordinates of the points in the original plane, a matrix of
the type CV_32FC2
or vector
.dstPoints
- Coordinates of the points in the target plane, a matrix of
the type CV_32FC2
or a vector
.method
- Method used to computed a homography matrix. The following
methods are possible:
ransacReprojThreshold
- Maximum allowed reprojection error to treat a
point pair as an inlier (used in the RANSAC method only). That is, if
| dstPoints _i - convertPointsHomogeneous(H * srcPoints _i)| > ransacReprojThreshold
then the point i is considered an outlier. If srcPoints
and dstPoints
are measured in pixels, it usually makes sense to
set this parameter somewhere in the range of 1 to 10.
Imgproc.warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)
,
Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
Video.estimateRigidTransform(org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
Imgproc.getAffineTransform(org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f)
,
Imgproc.getPerspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat)
public static Mat findHomography(MatOfPoint2f srcPoints, MatOfPoint2f dstPoints, int method, double ransacReprojThreshold, Mat mask)
Finds a perspective transformation between two planes.
The functions find and return the perspective transformation H between the source and the destination planes:
s_i [x'_i y'_i 1] ~ H [x_i y_i 1]
so that the back-projection error
sum _i(x'_i- (h_11 x_i + h_12 y_i + h_13)/(h_(31) x_i + h_32 y_i + h_33))^2+ (y'_i- (h_21 x_i + h_22 y_i + h_23)/(h_(31) x_i + h_32 y_i + h_33))^2
is minimized. If the parameter method
is set to the default
value 0, the function uses all the point pairs to compute an initial
homography estimate with a simple least-squares scheme.
However, if not all of the point pairs (srcPoints_i,dstPoints_i)
fit the rigid perspective transformation (that is, there are some outliers),
this initial estimate will be poor.
In this case, you can use one of the two robust methods. Both methods,
RANSAC
and LMeDS
, try many different random subsets
of the corresponding point pairs (of four pairs each), estimate the
homography matrix using this subset and a simple least-square algorithm, and
then compute the quality/goodness of the computed homography (which is the
number of inliers for RANSAC or the median re-projection error for LMeDs).
The best subset is then used to produce the initial estimate of the
homography matrix and the mask of inliers/outliers.
Regardless of the method, robust or not, the computed homography matrix is refined further (using inliers only in case of a robust method) with the Levenberg-Marquardt method to reduce the re-projection error even more.
The method RANSAC
can handle practically any ratio of outliers
but it needs a threshold to distinguish inliers from outliers.
The method LMeDS
does not need any threshold but it works
correctly only when there are more than 50% of inliers. Finally, if there are
no outliers and the noise is rather small, use the default method
(method=0
).
The function is used to find initial intrinsic and extrinsic matrices. Homography matrix is determined up to a scale. Thus, it is normalized so that h_33=1.
srcPoints
- Coordinates of the points in the original plane, a matrix of
the type CV_32FC2
or vector
.dstPoints
- Coordinates of the points in the target plane, a matrix of
the type CV_32FC2
or a vector
.method
- Method used to computed a homography matrix. The following
methods are possible:
ransacReprojThreshold
- Maximum allowed reprojection error to treat a
point pair as an inlier (used in the RANSAC method only). That is, if
| dstPoints _i - convertPointsHomogeneous(H * srcPoints _i)| > ransacReprojThreshold
then the point i is considered an outlier. If srcPoints
and dstPoints
are measured in pixels, it usually makes sense to
set this parameter somewhere in the range of 1 to 10.
mask
- Optional output mask set by a robust method (CV_RANSAC
or CV_LMEDS
). Note that the input mask values are ignored.Imgproc.warpPerspective(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Size, int, int, org.opencv.core.Scalar)
,
Core.perspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat)
,
Video.estimateRigidTransform(org.opencv.core.Mat, org.opencv.core.Mat, boolean)
,
Imgproc.getAffineTransform(org.opencv.core.MatOfPoint2f, org.opencv.core.MatOfPoint2f)
,
Imgproc.getPerspectiveTransform(org.opencv.core.Mat, org.opencv.core.Mat)
public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha)
Returns the new camera matrix based on the free scaling parameter.
The function computes and returns the optimal new camera matrix based on the
free scaling parameter. By varying this parameter, you may retrieve only
sensible pixels alpha=0
, keep all the original image pixels if
there is valuable information in the corners alpha=1
, or get
something in between. When alpha>0
, the undistortion result is
likely to have some black pixels corresponding to "virtual" pixels outside of
the captured distorted image. The original camera matrix, distortion
coefficients, the computed new camera matrix, and newImageSize
should be passed to "initUndistortRectifyMap" to produce the maps for
"remap".
cameraMatrix
- Input camera matrix.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.imageSize
- Original image size.alpha
- Free scaling parameter between 0 (when all the pixels in the
undistorted image are valid) and 1 (when all the source image pixels are
retained in the undistorted image). See "stereoRectify" for details.public static Mat getOptimalNewCameraMatrix(Mat cameraMatrix, Mat distCoeffs, Size imageSize, double alpha, Size newImgSize, Rect validPixROI, boolean centerPrincipalPoint)
Returns the new camera matrix based on the free scaling parameter.
The function computes and returns the optimal new camera matrix based on the
free scaling parameter. By varying this parameter, you may retrieve only
sensible pixels alpha=0
, keep all the original image pixels if
there is valuable information in the corners alpha=1
, or get
something in between. When alpha>0
, the undistortion result is
likely to have some black pixels corresponding to "virtual" pixels outside of
the captured distorted image. The original camera matrix, distortion
coefficients, the computed new camera matrix, and newImageSize
should be passed to "initUndistortRectifyMap" to produce the maps for
"remap".
cameraMatrix
- Input camera matrix.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.imageSize
- Original image size.alpha
- Free scaling parameter between 0 (when all the pixels in the
undistorted image are valid) and 1 (when all the source image pixels are
retained in the undistorted image). See "stereoRectify" for details.newImgSize
- a newImgSizevalidPixROI
- Optional output rectangle that outlines all-good-pixels
region in the undistorted image. See roi1, roi2
description in
"stereoRectify".centerPrincipalPoint
- Optional flag that indicates whether in the new
camera matrix the principal point should be at the image center or not. By
default, the principal point is chosen to best fit a subset of the source
image (determined by alpha
) to the corrected image.public static Rect getValidDisparityROI(Rect roi1, Rect roi2, int minDisparity, int numberOfDisparities, int SADWindowSize)
public static Mat initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints, java.util.List<MatOfPoint2f> imagePoints, Size imageSize)
Finds an initial camera matrix from 3D-2D point correspondences.
The function estimates and returns an initial camera matrix for the camera calibration process. Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.
objectPoints
- Vector of vectors of the calibration pattern points in
the calibration pattern coordinate space. In the old interface all the
per-view vectors are concatenated. See "calibrateCamera" for details.imagePoints
- Vector of vectors of the projections of the calibration
pattern points. In the old interface all the per-view vectors are
concatenated.imageSize
- Image size in pixels used to initialize the principal point.public static Mat initCameraMatrix2D(java.util.List<MatOfPoint3f> objectPoints, java.util.List<MatOfPoint2f> imagePoints, Size imageSize, double aspectRatio)
Finds an initial camera matrix from 3D-2D point correspondences.
The function estimates and returns an initial camera matrix for the camera calibration process. Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.
objectPoints
- Vector of vectors of the calibration pattern points in
the calibration pattern coordinate space. In the old interface all the
per-view vectors are concatenated. See "calibrateCamera" for details.imagePoints
- Vector of vectors of the projections of the calibration
pattern points. In the old interface all the per-view vectors are
concatenated.imageSize
- Image size in pixels used to initialize the principal point.aspectRatio
- If it is zero or negative, both f_x and
f_y are estimated independently. Otherwise, f_x = f_y *
aspectRatio.public static void matMulDeriv(Mat A, Mat B, Mat dABdA, Mat dABdB)
Computes partial derivatives of the matrix product for each multiplied matrix.
The function computes partial derivatives of the elements of the matrix product A*B with regard to the elements of each of the two input matrices. The function is used to compute the Jacobian matrices in "stereoCalibrate" but can also be used in any other similar optimization function.
A
- First multiplied matrix.B
- Second multiplied matrix.dABdA
- First output derivative matrix d(A*B)/dA
of size
A.rows*B.cols x (A.rows*A.cols).dABdB
- Second output derivative matrix d(A*B)/dB
of size
A.rows*B.cols x (B.rows*B.cols).public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints)
Projects 3D points to an image plane.
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 Jacobians are used during the global optimization in "calibrateCamera", "solvePnP", and "stereoCalibrate". The function itself can also be used to compute a re-projection error given the current intrinsic and extrinsic parameters.
Note: By setting rvec=tvec=(0,0,0)
or by setting
cameraMatrix
to a 3x3 identity matrix, or by passing zero
distortion coefficients, you can get various useful partial cases of the
function. This means that you can compute the distorted coordinates for a
sparse set of points or apply a perspective transformation (and also compute
the derivatives) in the ideal zero-distortion setup.
objectPoints
- Array of object points, 3xN/Nx3 1-channel or 1xN/Nx1
3-channel (or vector
), where N is the number of points
in the view.rvec
- Rotation vector. See "Rodrigues" for details.tvec
- Translation vector.cameraMatrix
- Camera matrix A =
|f_x 0 c_x| |0 f_y c_y| |0 0 _1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.imagePoints
- Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1
2-channel, or vector
.public static void projectPoints(MatOfPoint3f objectPoints, Mat rvec, Mat tvec, Mat cameraMatrix, MatOfDouble distCoeffs, MatOfPoint2f imagePoints, Mat jacobian, double aspectRatio)
Projects 3D points to an image plane.
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 Jacobians are used during the global optimization in "calibrateCamera", "solvePnP", and "stereoCalibrate". The function itself can also be used to compute a re-projection error given the current intrinsic and extrinsic parameters.
Note: By setting rvec=tvec=(0,0,0)
or by setting
cameraMatrix
to a 3x3 identity matrix, or by passing zero
distortion coefficients, you can get various useful partial cases of the
function. This means that you can compute the distorted coordinates for a
sparse set of points or apply a perspective transformation (and also compute
the derivatives) in the ideal zero-distortion setup.
objectPoints
- Array of object points, 3xN/Nx3 1-channel or 1xN/Nx1
3-channel (or vector
), where N is the number of points
in the view.rvec
- Rotation vector. See "Rodrigues" for details.tvec
- Translation vector.cameraMatrix
- Camera matrix A =
|f_x 0 c_x| |0 f_y c_y| |0 0 _1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.imagePoints
- Output array of image points, 2xN/Nx2 1-channel or 1xN/Nx1
2-channel, or vector
.jacobian
- Optional output 2Nx(10+aspectRatio
- Optional "fixed aspect ratio" parameter. If the parameter
is not 0, the function assumes that the aspect ratio (*fx/fy*) is fixed and
correspondingly adjusts the jacobian matrix.public static float rectify3Collinear(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Mat cameraMatrix3, Mat distCoeffs3, java.util.List<Mat> imgpt1, java.util.List<Mat> imgpt3, Size imageSize, Mat R12, Mat T12, Mat R13, Mat T13, Mat R1, Mat R2, Mat R3, Mat P1, Mat P2, Mat P3, Mat Q, double alpha, Size newImgSize, Rect roi1, Rect roi2, int flags)
public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q)
Reprojects a disparity image to 3D space.
The function transforms a single-channel disparity map to a 3-channel image
representing a 3D surface. That is, for each pixel (x,y)
andthe
corresponding disparity d=disparity(x,y)
, it computes:
[X Y Z W]^T = Q *[x y disparity(x,y) 1]^T _3dImage(x,y) = (X/W, Y/W, Z/W)
The matrix Q
can be an arbitrary 4 x 4 matrix (for
example, the one computed by "stereoRectify"). To reproject a sparse set of
points {(x,y,d),...} to 3D space, use "perspectiveTransform".
disparity
- Input single-channel 8-bit unsigned, 16-bit signed, 32-bit
signed or 32-bit floating-point disparity image._3dImage
- Output 3-channel floating-point image of the same size as
disparity
. Each element of _3dImage(x,y)
contains
3D coordinates of the point (x,y)
computed from the disparity
map.Q
- 4 x 4 perspective transformation matrix that can be
obtained with "stereoRectify".public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues)
Reprojects a disparity image to 3D space.
The function transforms a single-channel disparity map to a 3-channel image
representing a 3D surface. That is, for each pixel (x,y)
andthe
corresponding disparity d=disparity(x,y)
, it computes:
[X Y Z W]^T = Q *[x y disparity(x,y) 1]^T _3dImage(x,y) = (X/W, Y/W, Z/W)
The matrix Q
can be an arbitrary 4 x 4 matrix (for
example, the one computed by "stereoRectify"). To reproject a sparse set of
points {(x,y,d),...} to 3D space, use "perspectiveTransform".
disparity
- Input single-channel 8-bit unsigned, 16-bit signed, 32-bit
signed or 32-bit floating-point disparity image._3dImage
- Output 3-channel floating-point image of the same size as
disparity
. Each element of _3dImage(x,y)
contains
3D coordinates of the point (x,y)
computed from the disparity
map.Q
- 4 x 4 perspective transformation matrix that can be
obtained with "stereoRectify".handleMissingValues
- Indicates, whether the function should handle
missing values (i.e. points where the disparity was not computed). If
handleMissingValues=true
, then pixels with the minimal disparity
that corresponds to the outliers (see :ocv:funcx:"StereoBM.operator()") are
transformed to 3D points with a very large Z value (currently set to 10000).public static void reprojectImageTo3D(Mat disparity, Mat _3dImage, Mat Q, boolean handleMissingValues, int ddepth)
Reprojects a disparity image to 3D space.
The function transforms a single-channel disparity map to a 3-channel image
representing a 3D surface. That is, for each pixel (x,y)
andthe
corresponding disparity d=disparity(x,y)
, it computes:
[X Y Z W]^T = Q *[x y disparity(x,y) 1]^T _3dImage(x,y) = (X/W, Y/W, Z/W)
The matrix Q
can be an arbitrary 4 x 4 matrix (for
example, the one computed by "stereoRectify"). To reproject a sparse set of
points {(x,y,d),...} to 3D space, use "perspectiveTransform".
disparity
- Input single-channel 8-bit unsigned, 16-bit signed, 32-bit
signed or 32-bit floating-point disparity image._3dImage
- Output 3-channel floating-point image of the same size as
disparity
. Each element of _3dImage(x,y)
contains
3D coordinates of the point (x,y)
computed from the disparity
map.Q
- 4 x 4 perspective transformation matrix that can be
obtained with "stereoRectify".handleMissingValues
- Indicates, whether the function should handle
missing values (i.e. points where the disparity was not computed). If
handleMissingValues=true
, then pixels with the minimal disparity
that corresponds to the outliers (see :ocv:funcx:"StereoBM.operator()") are
transformed to 3D points with a very large Z value (currently set to 10000).ddepth
- The optional output array depth. If it is -1
, the
output image will have CV_32F
depth. ddepth
can
also be set to CV_16S
, CV_32S
or CV_32F
.public static void Rodrigues(Mat src, Mat dst)
Converts a rotation matrix to a rotation vector or vice versa.
theta <- norm(r) r <- r/ theta R = cos(theta) I + (1- cos(theta)) r r^T + sin(theta) |0 -r_z r_y| |r_z 0 -r_x| |-r_y r_x 0|
Inverse transformation can be also done easily, since
sin(theta) |0 -r_z r_y| |r_z 0 -r_x| |-r_y r_x 0| = (R - R^T)/2
A rotation vector is a convenient and most compact representation of a rotation matrix (since any rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry optimization procedures like "calibrateCamera", "stereoCalibrate", or "solvePnP".
src
- Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).dst
- Output rotation matrix (3x3) or rotation vector (3x1 or 1x3),
respectively.public static void Rodrigues(Mat src, Mat dst, Mat jacobian)
Converts a rotation matrix to a rotation vector or vice versa.
theta <- norm(r) r <- r/ theta R = cos(theta) I + (1- cos(theta)) r r^T + sin(theta) |0 -r_z r_y| |r_z 0 -r_x| |-r_y r_x 0|
Inverse transformation can be also done easily, since
sin(theta) |0 -r_z r_y| |r_z 0 -r_x| |-r_y r_x 0| = (R - R^T)/2
A rotation vector is a convenient and most compact representation of a rotation matrix (since any rotation matrix has just 3 degrees of freedom). The representation is used in the global 3D geometry optimization procedures like "calibrateCamera", "stereoCalibrate", or "solvePnP".
src
- Input rotation vector (3x1 or 1x3) or rotation matrix (3x3).dst
- Output rotation matrix (3x3) or rotation vector (3x1 or 1x3),
respectively.jacobian
- Optional output Jacobian matrix, 3x9 or 9x3, which is a
matrix of partial derivatives of the output array components with respect to
the input array components.public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ)
Computes an RQ decomposition of 3x3 matrices.
The function computes a RQ decomposition using the given rotations. This function is used in "decomposeProjectionMatrix" to decompose the left 3x3 submatrix of a projection matrix into a camera and a rotation matrix.
It optionally returns three rotation matrices, one for each axis, and the three Euler angles (as the return value) that could be used in OpenGL.
src
- 3x3 input matrix.mtxR
- Output 3x3 upper-triangular matrix.mtxQ
- Output 3x3 orthogonal matrix.public static double[] RQDecomp3x3(Mat src, Mat mtxR, Mat mtxQ, Mat Qx, Mat Qy, Mat Qz)
Computes an RQ decomposition of 3x3 matrices.
The function computes a RQ decomposition using the given rotations. This function is used in "decomposeProjectionMatrix" to decompose the left 3x3 submatrix of a projection matrix into a camera and a rotation matrix.
It optionally returns three rotation matrices, one for each axis, and the three Euler angles (as the return value) that could be used in OpenGL.
src
- 3x3 input matrix.mtxR
- Output 3x3 upper-triangular matrix.mtxQ
- Output 3x3 orthogonal matrix.Qx
- Optional output 3x3 rotation matrix around x-axis.Qy
- Optional output 3x3 rotation matrix around y-axis.Qz
- Optional output 3x3 rotation matrix around z-axis.public static boolean solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec)
Finds an object pose from 3D-2D point correspondences.
The function estimates the object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients.
objectPoints
- Array of object points in the object coordinate space,
3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points.
vector
can be also passed here.imagePoints
- Array of corresponding image points, 2xN/Nx2 1-channel or
1xN/Nx1 2-channel, where N is the number of points. vector
can be also passed here.cameraMatrix
- Input camera matrix A =
|fx 0 cx| |0 fy cy| |0 0 1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.rvec
- Output rotation vector (see "Rodrigues") that, together with
tvec
, brings points from the model coordinate system to the
camera coordinate system.tvec
- Output translation vector.public static boolean solvePnP(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int flags)
Finds an object pose from 3D-2D point correspondences.
The function estimates the object pose given a set of object points, their corresponding image projections, as well as the camera matrix and the distortion coefficients.
objectPoints
- Array of object points in the object coordinate space,
3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points.
vector
can be also passed here.imagePoints
- Array of corresponding image points, 2xN/Nx2 1-channel or
1xN/Nx1 2-channel, where N is the number of points. vector
can be also passed here.cameraMatrix
- Input camera matrix A =
|fx 0 cx| |0 fy cy| |0 0 1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.rvec
- Output rotation vector (see "Rodrigues") that, together with
tvec
, brings points from the model coordinate system to the
camera coordinate system.tvec
- Output translation vector.useExtrinsicGuess
- If true (1), the function uses the provided
rvec
and tvec
values as initial approximations of
the rotation and translation vectors, respectively, and further optimizes
them.flags
- Method for solving a PnP problem:
imagePoints
and the projected (using
"projectPoints") objectPoints
.
public static void solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec)
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
The function estimates an object pose given a set of object points, their
corresponding image projections, as well as the camera matrix and the
distortion coefficients. This function finds such a pose that minimizes
reprojection error, that is, the sum of squared distances between the
observed projections imagePoints
and the projected (using
"projectPoints") objectPoints
. The use of RANSAC makes the
function resistant to outliers. The function is parallelized with the TBB
library.
objectPoints
- Array of object points in the object coordinate space,
3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points.
vector
can be also passed here.imagePoints
- Array of corresponding image points, 2xN/Nx2 1-channel or
1xN/Nx1 2-channel, where N is the number of points. vector
can be also passed here.cameraMatrix
- Input camera matrix A =
|fx 0 cx| |0 fy cy| |0 0 1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.rvec
- Output rotation vector (see "Rodrigues") that, together with
tvec
, brings points from the model coordinate system to the
camera coordinate system.tvec
- Output translation vector.public static void solvePnPRansac(MatOfPoint3f objectPoints, MatOfPoint2f imagePoints, Mat cameraMatrix, MatOfDouble distCoeffs, Mat rvec, Mat tvec, boolean useExtrinsicGuess, int iterationsCount, float reprojectionError, int minInliersCount, Mat inliers, int flags)
Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
The function estimates an object pose given a set of object points, their
corresponding image projections, as well as the camera matrix and the
distortion coefficients. This function finds such a pose that minimizes
reprojection error, that is, the sum of squared distances between the
observed projections imagePoints
and the projected (using
"projectPoints") objectPoints
. The use of RANSAC makes the
function resistant to outliers. The function is parallelized with the TBB
library.
objectPoints
- Array of object points in the object coordinate space,
3xN/Nx3 1-channel or 1xN/Nx1 3-channel, where N is the number of points.
vector
can be also passed here.imagePoints
- Array of corresponding image points, 2xN/Nx2 1-channel or
1xN/Nx1 2-channel, where N is the number of points. vector
can be also passed here.cameraMatrix
- Input camera matrix A =
|fx 0 cx| |0 fy cy| |0 0 1|
.distCoeffs
- Input vector of distortion coefficients (k_1, k_2, p_1,
p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. If the vector is
NULL/empty, the zero distortion coefficients are assumed.rvec
- Output rotation vector (see "Rodrigues") that, together with
tvec
, brings points from the model coordinate system to the
camera coordinate system.tvec
- Output translation vector.useExtrinsicGuess
- If true (1), the function uses the provided
rvec
and tvec
values as initial approximations of
the rotation and translation vectors, respectively, and further optimizes
them.iterationsCount
- Number of iterations.reprojectionError
- Inlier threshold value used by the RANSAC procedure.
The parameter value is the maximum allowed distance between the observed and
computed point projections to consider it an inlier.minInliersCount
- Number of inliers. If the algorithm at some stage
finds more inliers than minInliersCount
, it finishes.inliers
- Output vector that contains indices of inliers in
objectPoints
and imagePoints
.flags
- Method for solving a PnP problem (see "solvePnP").public static double stereoCalibrate(java.util.List<Mat> objectPoints, java.util.List<Mat> imagePoints1, java.util.List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F)
Calibrates the stereo camera.
The function estimates transformation between two cameras making a stereo pair. If you have a stereo camera where the relative position and orientation of two cameras is fixed, and if you computed poses of an object relative to the first camera and to the second camera, (R1, T1) and (R2, T2), respectively (this can be done with "solvePnP"), then those poses definitely relate to each other. This means that, given (R_1,T_1), it should be possible to compute (R_2,T_2). You only need to know the position and orientation of the second camera relative to the first camera. This is what the described function does. It computes (R,T) so that:
R_2=R*R_1 T_2=R*T_1 + T,
Optionally, it computes the essential matrix E:
E= |0 -T_2 T_1| |T_2 0 -T_0| |-T_1 T_0 0|
where T_i are components of the translation vector T : T=[T_0, T_1, T_2]^T. And the function can also compute the fundamental matrix F:
F = cameraMatrix2^(-T) E cameraMatrix1^(-1)
Besides the stereo-related information, the function can also perform a full
calibration of each of two cameras. However, due to the high dimensionality
of the parameter space and noise in the input data, the function can diverge
from the correct solution. If the intrinsic parameters can be estimated with
high accuracy for each of the cameras individually (for example, using
"calibrateCamera"), you are recommended to do so and then pass
CV_CALIB_FIX_INTRINSIC
flag to the function along with the
computed intrinsic parameters. Otherwise, if all the parameters are estimated
at once, it makes sense to restrict some parameters, for example, pass
CV_CALIB_SAME_FOCAL_LENGTH
and CV_CALIB_ZERO_TANGENT_DIST
flags, which is usually a reasonable assumption.
Similarly to "calibrateCamera", the function minimizes the total re-projection error for all the points in all the available views from both cameras. The function returns the final value of the re-projection error.
objectPoints
- Vector of vectors of the calibration pattern points.imagePoints1
- Vector of vectors of the projections of the calibration
pattern points, observed by the first camera.imagePoints2
- Vector of vectors of the projections of the calibration
pattern points, observed by the second camera.cameraMatrix1
- Input/output first camera matrix:
|f_x^j 0 c_x^j| |0 f_y^j c_y^j| |0 0 1|
, j = 0, 1. If any ofCV_CALIB_USE_INTRINSIC_GUESS
,
CV_CALIB_FIX_ASPECT_RATIO
, CV_CALIB_FIX_INTRINSIC
,
or CV_CALIB_FIX_FOCAL_LENGTH
are specified, some or all of the
matrix components must be initialized. See the flags description for details.distCoeffs1
- Input/output vector of distortion coefficients (k_1,
k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. The
output vector length depends on the flags.cameraMatrix2
- Input/output second camera matrix. The parameter is
similar to cameraMatrix1
.distCoeffs2
- Input/output lens distortion coefficients for the second
camera. The parameter is similar to distCoeffs1
.imageSize
- Size of the image used only to initialize intrinsic camera
matrix.R
- Output rotation matrix between the 1st and the 2nd camera coordinate
systems.T
- Output translation vector between the coordinate systems of the
cameras.E
- Output essential matrix.F
- Output fundamental matrix.public static double stereoCalibrate(java.util.List<Mat> objectPoints, java.util.List<Mat> imagePoints1, java.util.List<Mat> imagePoints2, Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat E, Mat F, TermCriteria criteria, int flags)
Calibrates the stereo camera.
The function estimates transformation between two cameras making a stereo pair. If you have a stereo camera where the relative position and orientation of two cameras is fixed, and if you computed poses of an object relative to the first camera and to the second camera, (R1, T1) and (R2, T2), respectively (this can be done with "solvePnP"), then those poses definitely relate to each other. This means that, given (R_1,T_1), it should be possible to compute (R_2,T_2). You only need to know the position and orientation of the second camera relative to the first camera. This is what the described function does. It computes (R,T) so that:
R_2=R*R_1 T_2=R*T_1 + T,
Optionally, it computes the essential matrix E:
E= |0 -T_2 T_1| |T_2 0 -T_0| |-T_1 T_0 0|
where T_i are components of the translation vector T : T=[T_0, T_1, T_2]^T. And the function can also compute the fundamental matrix F:
F = cameraMatrix2^(-T) E cameraMatrix1^(-1)
Besides the stereo-related information, the function can also perform a full
calibration of each of two cameras. However, due to the high dimensionality
of the parameter space and noise in the input data, the function can diverge
from the correct solution. If the intrinsic parameters can be estimated with
high accuracy for each of the cameras individually (for example, using
"calibrateCamera"), you are recommended to do so and then pass
CV_CALIB_FIX_INTRINSIC
flag to the function along with the
computed intrinsic parameters. Otherwise, if all the parameters are estimated
at once, it makes sense to restrict some parameters, for example, pass
CV_CALIB_SAME_FOCAL_LENGTH
and CV_CALIB_ZERO_TANGENT_DIST
flags, which is usually a reasonable assumption.
Similarly to "calibrateCamera", the function minimizes the total re-projection error for all the points in all the available views from both cameras. The function returns the final value of the re-projection error.
objectPoints
- Vector of vectors of the calibration pattern points.imagePoints1
- Vector of vectors of the projections of the calibration
pattern points, observed by the first camera.imagePoints2
- Vector of vectors of the projections of the calibration
pattern points, observed by the second camera.cameraMatrix1
- Input/output first camera matrix:
|f_x^j 0 c_x^j| |0 f_y^j c_y^j| |0 0 1|
, j = 0, 1. If any ofCV_CALIB_USE_INTRINSIC_GUESS
,
CV_CALIB_FIX_ASPECT_RATIO
, CV_CALIB_FIX_INTRINSIC
,
or CV_CALIB_FIX_FOCAL_LENGTH
are specified, some or all of the
matrix components must be initialized. See the flags description for details.distCoeffs1
- Input/output vector of distortion coefficients (k_1,
k_2, p_1, p_2[, k_3[, k_4, k_5, k_6]]) of 4, 5, or 8 elements. The
output vector length depends on the flags.cameraMatrix2
- Input/output second camera matrix. The parameter is
similar to cameraMatrix1
.distCoeffs2
- Input/output lens distortion coefficients for the second
camera. The parameter is similar to distCoeffs1
.imageSize
- Size of the image used only to initialize intrinsic camera
matrix.R
- Output rotation matrix between the 1st and the 2nd camera coordinate
systems.T
- Output translation vector between the coordinate systems of the
cameras.E
- Output essential matrix.F
- Output fundamental matrix.criteria
- a criteriaflags
- Different flags that may be zero or a combination of the
following values:
cameraMatrix?
and
distCoeffs?
so that only R, T, E
, and
F
matrices are estimated.
CV_CALIB_USE_INTRINSIC_GUESS
is set, the coefficient from the supplied distCoeffs
matrix is
used. Otherwise, it is set to 0.
public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q)
Computes rectification transforms for each head of a calibrated stereo camera.
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by "stereoCalibrate" as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
P1 = f 0 cx_1 0 0 f cy 0 0 0 1 0
P2 = f 0 cx_2 T_x*f 0 f cy 0 0 0 1 0,
where T_x is a horizontal shift between the cameras and
cx_1=cx_2 if CV_CALIB_ZERO_DISPARITY
is set.
P1 = f 0 cx 0 0 f cy_1 0 0 0 1 0
P2 = f 0 cx 0 0 f cy_2 T_y*f 0 0 1 0,
where T_y is a vertical shift between the cameras and
cy_1=cy_2 if CALIB_ZERO_DISPARITY
is set.
As you can see, the first three columns of P1
and
P2
will effectively be the new "rectified" camera matrices.
The matrices, together with R1
and R2
, can then be
passed to "initUndistortRectifyMap" to initialize the rectification map for
each camera.
See below the screenshot from the stereo_calib.cpp
sample. Some
red horizontal lines pass through the corresponding image regions. This means
that the images are well rectified, which is what most stereo correspondence
algorithms rely on. The green rectangles are roi1
and
roi2
. You see that their interiors are all valid pixels.
cameraMatrix1
- First camera matrix.distCoeffs1
- First camera distortion parameters.cameraMatrix2
- Second camera matrix.distCoeffs2
- Second camera distortion parameters.imageSize
- Size of the image used for stereo calibration.R
- Rotation matrix between the coordinate systems of the first and the
second cameras.T
- Translation vector between coordinate systems of the cameras.R1
- Output 3x3 rectification transform (rotation matrix) for the first
camera.R2
- Output 3x3 rectification transform (rotation matrix) for the second
camera.P1
- Output 3x4 projection matrix in the new (rectified) coordinate
systems for the first camera.P2
- Output 3x4 projection matrix in the new (rectified) coordinate
systems for the second camera.Q
- Output 4 x 4 disparity-to-depth mapping matrix (see
"reprojectImageTo3D").public static void stereoRectify(Mat cameraMatrix1, Mat distCoeffs1, Mat cameraMatrix2, Mat distCoeffs2, Size imageSize, Mat R, Mat T, Mat R1, Mat R2, Mat P1, Mat P2, Mat Q, int flags, double alpha, Size newImageSize, Rect validPixROI1, Rect validPixROI2)
Computes rectification transforms for each head of a calibrated stereo camera.
The function computes the rotation matrices for each camera that (virtually) make both camera image planes the same plane. Consequently, this makes all the epipolar lines parallel and thus simplifies the dense stereo correspondence problem. The function takes the matrices computed by "stereoCalibrate" as input. As output, it provides two rotation matrices and also two projection matrices in the new coordinates. The function distinguishes the following two cases:
P1 = f 0 cx_1 0 0 f cy 0 0 0 1 0
P2 = f 0 cx_2 T_x*f 0 f cy 0 0 0 1 0,
where T_x is a horizontal shift between the cameras and
cx_1=cx_2 if CV_CALIB_ZERO_DISPARITY
is set.
P1 = f 0 cx 0 0 f cy_1 0 0 0 1 0
P2 = f 0 cx 0 0 f cy_2 T_y*f 0 0 1 0,
where T_y is a vertical shift between the cameras and
cy_1=cy_2 if CALIB_ZERO_DISPARITY
is set.
As you can see, the first three columns of P1
and
P2
will effectively be the new "rectified" camera matrices.
The matrices, together with R1
and R2
, can then be
passed to "initUndistortRectifyMap" to initialize the rectification map for
each camera.
See below the screenshot from the stereo_calib.cpp
sample. Some
red horizontal lines pass through the corresponding image regions. This means
that the images are well rectified, which is what most stereo correspondence
algorithms rely on. The green rectangles are roi1
and
roi2
. You see that their interiors are all valid pixels.
cameraMatrix1
- First camera matrix.distCoeffs1
- First camera distortion parameters.cameraMatrix2
- Second camera matrix.distCoeffs2
- Second camera distortion parameters.imageSize
- Size of the image used for stereo calibration.R
- Rotation matrix between the coordinate systems of the first and the
second cameras.T
- Translation vector between coordinate systems of the cameras.R1
- Output 3x3 rectification transform (rotation matrix) for the first
camera.R2
- Output 3x3 rectification transform (rotation matrix) for the second
camera.P1
- Output 3x4 projection matrix in the new (rectified) coordinate
systems for the first camera.P2
- Output 3x4 projection matrix in the new (rectified) coordinate
systems for the second camera.Q
- Output 4 x 4 disparity-to-depth mapping matrix (see
"reprojectImageTo3D").flags
- Operation flags that may be zero or CV_CALIB_ZERO_DISPARITY
.
If the flag is set, the function makes the principal points of each camera
have the same pixel coordinates in the rectified views. And if the flag is
not set, the function may still shift the images in the horizontal or
vertical direction (depending on the orientation of epipolar lines) to
maximize the useful image area.alpha
- Free scaling parameter. If it is -1 or absent, the function
performs the default scaling. Otherwise, the parameter should be between 0
and 1. alpha=0
means that the rectified images are zoomed and
shifted so that only valid pixels are visible (no black areas after
rectification). alpha=1
means that the rectified image is
decimated and shifted so that all the pixels from the original images from
the cameras are retained in the rectified images (no source image pixels are
lost). Obviously, any intermediate value yields an intermediate result
between those two extreme cases.newImageSize
- New image resolution after rectification. The same size
should be passed to "initUndistortRectifyMap" (see the stereo_calib.cpp
sample in OpenCV samples directory). When (0,0) is passed (default), it is
set to the original imageSize
. Setting it to larger value can
help you preserve details in the original image, especially when there is a
big radial distortion.validPixROI1
- Optional output rectangles inside the rectified images
where all the pixels are valid. If alpha=0
, the ROIs cover the
whole images. Otherwise, they are likely to be smaller (see the picture
below).validPixROI2
- Optional output rectangles inside the rectified images
where all the pixels are valid. If alpha=0
, the ROIs cover the
whole images. Otherwise, they are likely to be smaller (see the picture
below).public static boolean stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2)
Computes a rectification transform for an uncalibrated stereo camera.
The function computes the rectification transformations without knowing
intrinsic parameters of the cameras and their relative position in the space,
which explains the suffix "uncalibrated". Another related difference from
"stereoRectify" is that the function outputs not the rectification
transformations in the object (3D) space, but the planar perspective
transformations encoded by the homography matrices H1
and
H2
. The function implements the algorithm [Hartley99].
Note:
While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion, it would be better to correct it before computing the fundamental matrix and calling this function. For example, distortion coefficients can be estimated for each head of stereo camera separately by using "calibrateCamera". Then, the images can be corrected using "undistort", or just the point coordinates can be corrected with "undistortPoints".
points1
- Array of feature points in the first image.points2
- The corresponding points in the second image. The same formats
as in "findFundamentalMat" are supported.F
- Input fundamental matrix. It can be computed from the same set of
point pairs using "findFundamentalMat".imgSize
- Size of the image.H1
- Output rectification homography matrix for the first image.H2
- Output rectification homography matrix for the second image.public static boolean stereoRectifyUncalibrated(Mat points1, Mat points2, Mat F, Size imgSize, Mat H1, Mat H2, double threshold)
Computes a rectification transform for an uncalibrated stereo camera.
The function computes the rectification transformations without knowing
intrinsic parameters of the cameras and their relative position in the space,
which explains the suffix "uncalibrated". Another related difference from
"stereoRectify" is that the function outputs not the rectification
transformations in the object (3D) space, but the planar perspective
transformations encoded by the homography matrices H1
and
H2
. The function implements the algorithm [Hartley99].
Note:
While the algorithm does not need to know the intrinsic parameters of the cameras, it heavily depends on the epipolar geometry. Therefore, if the camera lenses have a significant distortion, it would be better to correct it before computing the fundamental matrix and calling this function. For example, distortion coefficients can be estimated for each head of stereo camera separately by using "calibrateCamera". Then, the images can be corrected using "undistort", or just the point coordinates can be corrected with "undistortPoints".
points1
- Array of feature points in the first image.points2
- The corresponding points in the second image. The same formats
as in "findFundamentalMat" are supported.F
- Input fundamental matrix. It can be computed from the same set of
point pairs using "findFundamentalMat".imgSize
- Size of the image.H1
- Output rectification homography matrix for the first image.H2
- Output rectification homography matrix for the second image.threshold
- Optional threshold used to filter out the outliers. If the
parameter is greater than zero, all the point pairs that do not comply with
the epipolar geometry (that is, the points for which |points2[i]^T*F*points1[i]|>threshold)
are rejected prior to computing the homographies. Otherwise,all the points
are considered inliers.public static void triangulatePoints(Mat projMatr1, Mat projMatr2, Mat projPoints1, Mat projPoints2, Mat points4D)
Reconstructs points by triangulation.
The function reconstructs 3-dimensional points (in homogeneous coordinates) by using their observations with a stereo camera. Projections matrices can be obtained from "stereoRectify".
projMatr1
- 3x4 projection matrix of the first camera.projMatr2
- 3x4 projection matrix of the second camera.projPoints1
- 2xN array of feature points in the first image.projPoints2
- 2xN array of corresponding points in the second image.points4D
- 4xN array of reconstructed points in homogeneous coordinates.reprojectImageTo3D(org.opencv.core.Mat, org.opencv.core.Mat, org.opencv.core.Mat, boolean, int)
public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities)
public static void validateDisparity(Mat disparity, Mat cost, int minDisparity, int numberOfDisparities, int disp12MaxDisp)
|
Official OpenCV 2.4 Documentation | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |