From c4a31a1ab161c8cb0a3977e52df5abc41666380a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 26 Feb 2014 17:01:45 +0400 Subject: [PATCH] TAPI: stitching: optimize compare operation --- modules/stitching/src/blenders.cpp | 14 +++++++++----- modules/stitching/src/warpers.cpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index 5012d9ba4a..922c524d0a 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -107,7 +107,9 @@ void Blender::feed(InputArray _img, InputArray _mask, Point tl) void Blender::blend(InputOutputArray dst, InputOutputArray dst_mask) { - dst_.setTo(Scalar::all(0), dst_mask_.getMat(ACCESS_READ) == 0); // TODO + UMat mask; + compare(dst_mask_, 0, mask, CMP_EQ); + dst_.setTo(Scalar::all(0), mask); dst.assign(dst_); dst_mask.assign(dst_mask_); dst_.release(); @@ -159,7 +161,7 @@ void FeatherBlender::feed(InputArray _img, InputArray mask, Point tl) void FeatherBlender::blend(InputOutputArray dst, InputOutputArray dst_mask) { normalizeUsingWeightMap(dst_weight_map_, dst_); - dst_mask_ = ((Mat)(dst_weight_map_.getMat(ACCESS_READ) > WEIGHT_EPS)).getUMat(ACCESS_READ); + compare(dst_weight_map_, WEIGHT_EPS, dst_mask_, CMP_GT); Blender::blend(dst, dst_mask); } @@ -301,7 +303,9 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl) else // weight_type_ == CV_16S { mask.getUMat().convertTo(weight_map, CV_16S); - add(weight_map, Scalar::all(1), weight_map, mask.getMat(ACCESS_READ) != 0); // TODO + UMat add_mask; + compare(mask, 0, add_mask, CMP_NE); + add(weight_map, Scalar::all(1), weight_map, add_mask); } copyMakeBorder(weight_map, weight_pyr_gauss[0], top, bottom, left, right, BORDER_CONSTANT); @@ -388,8 +392,8 @@ void MultiBandBlender::blend(InputOutputArray dst, InputOutputArray dst_mask) dst_ = dst_pyr_laplace_[0]; dst_ = dst_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); - dst_mask_ = ((Mat)(dst_band_weights_[0].getMat(ACCESS_READ) > WEIGHT_EPS)).getUMat(ACCESS_READ); - dst_mask_ = dst_mask_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); + UMat _dst_mask; + compare(dst_band_weights_[0](Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)), WEIGHT_EPS, dst_mask_, CMP_GT); dst_pyr_laplace_.clear(); dst_band_weights_.clear(); diff --git a/modules/stitching/src/warpers.cpp b/modules/stitching/src/warpers.cpp index a05ad1f5dd..b6d1f8a8ad 100644 --- a/modules/stitching/src/warpers.cpp +++ b/modules/stitching/src/warpers.cpp @@ -98,7 +98,7 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra _xmap.create(dsize, CV_32FC1); _ymap.create(dsize, CV_32FC1); - if (ocl::useOpenCL()) // TODO !!!!! check T + if (ocl::useOpenCL()) { ocl::Kernel k("buildWarpPlaneMaps", ocl::stitching::warpers_oclsrc); if (!k.empty())