Commit d044ac1c authored by Alexander Alekhin's avatar Alexander Alekhin

imgproc(getPerspectiveTransform): add solveMethod parameter

drop compatibility workaround via runtime parameter
parent 9787ab59
...@@ -2359,9 +2359,6 @@ coordinate origin is assumed to be the top-left corner). ...@@ -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 ); 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. /** @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: The function calculates the \f$2 \times 3\f$ matrix of an affine transform so that:
...@@ -2404,10 +2401,15 @@ where ...@@ -2404,10 +2401,15 @@ where
@param src Coordinates of quadrangle vertices in the source image. @param src Coordinates of quadrangle vertices in the source image.
@param dst Coordinates of the corresponding quadrangle vertices in the destination 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 @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 ); CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
......
...@@ -290,4 +290,23 @@ PERF_TEST(Transform, getPerspectiveTransform_1000) ...@@ -290,4 +290,23 @@ PERF_TEST(Transform, getPerspectiveTransform_1000)
SANITY_CHECK_NOTHING(); 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 } // namespace
...@@ -3039,7 +3039,7 @@ cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale ) ...@@ -3039,7 +3039,7 @@ cv::Mat cv::getRotationMatrix2D( Point2f center, double angle, double scale )
* where: * where:
* cij - matrix coefficients, c22 = 1 * 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() CV_INSTRUMENT_REGION()
...@@ -3062,9 +3062,7 @@ cv::Mat cv::getPerspectiveTransform( const Point2f src[], const Point2f dst[] ) ...@@ -3062,9 +3062,7 @@ cv::Mat cv::getPerspectiveTransform( const Point2f src[], const Point2f dst[] )
b[i+4] = dst[i].y; b[i+4] = dst[i].y;
} }
static int param_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD = solve(A, B, X, solveMethod);
(int)utils::getConfigurationParameterSizeT("OPENCV_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD", (size_t)DECOMP_LU);
solve(A, B, X, param_IMGPROC_GETPERSPECTIVETRANSFORM_SOLVE_METHOD);
M.ptr<double>()[8] = 1.; M.ptr<double>()[8] = 1.;
return M; return M;
...@@ -3153,11 +3151,11 @@ void cv::invertAffineTransform(InputArray _matM, OutputArray __iM) ...@@ -3153,11 +3151,11 @@ void cv::invertAffineTransform(InputArray _matM, OutputArray __iM)
CV_Error( CV_StsUnsupportedFormat, "" ); 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(); Mat src = _src.getMat(), dst = _dst.getMat();
CV_Assert(src.checkVector(2, CV_32F) == 4 && dst.checkVector(2, CV_32F) == 4); 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) cv::Mat cv::getAffineTransform(InputArray _src, InputArray _dst)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment