////////////////////////////// Image processing //////////////////////////////\r
// DST[x,y] = SRC[xmap[x,y],ymap[x,y]] with bilinear interpolation.\r
// xymap.type() == xymap.type() == CV_32FC1\r
- CV_EXPORTS void remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst);\r
+ CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap);\r
\r
// Does mean shift filtering on GPU.\r
- CV_EXPORTS void meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, int sp, int sr, \r
+ CV_EXPORTS void meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr, \r
TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1));\r
\r
// Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.\r
// The output is a 4-channel floating-point (CV_32FC4) matrix. \r
// Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.\r
// Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.\r
- CV_EXPORTS void reprojectImageTo3D_GPU(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);\r
+ CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);\r
// Acync version\r
- CV_EXPORTS void reprojectImageTo3D_GPU(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);\r
+ CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);\r
\r
- CV_EXPORTS void cvtColor_GPU(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);\r
- CV_EXPORTS void cvtColor_GPU(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);\r
+ CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);\r
+ CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);\r
\r
//////////////////////////////// StereoBM_GPU ////////////////////////////////\r
\r
class CV_EXPORTS StereoBM_GPU\r
{\r
- public:\r
+ public: \r
enum { BASIC_PRESET = 0, PREFILTER_XSOBEL = 1 };\r
\r
enum { DEFAULT_NDISP = 64, DEFAULT_WINSZ = 19 };\r
#include "safe_call.hpp"\r
\r
using namespace cv::gpu;\r
-using namespace cv::gpu::impl;\r
\r
#ifndef FLT_MAX\r
#define FLT_MAX 3.402823466e+38F\r
#include "safe_call.hpp"\r
\r
using namespace cv::gpu;\r
-using namespace cv::gpu::impl;\r
\r
#ifndef FLT_MAX\r
#define FLT_MAX 3.402823466e+30F\r
#include "saturate_cast.hpp"\r
\r
using namespace cv::gpu;\r
-using namespace cv::gpu::impl;\r
\r
#ifndef CV_DESCALE\r
#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n))\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace improc\r
{\r
template <typename T>\r
void RGB2RGB_caller(const DevMem2D_<T>& src, int srccn, const DevMem2D_<T>& dst, int dstcn, int bidx, cudaStream_t stream)\r
//};\r
}\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace improc\r
{\r
template <typename T>\r
void Gray2RGB_caller(const DevMem2D_<T>& src, const DevMem2D_<T>& dst, int dstcn, cudaStream_t stream)\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace improc\r
{\r
void RGB2Gray_gpu(const DevMem2D& src, int srccn, const DevMem2D& dst, int bidx, cudaStream_t stream)\r
{\r
#include "safe_call.hpp"\r
\r
using namespace cv::gpu;\r
-using namespace cv::gpu::impl;\r
\r
#ifndef FLT_MAX\r
#define FLT_MAX 3.402823466e+30F\r
typedef unsigned short ushort;\r
typedef unsigned int uint;\r
\r
- namespace impl\r
- {\r
- static inline int divUp(int a, int b) { return (a % b == 0) ? a/b : a/b + 1; }\r
+ static inline int divUp(int a, int b) { return (a % b == 0) ? a/b : a/b + 1; }\r
\r
+ namespace matrix_operations\r
+ { \r
extern "C" void copy_to_with_mask(const DevMem2D& src, DevMem2D dst, int depth, const DevMem2D& mask, int channels, const cudaStream_t & stream = 0);\r
\r
extern "C" void set_to_without_mask (DevMem2D dst, int depth, const double *scalar, int channels, const cudaStream_t & stream = 0);\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl \r
+namespace cv { namespace gpu { namespace improc \r
{\r
void remap_gpu_1c(const DevMem2D& src, const DevMem2Df& xmap, const DevMem2Df& ymap, DevMem2D dst)\r
{\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl \r
+namespace cv { namespace gpu { namespace improc \r
{\r
extern "C" void meanShiftFiltering_gpu(const DevMem2D& src, DevMem2D dst, int sp, int sr, int maxIter, float eps)\r
{ \r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl \r
+namespace cv { namespace gpu { namespace improc \r
{\r
void drawColorDisp_gpu(const DevMem2D& src, const DevMem2D& dst, int ndisp, const cudaStream_t& stream)\r
{\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl \r
+namespace cv { namespace gpu { namespace improc \r
{\r
template <typename T>\r
inline void reprojectImageTo3D_caller(const DevMem2D_<T>& disp, const DevMem2Df& xyzw, const float* q, const cudaStream_t& stream)\r
#include "saturate_cast.hpp"
using namespace cv::gpu;
-using namespace cv::gpu::impl;
+using namespace cv::gpu::matrix_operations;
namespace mat_operators
{
namespace gpu
{
- namespace impl
+ namespace matrix_operations
{
///////////////////////////////////////////////////////////////////////////
}\r
\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace bm\r
{\r
template<int RADIUS> void kernel_caller(const DevMem2D& left, const DevMem2D& right, const DevMem2D& disp, int maxdisp, const cudaStream_t & stream)\r
{\r
\r
}\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace bm\r
{\r
extern "C" void prefilter_xsobel(const DevMem2D& input, const DevMem2D& output, int prefilterCap)\r
{\r
}\r
}\r
\r
-namespace cv { namespace gpu { namespace impl\r
+namespace cv { namespace gpu { namespace bm\r
{\r
extern "C" void postfilter_textureness(const DevMem2D& input, int winsz, float avgTexturenessThreshold, const DevMem2D& disp)\r
{\r
\r
void cv::gpu::Stream::enqueueMemSet(const GpuMat& src, Scalar val)\r
{\r
- impl::set_to_without_mask(src, src.depth(), val.val, src.channels(), impl->stream);\r
+ matrix_operations::set_to_without_mask(src, src.depth(), val.val, src.channels(), impl->stream);\r
}\r
\r
void cv::gpu::Stream::enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask)\r
{\r
- impl::set_to_with_mask(src, src.depth(), val.val, mask, src.channels(), impl->stream);\r
+ matrix_operations::set_to_with_mask(src, src.depth(), val.val, mask, src.channels(), impl->stream);\r
}\r
\r
void cv::gpu::Stream::enqueueConvert(const GpuMat& src, GpuMat& dst, int rtype, double alpha, double beta)\r
psrc = &(temp = src);\r
\r
dst.create( src.size(), rtype );\r
- impl::convert_to(*psrc, sdepth, dst, ddepth, psrc->channels(), alpha, beta, impl->stream);\r
+ matrix_operations::convert_to(*psrc, sdepth, dst, ddepth, psrc->channels(), alpha, beta, impl->stream);\r
}\r
\r
\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::remap(const GpuMat&, const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::meanShiftFiltering_GPU(const GpuMat&, GpuMat&, int, int, TermCriteria ) { throw_nogpu(); }\r
+void cv::gpu::remap( const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap ){ throw_nogpu(); }\r
+void cv::gpu::meanShiftFiltering(const GpuMat&, GpuMat&, int, int, TermCriteria ) { throw_nogpu(); }\r
void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int) { throw_nogpu(); }\r
void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::reprojectImageTo3D_GPU(const GpuMat&, GpuMat&, const Mat&) { throw_nogpu(); }\r
-void cv::gpu::reprojectImageTo3D_GPU(const GpuMat&, GpuMat&, const Mat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::cvtColor_GPU(const GpuMat&, GpuMat&, int, int) { throw_nogpu(); }\r
-void cv::gpu::cvtColor_GPU(const GpuMat&, GpuMat&, int, int, const Stream&) { throw_nogpu(); }\r
+void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&) { throw_nogpu(); }\r
+void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&, const Stream&) { throw_nogpu(); }\r
+void cv::gpu::cvtColor(const GpuMat&, GpuMat&, int, int) { throw_nogpu(); }\r
+void cv::gpu::cvtColor(const GpuMat&, GpuMat&, int, int, const Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
namespace cv { namespace gpu \r
{ \r
- namespace impl \r
+ namespace improc \r
{\r
void remap_gpu_1c(const DevMem2D& src, const DevMem2Df& xmap, const DevMem2Df& ymap, DevMem2D dst);\r
void remap_gpu_3c(const DevMem2D& src, const DevMem2Df& xmap, const DevMem2Df& ymap, DevMem2D dst);\r
////////////////////////////////////////////////////////////////////////\r
// remap\r
\r
-void cv::gpu::remap(const GpuMat& src, const GpuMat& xmap, const GpuMat& ymap, GpuMat& dst)\r
+void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap)\r
{\r
typedef void (*remap_gpu_t)(const DevMem2D& src, const DevMem2Df& xmap, const DevMem2Df& ymap, DevMem2D dst);\r
- static const remap_gpu_t callers[] = {impl::remap_gpu_1c, 0, impl::remap_gpu_3c};\r
+ static const remap_gpu_t callers[] = {improc::remap_gpu_1c, 0, improc::remap_gpu_3c};\r
\r
CV_Assert((src.type() == CV_8U || src.type() == CV_8UC3) && xmap.type() == CV_32F && ymap.type() == CV_32F);\r
\r
////////////////////////////////////////////////////////////////////////\r
// meanShiftFiltering_GPU\r
\r
-void cv::gpu::meanShiftFiltering_GPU(const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria)\r
+void cv::gpu::meanShiftFiltering(const GpuMat& src, GpuMat& dst, int sp, int sr, TermCriteria criteria)\r
{ \r
if( src.empty() )\r
CV_Error( CV_StsBadArg, "The input image is empty" );\r
eps = 1.f;\r
eps = (float)std::max(criteria.epsilon, 0.0); \r
\r
- impl::meanShiftFiltering_gpu(src, dst, sp, sr, maxIter, eps); \r
+ improc::meanShiftFiltering_gpu(src, dst, sp, sr, maxIter, eps); \r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
out = dst;\r
out.create(src.size(), CV_8UC4);\r
\r
- impl::drawColorDisp_gpu((DevMem2D_<T>)src, out, ndisp, stream);\r
+ improc::drawColorDisp_gpu((DevMem2D_<T>)src, out, ndisp, stream);\r
\r
dst = out;\r
}\r
void reprojectImageTo3D_caller(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const cudaStream_t& stream)\r
{ \r
xyzw.create(disp.rows, disp.cols, CV_32FC4);\r
- impl::reprojectImageTo3D_gpu((DevMem2D_<T>)disp, xyzw, Q.ptr<float>(), stream);\r
+ improc::reprojectImageTo3D_gpu((DevMem2D_<T>)disp, xyzw, Q.ptr<float>(), stream);\r
}\r
\r
typedef void (*reprojectImageTo3D_caller_t)(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const cudaStream_t& stream);\r
const reprojectImageTo3D_caller_t reprojectImageTo3D_callers[] = {reprojectImageTo3D_caller<unsigned char>, 0, 0, reprojectImageTo3D_caller<short>, 0, 0, 0, 0};\r
}\r
\r
-void cv::gpu::reprojectImageTo3D_GPU(const GpuMat& disp, GpuMat& xyzw, const Mat& Q)\r
+void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q)\r
{\r
CV_Assert((disp.type() == CV_8U || disp.type() == CV_16S) && Q.type() == CV_32F && Q.rows == 4 && Q.cols == 4);\r
\r
reprojectImageTo3D_callers[disp.type()](disp, xyzw, Q, 0);\r
}\r
\r
-void cv::gpu::reprojectImageTo3D_GPU(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream)\r
+void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream)\r
{\r
CV_Assert((disp.type() == CV_8U || disp.type() == CV_16S) && Q.type() == CV_32F && Q.rows == 4 && Q.cols == 4);\r
\r
\r
out.create(sz, CV_MAKETYPE(depth, dcn));\r
if( depth == CV_8U )\r
- impl::RGB2RGB_gpu((DevMem2D)src, scn, (DevMem2D)out, dcn, bidx, stream);\r
+ improc::RGB2RGB_gpu((DevMem2D)src, scn, (DevMem2D)out, dcn, bidx, stream);\r
else if( depth == CV_16U )\r
- impl::RGB2RGB_gpu((DevMem2D_<unsigned short>)src, scn, (DevMem2D_<unsigned short>)out, dcn, bidx, stream);\r
+ improc::RGB2RGB_gpu((DevMem2D_<unsigned short>)src, scn, (DevMem2D_<unsigned short>)out, dcn, bidx, stream);\r
else\r
- impl::RGB2RGB_gpu((DevMem2Df)src, scn, (DevMem2Df)out, dcn, bidx, stream);\r
+ improc::RGB2RGB_gpu((DevMem2Df)src, scn, (DevMem2Df)out, dcn, bidx, stream);\r
break;\r
\r
//case CV_BGR2BGR565: case CV_BGR2BGR555: case CV_RGB2BGR565: case CV_RGB2BGR555:\r
bidx = code == CV_BGR2GRAY || code == CV_BGRA2GRAY ? 0 : 2;\r
\r
if( depth == CV_8U )\r
- impl::RGB2Gray_gpu((DevMem2D)src, scn, (DevMem2D)out, bidx, stream);\r
+ improc::RGB2Gray_gpu((DevMem2D)src, scn, (DevMem2D)out, bidx, stream);\r
else if( depth == CV_16U )\r
- impl::RGB2Gray_gpu((DevMem2D_<unsigned short>)src, scn, (DevMem2D_<unsigned short>)out, bidx, stream);\r
+ improc::RGB2Gray_gpu((DevMem2D_<unsigned short>)src, scn, (DevMem2D_<unsigned short>)out, bidx, stream);\r
else\r
- impl::RGB2Gray_gpu((DevMem2Df)src, scn, (DevMem2Df)out, bidx, stream);\r
+ improc::RGB2Gray_gpu((DevMem2Df)src, scn, (DevMem2Df)out, bidx, stream);\r
break;\r
\r
//case CV_BGR5652GRAY: case CV_BGR5552GRAY:\r
out.create(sz, CV_MAKETYPE(depth, dcn));\r
\r
if( depth == CV_8U )\r
- impl::Gray2RGB_gpu((DevMem2D)src, (DevMem2D)out, dcn, stream);\r
+ improc::Gray2RGB_gpu((DevMem2D)src, (DevMem2D)out, dcn, stream);\r
else if( depth == CV_16U )\r
- impl::Gray2RGB_gpu((DevMem2D_<unsigned short>)src, (DevMem2D_<unsigned short>)out, dcn, stream);\r
+ improc::Gray2RGB_gpu((DevMem2D_<unsigned short>)src, (DevMem2D_<unsigned short>)out, dcn, stream);\r
else\r
- impl::Gray2RGB_gpu((DevMem2Df)src, (DevMem2Df)out, dcn, stream);\r
+ improc::Gray2RGB_gpu((DevMem2Df)src, (DevMem2Df)out, dcn, stream);\r
break;\r
\r
//case CV_GRAY2BGR565: case CV_GRAY2BGR555:\r
}\r
}\r
\r
-void cv::gpu::cvtColor_GPU(const GpuMat& src, GpuMat& dst, int code, int dcn)\r
+void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn)\r
{\r
cvtColor_caller(src, dst, code, dcn, 0);\r
}\r
\r
-void cv::gpu::cvtColor_GPU(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream)\r
+void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream)\r
{\r
cvtColor_caller(src, dst, code, dcn, StreamAccessor::getStream(stream));\r
}\r
else\r
{\r
mat.create(size(), type());\r
- cv::gpu::impl::copy_to_with_mask(*this, mat, depth(), mask, channels());\r
+ cv::gpu::matrix_operations::copy_to_with_mask(*this, mat, depth(), mask, channels());\r
}\r
}\r
\r
psrc = &(temp = *this);\r
\r
dst.create( size(), rtype );\r
- impl::convert_to(*psrc, sdepth, dst, ddepth, psrc->channels(), alpha, beta);\r
+ matrix_operations::convert_to(*psrc, sdepth, dst, ddepth, psrc->channels(), alpha, beta);\r
}\r
\r
GpuMat& GpuMat::operator = (const Scalar& s)\r
{\r
- impl::set_to_without_mask( *this, depth(), s.val, channels());\r
+ matrix_operations::set_to_without_mask( *this, depth(), s.val, channels());\r
return *this;\r
}\r
\r
CV_DbgAssert(!this->empty());\r
\r
if (mask.empty())\r
- impl::set_to_without_mask( *this, depth(), s.val, channels());\r
+ matrix_operations::set_to_without_mask( *this, depth(), s.val, channels());\r
else\r
- impl::set_to_with_mask( *this, depth(), s.val, mask, channels());\r
+ matrix_operations::set_to_with_mask( *this, depth(), s.val, mask, channels());\r
\r
return *this;\r
}\r
\r
namespace cv { namespace gpu\r
{\r
- namespace impl\r
+ namespace bm\r
{\r
//extern "C" void stereoBM_GPU(const DevMem2D& left, const DevMem2D& right, const DevMem2D& disp, int ndisp, int winsz, const DevMem2D_<uint>& minSSD_buf);\r
extern "C" void stereoBM_GPU(const DevMem2D& left, const DevMem2D& right, const DevMem2D& disp, int ndisp, int winsz, const DevMem2D_<uint>& minSSD_buf, const cudaStream_t & stream);\r
leBuf.create( left.size(), left.type());\r
riBuf.create(right.size(), right.type());\r
\r
- impl::prefilter_xsobel( left, leBuf);\r
- impl::prefilter_xsobel(right, riBuf);\r
+ bm::prefilter_xsobel( left, leBuf);\r
+ bm::prefilter_xsobel(right, riBuf);\r
\r
le_for_bm = leBuf;\r
ri_for_bm = riBuf;\r
}\r
\r
- impl::stereoBM_GPU(le_for_bm, ri_for_bm, disparity, ndisp, winSize, minSSD, stream);\r
+ bm::stereoBM_GPU(le_for_bm, ri_for_bm, disparity, ndisp, winSize, minSSD, stream);\r
\r
if (avergeTexThreshold)\r
- impl::postfilter_textureness(le_for_bm, winSize, avergeTexThreshold, disparity);\r
+ bm::postfilter_textureness(le_for_bm, winSize, avergeTexThreshold, disparity);\r
}\r
\r
\r
cvtColor(img, rgba, CV_BGR2BGRA);\r
\r
cv::gpu::GpuMat res;\r
- cv::gpu::meanShiftFiltering_GPU( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
+ cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
if (res.type() != CV_8UC4)\r
{\r
ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
{
public:
CV_GpuStereoBMTest();
+
protected:
void run(int);
};
{
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
- cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
+ cv::Mat img_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
- if (img_l.empty() || img_r.empty() || img_template.empty())
+ if (img_l.empty() || img_r.empty() || img_reference.empty())
{
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return;
cv::gpu::GpuMat disp;
cv::gpu::StereoBM_GPU bm(0, 128, 19);
-
bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
- //cv::imwrite(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", disp);
-
- disp.convertTo(disp, img_template.type());
+ disp.convertTo(disp, img_reference.type());
+ double norm = cv::norm(disp, img_reference, cv::NORM_INF);
- double norm = cv::norm(disp, img_template, cv::NORM_INF);
if (norm >= 100)
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
ts->set_failed_test_info((norm < 100) ? CvTS::OK : CvTS::FAIL_GENERIC);