Browse Source

Added CvInvoke.InitCameraMatrix2D

pull/24/head
Canming Huang 8 years ago
parent
commit
022852afc5
  1. 11
      Emgu.CV.Extern/calib3d/calib3d_c.cpp
  2. 7
      Emgu.CV.Extern/calib3d/calib3d_c.h
  3. 27
      Emgu.CV/PInvoke/CvInvokeCalib3d.cs

11
Emgu.CV.Extern/calib3d/calib3d_c.cpp

@ -262,6 +262,17 @@ void cveGetOptimalNewCameraMatrix(
cv::swap(m, *newCameraMatrix);
}
void cveInitCameraMatrix2D(
cv::_InputArray* objectPoints,
cv::_InputArray* imagePoints,
CvSize* imageSize,
double aspectRatio,
cv::Mat* cameraMatrix)
{
cv::Mat m = cv::initCameraMatrix2D(*objectPoints, *imagePoints, *imageSize, aspectRatio);
cv::swap(m, *cameraMatrix);
}
/* Fisheye calibration */
void cveFisheyeProjectPoints(cv::_InputArray* objectPoints, cv::_OutputArray* imagePoints, cv::_InputArray* rvec, cv::_InputArray* tvec,
cv::_InputArray* K, cv::_InputArray* D, double alpha, cv::_OutputArray* jacobian)

7
Emgu.CV.Extern/calib3d/calib3d_c.h

@ -103,6 +103,13 @@ CVAPI(void) cveGetOptimalNewCameraMatrix(
bool centerPrincipalPoint,
cv::Mat* newCameraMatrix);
CVAPI(void) cveInitCameraMatrix2D(
cv::_InputArray* objectPoints,
cv::_InputArray* imagePoints,
CvSize* imageSize,
double aspectRatio,
cv::Mat* cameraMatrix);
/* Fisheye calibration */
CVAPI(void) cveFisheyeProjectPoints(cv::_InputArray* objectPoints, cv::_OutputArray* imagePoints, cv::_InputArray* rvec, cv::_InputArray* tvec,
cv::_InputArray* K, cv::_InputArray* D, double alpha, cv::_OutputArray* jacobian);

27
Emgu.CV/PInvoke/CvInvokeCalib3d.cs

@ -299,6 +299,33 @@ namespace Emgu.CV
bool centerPrincipalPoint,
IntPtr newCameraMatrix);
/// <summary>
/// Finds an initial camera matrix from 3D-2D point correspondences.
/// </summary>
/// <param name="objectPoints">Vector of vectors of the calibration pattern points in the calibration pattern coordinate space.</param>
/// <param name="imagePoints">Vector of vectors of the projections of the calibration pattern points.</param>
/// <param name="imageSize">Image size in pixels used to initialize the principal point.</param>
/// <param name="aspectRatio">If it is zero or negative, both fx and fy are estimated independently. Otherwise, fx=fy*aspectRatio.</param>
/// <returns>An initial camera matrix for the camera calibration process.</returns>
/// <remarks>Currently, the function only supports planar calibration patterns, which are patterns where each object point has z-coordinate =0.</remarks>
public static Mat InitCameraMatrix2D(IInputArrayOfArrays objectPoints, IInputArrayOfArrays imagePoints, Size imageSize,
double aspectRatio = 1.0)
{
Mat m = new Mat();
using (InputArray iaObjectPoints = objectPoints.GetInputArray())
using (InputArray iaImagePoints = imagePoints.GetInputArray())
cveInitCameraMatrix2D(iaObjectPoints, iaImagePoints, ref imageSize, aspectRatio, m );
return m;
}
[DllImport(ExternLibrary, CallingConvention = CvInvoke.CvCallingConvention)]
private static extern void cveInitCameraMatrix2D(
IntPtr objectPoints,
IntPtr imagePoints,
ref Size imageSize,
double aspectRatio,
IntPtr cameraMatrix);
/// <summary>
/// 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 as functions of all the input parameters w.r.t. the particular parameters, intrinsic and/or extrinsic.

Loading…
Cancel
Save