From c1ea6f3c4253b2a8b4ae897e1d129547babf236a Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 12 Mar 2014 14:54:22 +0400 Subject: [PATCH] TAPI: stitching: improve warpers --- .../include/opencv2/stitching/detail/util.hpp | 1 + .../include/opencv2/stitching/detail/warpers.hpp | 43 +---- .../opencv2/stitching/detail/warpers_inl.hpp | 2 +- .../include/opencv2/stitching/warpers.hpp | 18 -- modules/stitching/perf/opencl/perf_warpers.cpp | 24 +-- modules/stitching/src/precomp.hpp | 1 + modules/stitching/src/stitcher.cpp | 8 +- modules/stitching/src/warpers.cpp | 121 ++++++++++++- modules/stitching/src/warpers_ocl.cpp | 187 --------------------- modules/stitching/test/ocl/test_warpers.cpp | 41 ++--- samples/cpp/stitching_detailed.cpp | 28 +-- 11 files changed, 149 insertions(+), 325 deletions(-) delete mode 100644 modules/stitching/src/warpers_ocl.cpp diff --git a/modules/stitching/include/opencv2/stitching/detail/util.hpp b/modules/stitching/include/opencv2/stitching/detail/util.hpp index 561880c..6b1c5f3 100644 --- a/modules/stitching/include/opencv2/stitching/detail/util.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/util.hpp @@ -71,6 +71,7 @@ #define LOG_(_level, _msg) \ for(;;) \ { \ + using namespace std; \ if ((_level) >= ::cv::detail::stitchingLogLevel()) \ { \ LOG_STITCHING_MSG(_msg); \ diff --git a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp index 093f07c..c8869f1 100644 --- a/modules/stitching/include/opencv2/stitching/detail/warpers.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/warpers.hpp @@ -160,6 +160,8 @@ class CV_EXPORTS SphericalWarper : public RotationWarperBase public: SphericalWarper(float scale) { projector_.scale = scale; } + Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap); + Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst); protected: void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br); }; @@ -178,6 +180,8 @@ class CV_EXPORTS CylindricalWarper : public RotationWarperBase Point RotationWarperBase

::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) { - Mat xmap, ymap; + UMat xmap, ymap; Rect dst_roi = buildMaps(src.size(), K, R, xmap, ymap); dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); diff --git a/modules/stitching/include/opencv2/stitching/warpers.hpp b/modules/stitching/include/opencv2/stitching/warpers.hpp index cdcb35c..da5fe26 100644 --- a/modules/stitching/include/opencv2/stitching/warpers.hpp +++ b/modules/stitching/include/opencv2/stitching/warpers.hpp @@ -167,24 +167,6 @@ public: }; #endif -class PlaneWarperOcl: public WarperCreator -{ -public: - Ptr create(float scale) const { return makePtr(scale); } -}; - -class SphericalWarperOcl: public WarperCreator -{ -public: - Ptr create(float scale) const { return makePtr(scale); } -}; - -class CylindricalWarperOcl: public WarperCreator -{ -public: - Ptr create(float scale) const { return makePtr(scale); } -}; - } // namespace cv #endif // __OPENCV_STITCHING_WARPER_CREATORS_HPP__ diff --git a/modules/stitching/perf/opencl/perf_warpers.cpp b/modules/stitching/perf/opencl/perf_warpers.cpp index 21fe22d..6a8be4e 100644 --- a/modules/stitching/perf/opencl/perf_warpers.cpp +++ b/modules/stitching/perf/opencl/perf_warpers.cpp @@ -63,24 +63,12 @@ public: explicit WarperBase(int type, Size srcSize) { Ptr creator; - if (cv::ocl::useOpenCL()) - { - if (type == SphericalWarperType) - creator = makePtr(); - else if (type == CylindricalWarperType) - creator = makePtr(); - else if (type == PlaneWarperType) - creator = makePtr(); - } - else - { - if (type == SphericalWarperType) - creator = makePtr(); - else if (type == CylindricalWarperType) - creator = makePtr(); - else if (type == PlaneWarperType) - creator = makePtr(); - } + if (type == SphericalWarperType) + creator = makePtr(); + else if (type == CylindricalWarperType) + creator = makePtr(); + else if (type == PlaneWarperType) + creator = makePtr(); CV_Assert(!creator.empty()); K = Mat::eye(3, 3, CV_32FC1); diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index 499202f..18ce413 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include "opencv2/core.hpp" #include "opencv2/core/ocl.hpp" diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index ae46726..2d12886 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -309,9 +309,7 @@ Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArra // Preliminary result is in CV_16SC3 format, but all values are in [0,255] range, // so convert it to avoid user confusing - result.convertTo(pano_, CV_8U); - - pano.assign(pano_); + result.convertTo(pano, CV_8U); return OK; } @@ -456,7 +454,7 @@ Stitcher::Status Stitcher::estimateCameraParams() Mat R; cameras_[i].R.convertTo(R, CV_32F); cameras_[i].R = R; - LOGLN("Initial intrinsic parameters #" << indices_[i] + 1 << ":\n " << cameras_[i].K()); + //LOGLN("Initial intrinsic parameters #" << indices_[i] + 1 << ":\n " << cameras_[i].K()); } bundle_adjuster_->setConfThresh(conf_thresh_); @@ -467,7 +465,7 @@ Stitcher::Status Stitcher::estimateCameraParams() std::vector focals; for (size_t i = 0; i < cameras_.size(); ++i) { - LOGLN("Camera #" << indices_[i] + 1 << ":\n" << cameras_[i].K()); + //LOGLN("Camera #" << indices_[i] + 1 << ":\n" << cameras_[i].K()); focals.push_back(cameras_[i].focal); } diff --git a/modules/stitching/src/warpers.cpp b/modules/stitching/src/warpers.cpp index eb15d44..a05ad1f 100644 --- a/modules/stitching/src/warpers.cpp +++ b/modules/stitching/src/warpers.cpp @@ -41,6 +41,7 @@ //M*/ #include "precomp.hpp" +#include "opencl_kernels.hpp" namespace cv { namespace detail { @@ -86,7 +87,6 @@ Point2f PlaneWarper::warpPoint(const Point2f &pt, InputArray K, InputArray R, In return uv; } - Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray _xmap, OutputArray _ymap) { projector_.setCameraParams(K, R, T); @@ -94,8 +94,29 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra Point dst_tl, dst_br; detectResultRoi(src_size, dst_tl, dst_br); - _xmap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); - _ymap.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, CV_32F); + Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); + _xmap.create(dsize, CV_32FC1); + _ymap.create(dsize, CV_32FC1); + + if (ocl::useOpenCL()) // TODO !!!!! check T + { + ocl::Kernel k("buildWarpPlaneMaps", ocl::stitching::warpers_oclsrc); + if (!k.empty()) + { + + Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv), t(1, 3, CV_32FC1, projector_.t); + UMat uxmap = _xmap.getUMat(), uymap = _ymap.getUMat(), + uk_rinv = k_rinv.getUMat(ACCESS_READ), ut = t.getUMat(ACCESS_READ); + + k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), + ocl::KernelArg::PtrReadOnly(uk_rinv), ocl::KernelArg::PtrReadOnly(ut), + dst_tl.x, dst_tl.y, projector_.scale); + + size_t globalsize[2] = { dsize.width, dsize.height }; + if (k.run(2, globalsize, NULL, true)) + return Rect(dst_tl, dst_br); + } + } Mat xmap = _xmap.getMat(), ymap = _ymap.getMat(); @@ -117,11 +138,11 @@ Rect PlaneWarper::buildMaps(Size src_size, InputArray K, InputArray R, InputArra Point PlaneWarper::warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, OutputArray dst) { - Mat xmap, ymap; - Rect dst_roi = buildMaps(src.size(), K, R, T, xmap, ymap); + UMat uxmap, uymap; + Rect dst_roi = buildMaps(src.size(), K, R, T, uxmap, uymap); dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); - remap(src, dst, xmap, ymap, interp_mode, border_mode); + remap(src, dst, uxmap, uymap, interp_mode, border_mode); return dst_roi.tl(); } @@ -341,5 +362,93 @@ void SphericalPortraitWarper::detectResultRoi(Size src_size, Point &dst_tl, Poin dst_br.y = static_cast(br_vf); } +/////////////////////////////////////////// SphericalWarper //////////////////////////////////////// + +Rect SphericalWarper::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) +{ + if (ocl::useOpenCL()) + { + ocl::Kernel k("buildWarpSphericalMaps", ocl::stitching::warpers_oclsrc); + if (!k.empty()) + { + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); + xmap.create(dsize, CV_32FC1); + ymap.create(dsize, CV_32FC1); + + Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv); + UMat uxmap = xmap.getUMat(), uymap = ymap.getUMat(), uk_rinv = k_rinv.getUMat(ACCESS_READ); + + k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), + ocl::KernelArg::PtrReadOnly(uk_rinv), dst_tl.x, dst_tl.y, projector_.scale); + + size_t globalsize[2] = { dsize.width, dsize.height }; + if (k.run(2, globalsize, NULL, true)) + return Rect(dst_tl, dst_br); + } + } + + return RotationWarperBase::buildMaps(src_size, K, R, xmap, ymap); +} + +Point SphericalWarper::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) +{ + UMat uxmap, uymap; + Rect dst_roi = buildMaps(src.size(), K, R, uxmap, uymap); + + dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); + remap(src, dst, uxmap, uymap, interp_mode, border_mode); + + return dst_roi.tl(); +} + +/////////////////////////////////////////// CylindricalWarper //////////////////////////////////////// + +Rect CylindricalWarper::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) +{ + if (ocl::useOpenCL()) + { + ocl::Kernel k("buildWarpCylindricalMaps", ocl::stitching::warpers_oclsrc); + if (!k.empty()) + { + projector_.setCameraParams(K, R); + + Point dst_tl, dst_br; + detectResultRoi(src_size, dst_tl, dst_br); + + Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); + xmap.create(dsize, CV_32FC1); + ymap.create(dsize, CV_32FC1); + + Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv); + UMat uxmap = xmap.getUMat(), uymap = ymap.getUMat(), uk_rinv = k_rinv.getUMat(ACCESS_READ); + + k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), + ocl::KernelArg::PtrReadOnly(uk_rinv), dst_tl.x, dst_tl.y, projector_.scale); + + size_t globalsize[2] = { dsize.width, dsize.height }; + if (k.run(2, globalsize, NULL, true)) + return Rect(dst_tl, dst_br); + } + } + + return RotationWarperBase::buildMaps(src_size, K, R, xmap, ymap); +} + +Point CylindricalWarper::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) +{ + UMat uxmap, uymap; + Rect dst_roi = buildMaps(src.size(), K, R, uxmap, uymap); + + dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); + remap(src, dst, uxmap, uymap, interp_mode, border_mode); + + return dst_roi.tl(); +} + } // namespace detail } // namespace cv diff --git a/modules/stitching/src/warpers_ocl.cpp b/modules/stitching/src/warpers_ocl.cpp deleted file mode 100644 index ef8f316..0000000 --- a/modules/stitching/src/warpers_ocl.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "precomp.hpp" -#include "opencl_kernels.hpp" - -namespace cv { -namespace detail { - -/////////////////////////////////////////// PlaneWarperOcl //////////////////////////////////////////// - -Rect PlaneWarperOcl::buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap) -{ - projector_.setCameraParams(K, R, T); - - Point dst_tl, dst_br; - detectResultRoi(src_size, dst_tl, dst_br); - - if (ocl::useOpenCL()) - { - ocl::Kernel k("buildWarpPlaneMaps", ocl::stitching::warpers_oclsrc); - if (!k.empty()) - { - Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); - xmap.create(dsize, CV_32FC1); - ymap.create(dsize, CV_32FC1); - - Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv), t(1, 3, CV_32FC1, projector_.t); - UMat uxmap = xmap.getUMat(), uymap = ymap.getUMat(), - uk_rinv = k_rinv.getUMat(ACCESS_READ), ut = t.getUMat(ACCESS_READ); - - k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), - ocl::KernelArg::PtrReadOnly(uk_rinv), ocl::KernelArg::PtrReadOnly(ut), - dst_tl.x, dst_tl.y, projector_.scale); - - size_t globalsize[2] = { dsize.width, dsize.height }; - if (k.run(2, globalsize, NULL, true)) - return Rect(dst_tl, dst_br); - } - } - - return PlaneWarper::buildMaps(src_size, K, R, T, xmap, ymap); -} - -Point PlaneWarperOcl::warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode, OutputArray dst) -{ - UMat uxmap, uymap; - Rect dst_roi = buildMaps(src.size(), K, R, T, uxmap, uymap); - - dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); - UMat udst = dst.getUMat(); - remap(src, udst, uxmap, uymap, interp_mode, border_mode); - - return dst_roi.tl(); -} - -/////////////////////////////////////////// SphericalWarperOcl //////////////////////////////////////// - -Rect SphericalWarperOcl::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) -{ - projector_.setCameraParams(K, R); - - Point dst_tl, dst_br; - detectResultRoi(src_size, dst_tl, dst_br); - - if (ocl::useOpenCL()) - { - ocl::Kernel k("buildWarpSphericalMaps", ocl::stitching::warpers_oclsrc); - if (!k.empty()) - { - Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); - xmap.create(dsize, CV_32FC1); - ymap.create(dsize, CV_32FC1); - - Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv); - UMat uxmap = xmap.getUMat(), uymap = ymap.getUMat(), uk_rinv = k_rinv.getUMat(ACCESS_READ); - - k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), - ocl::KernelArg::PtrReadOnly(uk_rinv), dst_tl.x, dst_tl.y, projector_.scale); - - size_t globalsize[2] = { dsize.width, dsize.height }; - if (k.run(2, globalsize, NULL, true)) - return Rect(dst_tl, dst_br); - } - } - - return SphericalWarper::buildMaps(src_size, K, R, xmap, ymap); -} - -Point SphericalWarperOcl::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) -{ - UMat uxmap, uymap; - Rect dst_roi = buildMaps(src.size(), K, R, uxmap, uymap); - - dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); - UMat udst = dst.getUMat(); - remap(src, udst, uxmap, uymap, interp_mode, border_mode); - - return dst_roi.tl(); -} - -/////////////////////////////////////////// CylindricalWarperOcl //////////////////////////////////////// - -Rect CylindricalWarperOcl::buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) -{ - projector_.setCameraParams(K, R); - - Point dst_tl, dst_br; - detectResultRoi(src_size, dst_tl, dst_br); - - if (ocl::useOpenCL()) - { - ocl::Kernel k("buildWarpCylindricalMaps", ocl::stitching::warpers_oclsrc); - if (!k.empty()) - { - Size dsize(dst_br.x - dst_tl.x + 1, dst_br.y - dst_tl.y + 1); - xmap.create(dsize, CV_32FC1); - ymap.create(dsize, CV_32FC1); - - Mat k_rinv(1, 9, CV_32FC1, projector_.k_rinv); - UMat uxmap = xmap.getUMat(), uymap = ymap.getUMat(), uk_rinv = k_rinv.getUMat(ACCESS_READ); - - k.args(ocl::KernelArg::WriteOnlyNoSize(uxmap), ocl::KernelArg::WriteOnly(uymap), - ocl::KernelArg::PtrReadOnly(uk_rinv), dst_tl.x, dst_tl.y, projector_.scale); - - size_t globalsize[2] = { dsize.width, dsize.height }; - if (k.run(2, globalsize, NULL, true)) - return Rect(dst_tl, dst_br); - } - } - - return CylindricalWarper::buildMaps(src_size, K, R, xmap, ymap); -} - -Point CylindricalWarperOcl::warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) -{ - UMat uxmap, uymap; - Rect dst_roi = buildMaps(src.size(), K, R, uxmap, uymap); - - dst.create(dst_roi.height + 1, dst_roi.width + 1, src.type()); - UMat udst = dst.getUMat(); - remap(src, udst, uxmap, uymap, interp_mode, border_mode); - - return dst_roi.tl(); -} - -} // namespace detail -} // namespace cv diff --git a/modules/stitching/test/ocl/test_warpers.cpp b/modules/stitching/test/ocl/test_warpers.cpp index 94050e9..43f0e97 100644 --- a/modules/stitching/test/ocl/test_warpers.cpp +++ b/modules/stitching/test/ocl/test_warpers.cpp @@ -48,13 +48,11 @@ namespace cvtest { namespace ocl { -///////////////////////// WarperTestBase /////////////////////////// - struct WarperTestBase : public Test, public TestUtils { Mat src, dst, xmap, ymap; - Mat udst, uxmap, uymap; + UMat usrc, udst, uxmap, uymap; Mat K, R; virtual void generateTestData() @@ -62,6 +60,7 @@ struct WarperTestBase : Size size = randomSize(1, MAX_VALUE); src = randomMat(size, CV_32FC1, -500, 500); + src.copyTo(usrc); K = Mat::eye(3, 3, CV_32FC1); float angle = (float)(30.0 * CV_PI / 180.0); @@ -81,70 +80,64 @@ struct WarperTestBase : } }; -//////////////////////////////// SphericalWarperOcl ///////////////////////////////////////////////// - -typedef WarperTestBase SphericalWarperOclTest; +typedef WarperTestBase SphericalWarperTest; -OCL_TEST_F(SphericalWarperOclTest, Mat) +OCL_TEST_F(SphericalWarperTest, Mat) { for (int j = 0; j < test_loop_times; j++) { generateTestData(); - Ptr creator = makePtr(); + Ptr creator = makePtr(); Ptr warper = creator->create(2.0); OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap)); - OCL_ON(warper->buildMaps(src.size(), K, R, uxmap, uymap)); + OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap)); OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst)); - OCL_ON(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); + OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); Near(1e-4); } } -//////////////////////////////// CylindricalWarperOcl ///////////////////////////////////////////////// +typedef WarperTestBase CylindricalWarperTest; -typedef WarperTestBase CylindricalWarperOclTest; - -OCL_TEST_F(CylindricalWarperOclTest, Mat) +OCL_TEST_F(CylindricalWarperTest, Mat) { for (int j = 0; j < test_loop_times; j++) { generateTestData(); - Ptr creator = makePtr(); + Ptr creator = makePtr(); Ptr warper = creator->create(2.0); OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap)); - OCL_ON(warper->buildMaps(src.size(), K, R, uxmap, uymap)); + OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap)); OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst)); - OCL_ON(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); + OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); Near(1e-4); } } -//////////////////////////////// PlaneWarperOcl ///////////////////////////////////////////////// - -typedef WarperTestBase PlaneWarperOclTest; +typedef WarperTestBase PlaneWarperTest; -OCL_TEST_F(PlaneWarperOclTest, Mat) +OCL_TEST_F(PlaneWarperTest, Mat) { for (int j = 0; j < test_loop_times; j++) { generateTestData(); - Ptr creator = makePtr(); + Ptr creator = makePtr(); Ptr warper = creator->create(2.0); OCL_OFF(warper->buildMaps(src.size(), K, R, xmap, ymap)); - OCL_ON(warper->buildMaps(src.size(), K, R, uxmap, uymap)); + OCL_ON(warper->buildMaps(usrc.size(), K, R, uxmap, uymap)); OCL_OFF(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, dst)); - OCL_ON(warper->warp(src, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); + OCL_ON(warper->warp(usrc, K, R, INTER_LINEAR, BORDER_REPLICATE, udst)); Near(1e-4); } diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index 93389a9..df0a9ab 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -74,9 +74,6 @@ static void printUsage() " --try_cuda (yes|no)\n" " Try to use CUDA. The default value is 'no'. All default values\n" " are for CPU mode.\n" - " --try_ocl (yes|no)\n" - " Try to use OpenCL. The default value is 'no'. All default values\n" - " are for CPU mode.\n" "\nMotion Estimation Flags:\n" " --work_megapix \n" " Resolution for image registration step. The default is 0.6 Mpx.\n" @@ -127,7 +124,6 @@ static void printUsage() vector img_names; bool preview = false; bool try_cuda = false; -bool try_ocl = false; double work_megapix = 0.6; double seam_megapix = 0.1; double compose_megapix = -1; @@ -178,19 +174,6 @@ static int parseCmdArgs(int argc, char** argv) } i++; } - else if (string(argv[i]) == "--try_ocl") - { - if (string(argv[i + 1]) == "no") - try_ocl = false; - else if (string(argv[i + 1]) == "yes") - try_ocl = true; - else - { - cout << "Bad --try_ocl flag value\n"; - return -1; - } - i++; - } else if (string(argv[i]) == "--work_megapix") { work_megapix = atof(argv[i + 1]); @@ -571,17 +554,8 @@ int main(int argc, char* argv[]) // Warp images and their masks Ptr warper_creator; - if (try_ocl) - { - if (warp_type == "plane") - warper_creator = makePtr(); - else if (warp_type == "cylindrical") - warper_creator = makePtr(); - else if (warp_type == "spherical") - warper_creator = makePtr(); - } #ifdef HAVE_OPENCV_CUDAWARPING - else if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0) + if (try_cuda && cuda::getCudaEnabledDeviceCount() > 0) { if (warp_type == "plane") warper_creator = makePtr(); -- 2.7.4