Commit c4a31a1a authored by Alexander Alekhin's avatar Alexander Alekhin Committed by Andrey Pavlenko

TAPI: stitching: optimize compare operation

parent 7a5c1bab
...@@ -107,7 +107,9 @@ void Blender::feed(InputArray _img, InputArray _mask, Point tl) ...@@ -107,7 +107,9 @@ void Blender::feed(InputArray _img, InputArray _mask, Point tl)
void Blender::blend(InputOutputArray dst, InputOutputArray dst_mask) 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.assign(dst_);
dst_mask.assign(dst_mask_); dst_mask.assign(dst_mask_);
dst_.release(); dst_.release();
...@@ -159,7 +161,7 @@ void FeatherBlender::feed(InputArray _img, InputArray mask, Point tl) ...@@ -159,7 +161,7 @@ void FeatherBlender::feed(InputArray _img, InputArray mask, Point tl)
void FeatherBlender::blend(InputOutputArray dst, InputOutputArray dst_mask) void FeatherBlender::blend(InputOutputArray dst, InputOutputArray dst_mask)
{ {
normalizeUsingWeightMap(dst_weight_map_, dst_); 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); Blender::blend(dst, dst_mask);
} }
...@@ -301,7 +303,9 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl) ...@@ -301,7 +303,9 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
else // weight_type_ == CV_16S else // weight_type_ == CV_16S
{ {
mask.getUMat().convertTo(weight_map, 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); 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) ...@@ -388,8 +392,8 @@ void MultiBandBlender::blend(InputOutputArray dst, InputOutputArray dst_mask)
dst_ = dst_pyr_laplace_[0]; dst_ = dst_pyr_laplace_[0];
dst_ = dst_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); 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); UMat _dst_mask;
dst_mask_ = dst_mask_(Range(0, dst_roi_final_.height), Range(0, dst_roi_final_.width)); 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_pyr_laplace_.clear();
dst_band_weights_.clear(); dst_band_weights_.clear();
......
...@@ -98,7 +98,7 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra ...@@ -98,7 +98,7 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra
_xmap.create(dsize, CV_32FC1); _xmap.create(dsize, CV_32FC1);
_ymap.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); ocl::Kernel k("buildWarpPlaneMaps", ocl::stitching::warpers_oclsrc);
if (!k.empty()) if (!k.empty())
......
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