mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 03:33:28 +08:00
imgproc(getPerspectiveTransform): add solveMethod parameter
drop compatibility workaround via runtime parameter
This commit is contained in:
parent
9787ab598b
commit
d044ac1c66
@ -2359,9 +2359,6 @@ coordinate origin is assumed to be the top-left corner).
|
||||
*/
|
||||
CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale );
|
||||
|
||||
//! returns 3x3 perspective transformation for the corresponding 4 point pairs.
|
||||
CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
|
||||
|
||||
/** @brief Calculates an affine transform from three pairs of the corresponding points.
|
||||
|
||||
The function calculates the \f$2 \times 3\f$ matrix of an affine transform so that:
|
||||
@ -2404,10 +2401,15 @@ where
|
||||
|
||||
@param src Coordinates of quadrangle vertices in the source image.
|
||||
@param dst Coordinates of the corresponding quadrangle vertices in the destination image.
|
||||
@param solveMethod method passed to cv::solve (#DecompTypes)
|
||||
|
||||
@sa findHomography, warpPerspective, perspectiveTransform
|
||||
*/
|
||||
CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst );
|
||||
CV_EXPORTS_W Mat getPerspectiveTransform(InputArray src, InputArray dst, int solveMethod = DECOMP_LU);
|
||||
|
||||
/** @overload */
|
||||
CV_EXPORTS Mat getPerspectiveTransform(const Point2f src[], const Point2f dst[], int solveMethod = DECOMP_LU);
|
||||
|
||||
|
||||
CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
|
||||
|
||||
|
@ -290,4 +290,23 @@ PERF_TEST(Transform, getPerspectiveTransform_1000)
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST(Transform, getPerspectiveTransform_QR_1000)
|
||||
{
|
||||
unsigned int size = 8;
|
||||
Mat source(1, size/2, CV_32FC2);
|
||||
Mat destination(1, size/2, CV_32FC2);
|
||||
Mat transformCoefficient;
|
||||
|
||||
declare.in(source, destination, WARMUP_RNG);
|
||||
|
||||
PERF_SAMPLE_BEGIN()
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
transformCoefficient = getPerspectiveTransform(source, destination, DECOMP_QR);
|
||||
}
|
||||
PERF_SAMPLE_END()
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -3039,7 +3039,7 @@ cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale )
|
||||
* where:
|
||||
* cij - matrix coefficients, c22 = 1
|
||||
*/
|
||||
cv::Mat cv::getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
|
||||
cv::Mat cv::getPerspectiveTransform(const Point2f src[], const Point2f dst[], int solveMethod)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
|
||||
@ -3062,9 +3062,7 @@ cv::Mat cv::getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
|
||||
b[i+4] = dst[i].y;
|
||||
}
|
||||
|
||||
static int param_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD =
|
||||
(int)utils::getConfigurationParameterSizeT("OPENCV_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD", (size_t)DECOMP_LU);
|
||||
solve(A, B, X, param_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD);
|
||||
solve(A, B, X, solveMethod);
|
||||
M.ptr<double>()[8] = 1.;
|
||||
|
||||
return M;
|
||||
@ -3153,11 +3151,11 @@ void cv::invertAffineTransform(InputArray _matM, OutputArray __iM)
|
||||
CV_Error( CV_StsUnsupportedFormat, "" );
|
||||
}
|
||||
|
||||
cv::Mat cv::getPerspectiveTransform(InputArray _src, InputArray _dst)
|
||||
cv::Mat cv::getPerspectiveTransform(InputArray _src, InputArray _dst, int solveMethod)
|
||||
{
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
CV_Assert(src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4);
|
||||
return getPerspectiveTransform((const Point2f*)src.data, (const Point2f*)dst.data);
|
||||
return getPerspectiveTransform((const Point2f*)src.data, (const Point2f*)dst.data, solveMethod);
|
||||
}
|
||||
|
||||
cv::Mat cv::getAffineTransform(InputArray _src, InputArray _dst)
|
||||
|
Loading…
Reference in New Issue
Block a user