From 1e2fb6de3065547d7107cb6eec628c9f7f0802da Mon Sep 17 00:00:00 2001 From: perping Date: Wed, 13 Nov 2013 10:09:39 +0800 Subject: [PATCH] fix match_template and haar --- modules/ocl/src/haar.cpp | 6 +++--- modules/ocl/src/match_template.cpp | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/ocl/src/haar.cpp b/modules/ocl/src/haar.cpp index bd5a8d1..ac8a64e 100644 --- a/modules/ocl/src/haar.cpp +++ b/modules/ocl/src/haar.cpp @@ -800,7 +800,7 @@ CvSeq *cv::ocl::OclCascadeClassifier::oclHaarDetectObjects( oclMat &gimg, CvMemS indexy += sz.height; } - if(Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE)) + if(gsqsum_t.depth() == CV_64F) gsqsum_t.convertTo(gsqsum, CV_32FC1); else gsqsum = gsqsum_t; @@ -1294,7 +1294,7 @@ void cv::ocl::OclCascadeClassifierBuf::detectMultiScale(oclMat &gimg, CV_OUT std cv::ocl::integral(resizeroi, gimgroi, gimgroisq); indexy += sz.height; } - if(Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE)) + if(gsqsum_t.depth() == CV_64F) gsqsum_t.convertTo(gsqsum, CV_32FC1); else gsqsum = gsqsum_t; @@ -1360,7 +1360,7 @@ void cv::ocl::OclCascadeClassifierBuf::detectMultiScale(oclMat &gimg, CV_OUT std else { cv::ocl::integral(gimg, gsum, gsqsum_t); - if(Context::getContext()->supportsFeature(FEATURE_CL_DOUBLE)) + if(gsqsum_t.depth() == CV_64F) gsqsum_t.convertTo(gsqsum, CV_32FC1); else gsqsum = gsqsum_t; diff --git a/modules/ocl/src/match_template.cpp b/modules/ocl/src/match_template.cpp index d18bacc..28397b6 100644 --- a/modules/ocl/src/match_template.cpp +++ b/modules/ocl/src/match_template.cpp @@ -250,7 +250,10 @@ namespace cv buf.image_sums.resize(1); buf.image_sqsums.resize(1); integral(image.reshape(1), buf.image_sums[0], temp); - temp.convertTo(buf.image_sqsums[0], CV_32FC1); + if(temp.depth() == CV_64F) + temp.convertTo(buf.image_sqsums[0], CV_32FC1); + else + buf.image_sqsums[0] = temp; unsigned long long templ_sqsum = (unsigned long long)sqrSum(templ.reshape(1))[0]; Context *clCxt = image.clCxt; @@ -416,7 +419,12 @@ namespace cv { buf.image_sums.resize(1); buf.image_sqsums.resize(1); - integral(image, buf.image_sums[0], buf.image_sqsums[0]); + cv::ocl::oclMat temp; + integral(image, buf.image_sums[0], temp); + if(temp.depth() == CV_64F) + temp.convertTo(buf.image_sqsums[0], CV_32FC1); + else + buf.image_sqsums[0] = temp; templ_sum[0] = (float)sum(templ)[0]; @@ -452,10 +460,14 @@ namespace cv templ_sum *= scale; buf.image_sums.resize(buf.images.size()); buf.image_sqsums.resize(buf.images.size()); - + cv::ocl::oclMat temp; for(int i = 0; i < image.oclchannels(); i ++) { - integral(buf.images[i], buf.image_sums[i], buf.image_sqsums[i]); + integral(buf.images[i], buf.image_sums[i], temp); + if(temp.depth() == CV_64F) + temp.convertTo(buf.image_sqsums[i], CV_32FC1); + else + buf.image_sqsums[i] = temp; } switch(image.oclchannels()) -- 2.7.4