added cudev::GpuMat_<T> support to Input/Output arrays

This commit is contained in:
Vladislav Vinogradov 2013-07-19 16:37:10 +04:00
parent 1c0d2b37a7
commit 2311b0b43b
6 changed files with 62 additions and 31 deletions

View File

@ -498,6 +498,11 @@ namespace gpu
class CV_EXPORTS Event;
}
namespace cudev
{
template <typename _Tp> class GpuMat_;
}
} // cv
#endif //__OPENCV_CORE_BASE_HPP__

View File

@ -96,6 +96,7 @@ public:
_InputArray(const gpu::GpuMat& d_mat);
_InputArray(const ogl::Buffer& buf);
_InputArray(const gpu::CudaMem& cuda_mem);
template<typename _Tp> _InputArray(const cudev::GpuMat_<_Tp>& m);
virtual Mat getMat(int i=-1) const;
virtual void getMatVector(std::vector<Mat>& mv) const;
@ -144,6 +145,7 @@ public:
_OutputArray(gpu::GpuMat& d_mat);
_OutputArray(ogl::Buffer& buf);
_OutputArray(gpu::CudaMem& cuda_mem);
template<typename _Tp> _OutputArray(cudev::GpuMat_<_Tp>& m);
template<typename _Tp> _OutputArray(std::vector<_Tp>& vec);
template<typename _Tp> _OutputArray(std::vector<std::vector<_Tp> >& vec);
template<typename _Tp> _OutputArray(std::vector<Mat_<_Tp> >& vec);
@ -156,6 +158,7 @@ public:
_OutputArray(const gpu::GpuMat& d_mat);
_OutputArray(const ogl::Buffer& buf);
_OutputArray(const gpu::CudaMem& cuda_mem);
template<typename _Tp> _OutputArray(const cudev::GpuMat_<_Tp>& m);
template<typename _Tp> _OutputArray(const std::vector<_Tp>& vec);
template<typename _Tp> _OutputArray(const std::vector<std::vector<_Tp> >& vec);
template<typename _Tp> _OutputArray(const std::vector<Mat_<_Tp> >& vec);

View File

@ -335,4 +335,27 @@ __host__ GpuMat_<T>& GpuMat_<T>::assign(const Expr<Body>& expr, Stream& stream)
}}
// Input / Output Arrays
namespace cv {
template<typename _Tp>
__host__ _InputArray::_InputArray(const cudev::GpuMat_<_Tp>& m)
: flags(FIXED_TYPE + GPU_MAT + DataType<_Tp>::type), obj((void*)&m)
{}
template<typename _Tp>
__host__ _OutputArray::_OutputArray(cudev::GpuMat_<_Tp>& m)
: _InputArray(m)
{}
template<typename _Tp>
__host__ _OutputArray::_OutputArray(const cudev::GpuMat_<_Tp>& m)
: _InputArray(m)
{
flags |= FIXED_SIZE;
}
}
#endif

View File

@ -230,22 +230,22 @@ namespace
switch (srcType)
{
case CV_8UC1:
func_ = cudev::filter2D<uchar, uchar>;
func_ = cv::gpu::cudev::filter2D<uchar, uchar>;
break;
case CV_8UC4:
func_ = cudev::filter2D<uchar4, uchar4>;
func_ = cv::gpu::cudev::filter2D<uchar4, uchar4>;
break;
case CV_16UC1:
func_ = cudev::filter2D<ushort, ushort>;
func_ = cv::gpu::cudev::filter2D<ushort, ushort>;
break;
case CV_16UC4:
func_ = cudev::filter2D<ushort4, ushort4>;
func_ = cv::gpu::cudev::filter2D<ushort4, ushort4>;
break;
case CV_32FC1:
func_ = cudev::filter2D<float, float>;
func_ = cv::gpu::cudev::filter2D<float, float>;
break;
case CV_32FC4:
func_ = cudev::filter2D<float4, float4>;
func_ = cv::gpu::cudev::filter2D<float4, float4>;
break;
}
}

View File

@ -187,7 +187,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::bgr_to_bgr555(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr_to_bgr555(src, dst, StreamAccessor::getStream(stream));
}
void bgr_to_bgr565(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -200,7 +200,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::bgr_to_bgr565(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr_to_bgr565(src, dst, StreamAccessor::getStream(stream));
}
void rgb_to_bgr555(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -213,7 +213,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::rgb_to_bgr555(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::rgb_to_bgr555(src, dst, StreamAccessor::getStream(stream));
}
void rgb_to_bgr565(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -226,7 +226,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::rgb_to_bgr565(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::rgb_to_bgr565(src, dst, StreamAccessor::getStream(stream));
}
void bgra_to_bgr555(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -239,7 +239,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::bgra_to_bgr555(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgra_to_bgr555(src, dst, StreamAccessor::getStream(stream));
}
void bgra_to_bgr565(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -252,7 +252,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::bgra_to_bgr565(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgra_to_bgr565(src, dst, StreamAccessor::getStream(stream));
}
void rgba_to_bgr555(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -265,7 +265,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::rgba_to_bgr555(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::rgba_to_bgr555(src, dst, StreamAccessor::getStream(stream));
}
void rgba_to_bgr565(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -278,7 +278,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::rgba_to_bgr565(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::rgba_to_bgr565(src, dst, StreamAccessor::getStream(stream));
}
void bgr555_to_rgb(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -291,7 +291,7 @@ namespace
_dst.create(src.size(), CV_8UC3);
GpuMat dst = _dst.getGpuMat();
cudev::bgr555_to_rgb(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr555_to_rgb(src, dst, StreamAccessor::getStream(stream));
}
void bgr565_to_rgb(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -304,7 +304,7 @@ namespace
_dst.create(src.size(), CV_8UC3);
GpuMat dst = _dst.getGpuMat();
cudev::bgr565_to_rgb(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr565_to_rgb(src, dst, StreamAccessor::getStream(stream));
}
void bgr555_to_bgr(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -317,7 +317,7 @@ namespace
_dst.create(src.size(), CV_8UC3);
GpuMat dst = _dst.getGpuMat();
cudev::bgr555_to_bgr(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr555_to_bgr(src, dst, StreamAccessor::getStream(stream));
}
void bgr565_to_bgr(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -330,7 +330,7 @@ namespace
_dst.create(src.size(), CV_8UC3);
GpuMat dst = _dst.getGpuMat();
cudev::bgr565_to_bgr(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr565_to_bgr(src, dst, StreamAccessor::getStream(stream));
}
void bgr555_to_rgba(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -343,7 +343,7 @@ namespace
_dst.create(src.size(), CV_8UC4);
GpuMat dst = _dst.getGpuMat();
cudev::bgr555_to_rgba(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr555_to_rgba(src, dst, StreamAccessor::getStream(stream));
}
void bgr565_to_rgba(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -356,7 +356,7 @@ namespace
_dst.create(src.size(), CV_8UC4);
GpuMat dst = _dst.getGpuMat();
cudev::bgr565_to_rgba(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr565_to_rgba(src, dst, StreamAccessor::getStream(stream));
}
void bgr555_to_bgra(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -369,7 +369,7 @@ namespace
_dst.create(src.size(), CV_8UC4);
GpuMat dst = _dst.getGpuMat();
cudev::bgr555_to_bgra(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr555_to_bgra(src, dst, StreamAccessor::getStream(stream));
}
void bgr565_to_bgra(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -382,7 +382,7 @@ namespace
_dst.create(src.size(), CV_8UC4);
GpuMat dst = _dst.getGpuMat();
cudev::bgr565_to_bgra(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr565_to_bgra(src, dst, StreamAccessor::getStream(stream));
}
void gray_to_bgr(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -427,7 +427,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::gray_to_bgr555(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::gray_to_bgr555(src, dst, StreamAccessor::getStream(stream));
}
void gray_to_bgr565(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -440,7 +440,7 @@ namespace
_dst.create(src.size(), CV_8UC2);
GpuMat dst = _dst.getGpuMat();
cudev::gray_to_bgr565(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::gray_to_bgr565(src, dst, StreamAccessor::getStream(stream));
}
void bgr555_to_gray(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -453,7 +453,7 @@ namespace
_dst.create(src.size(), CV_8UC1);
GpuMat dst = _dst.getGpuMat();
cudev::bgr555_to_gray(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr555_to_gray(src, dst, StreamAccessor::getStream(stream));
}
void bgr565_to_gray(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -466,7 +466,7 @@ namespace
_dst.create(src.size(), CV_8UC1);
GpuMat dst = _dst.getGpuMat();
cudev::bgr565_to_gray(src, dst, StreamAccessor::getStream(stream));
cv::gpu::cudev::bgr565_to_gray(src, dst, StreamAccessor::getStream(stream));
}
void rgb_to_gray(InputArray _src, OutputArray _dst, int, Stream& stream)
@ -2145,9 +2145,9 @@ void cv::gpu::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn,
code == COLOR_BayerRG2BGR_MHT || code == COLOR_BayerGR2BGR_MHT ? 0 : 1);
if (dcn == 3)
cudev::MHCdemosaic<3>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
cv::gpu::cudev::MHCdemosaic<3>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
else
cudev::MHCdemosaic<4>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
cv::gpu::cudev::MHCdemosaic<4>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
break;
}
@ -2172,7 +2172,7 @@ void cv::gpu::demosaicing(InputArray _src, OutputArray _dst, int code, int dcn,
const int2 firstRed = make_int2(code == COLOR_BayerRG2BGR_MHT || code == COLOR_BayerGB2BGR_MHT ? 0 : 1,
code == COLOR_BayerRG2BGR_MHT || code == COLOR_BayerGR2BGR_MHT ? 0 : 1);
cudev::MHCdemosaic<1>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
cv::gpu::cudev::MHCdemosaic<1>(srcWhole, make_int2(ofs.x, ofs.y), dst, firstRed, StreamAccessor::getStream(stream));
break;
}

View File

@ -181,7 +181,7 @@ namespace
const GpuMat& prevLayer = i == 0 ? layer0_ : pyramid_[i - 1];
cudev::pyramid::downsampleX2(prevLayer, pyramid_[i], img.depth(), img.channels(), StreamAccessor::getStream(stream));
cv::gpu::cudev::pyramid::downsampleX2(prevLayer, pyramid_[i], img.depth(), img.channels(), StreamAccessor::getStream(stream));
szLastLayer = szCurLayer;
}
@ -222,7 +222,7 @@ namespace
lastLayer = curLayer;
}
cudev::pyramid::interpolateFrom1(lastLayer, outImg, outImg.depth(), outImg.channels(), StreamAccessor::getStream(stream));
cv::gpu::cudev::pyramid::interpolateFrom1(lastLayer, outImg, outImg.depth(), outImg.channels(), StreamAccessor::getStream(stream));
}
}