From 18ce0dff244ac27b586de64d2301ffb4f115f19d Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Wed, 25 Jan 2012 12:43:47 +0000 Subject: [PATCH] fixed bug #1552 --- modules/imgproc/src/templmatch.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 4a62d35..0f445ef 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -44,7 +44,7 @@ namespace cv { -void crossCorr( const Mat& img, const Mat& templ, Mat& corr, +void crossCorr( const Mat& img, const Mat& _templ, Mat& corr, Size corrsize, int ctype, Point anchor, double delta, int borderType ) { @@ -52,14 +52,21 @@ void crossCorr( const Mat& img, const Mat& templ, Mat& corr, const int minBlockSize = 256; std::vector buf; + Mat templ = _templ; int depth = img.depth(), cn = img.channels(); int tdepth = templ.depth(), tcn = templ.channels(); int cdepth = CV_MAT_DEPTH(ctype), ccn = CV_MAT_CN(ctype); CV_Assert( img.dims <= 2 && templ.dims <= 2 && corr.dims <= 2 ); CV_Assert( depth == CV_8U || depth == CV_16U || depth == CV_32F || depth == CV_64F ); - CV_Assert( depth == tdepth || tdepth == CV_32F ); + if( depth != tdepth && tdepth != std::max(CV_32F, depth) ) + { + _templ.convertTo(templ, std::max(CV_32F, depth)); + tdepth = templ.depth(); + } + + CV_Assert( depth == tdepth || tdepth == CV_32F); CV_Assert( corrsize.height <= img.rows + templ.rows - 1 && corrsize.width <= img.cols + templ.cols - 1 ); -- 2.7.4