From 1fa37fe733756bbc8c48dfd6ee5a7a25c9c6521f Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 6 Jan 2015 16:57:21 +0300 Subject: [PATCH 1/3] OpenCV for Tegra compilation fix for - Gaussian blur; - CascadeClassifier; - Blenders in stitching module; - Laplacial pyromids in stitching module. --- modules/imgproc/src/smooth.cpp | 4 +++- modules/objdetect/src/cascadedetect.cpp | 2 +- modules/objdetect/src/cascadedetect.hpp | 2 ++ modules/stitching/src/blenders.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 5ab70d9a26..2a69003641 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -1497,7 +1497,9 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, } #ifdef HAVE_TEGRA_OPTIMIZATION - if(sigma1 == 0 && sigma2 == 0 && tegra::gaussian(_src.getMat(), _dst.getMat(), ksize, borderType)) + Mat src = _src.getMat(); + Mat dst = _dst.getMat(); + if(sigma1 == 0 && sigma2 == 0 && tegra::gaussian(src, dst, ksize, borderType)) return; #endif diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 4e25a5ccf1..8a61c2dd7e 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -931,7 +931,7 @@ Ptr CascadeClassifierImpl::getMaskGenerato Ptr createFaceDetectionMaskGenerator() { #ifdef HAVE_TEGRA_OPTIMIZATION - return tegra::getCascadeClassifierMaskGenerator(*this); + return tegra::getCascadeClassifierMaskGenerator(); #else return Ptr(); #endif diff --git a/modules/objdetect/src/cascadedetect.hpp b/modules/objdetect/src/cascadedetect.hpp index 17eeccd53b..4cbf3e9bf0 100644 --- a/modules/objdetect/src/cascadedetect.hpp +++ b/modules/objdetect/src/cascadedetect.hpp @@ -1,5 +1,7 @@ #pragma once +#include "opencv2/core/ocl.hpp" + namespace cv { diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index c36e6877bc..3fddff5ffe 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -477,6 +477,8 @@ static bool ocl_normalizeUsingWeightMap(InputArray _weight, InputOutputArray _ma void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) { #ifdef HAVE_TEGRA_OPTIMIZATION + Mat weight = _weight.getMat(); + Mat src = _src.getMat(); if(tegra::normalizeUsingWeightMap(weight, src)) return; #endif @@ -486,9 +488,6 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) !ocl_normalizeUsingWeightMap(_weight, _src) ) #endif { - Mat weight = _weight.getMat(); - Mat src = _src.getMat(); - CV_Assert(src.type() == CV_16SC3); if(weight.type() == CV_32FC1) @@ -547,7 +546,8 @@ void createWeightMap(InputArray mask, float sharpness, InputOutputArray weight) void createLaplacePyr(InputArray img, int num_levels, std::vector &pyr) { #ifdef HAVE_TEGRA_OPTIMIZATION - if(tegra::createLaplacePyr(img, num_levels, pyr)) + cv::Mat imgMat = img.getMat(); + if(tegra::createLaplacePyr(imgMat, num_levels, pyr)) return; #endif From 54f52c3f45e998d50dcf77e13945ed1dcf5d2408 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 13 Jan 2015 23:33:01 +0300 Subject: [PATCH 2/3] Build fix for non-TEGRA case. --- modules/stitching/src/blenders.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index 3fddff5ffe..caae058681 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -476,9 +476,9 @@ static bool ocl_normalizeUsingWeightMap(InputArray _weight, InputOutputArray _ma void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) { -#ifdef HAVE_TEGRA_OPTIMIZATION - Mat weight = _weight.getMat(); Mat src = _src.getMat(); + Mat weight = _weight.getMat(); +#ifdef HAVE_TEGRA_OPTIMIZATION if(tegra::normalizeUsingWeightMap(weight, src)) return; #endif From cc97c57fd495c25c7872d25a7acef7c100e5cfed Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 16 Jan 2015 13:22:51 +0300 Subject: [PATCH 3/3] Accuracy fix for blenaders in stitching module. --- modules/stitching/src/blenders.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index caae058681..015ceb025f 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -476,9 +476,11 @@ static bool ocl_normalizeUsingWeightMap(InputArray _weight, InputOutputArray _ma void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) { - Mat src = _src.getMat(); - Mat weight = _weight.getMat(); + Mat src; + Mat weight; #ifdef HAVE_TEGRA_OPTIMIZATION + src = _src.getMat(); + weight = _weight.getMat(); if(tegra::normalizeUsingWeightMap(weight, src)) return; #endif @@ -488,9 +490,12 @@ void normalizeUsingWeightMap(InputArray _weight, InputOutputArray _src) !ocl_normalizeUsingWeightMap(_weight, _src) ) #endif { + src = _src.getMat(); + weight = _weight.getMat(); + CV_Assert(src.type() == CV_16SC3); - if(weight.type() == CV_32FC1) + if (weight.type() == CV_32FC1) { for (int y = 0; y < src.rows; ++y) {