base_ = glGenLists(256);\r
CV_CheckGlError();\r
\r
- glFuncTab()->generateBitmapFont(family, height, weight, style & STYLE_ITALIC, style & STYLE_UNDERLINE, 0, 256, base_);\r
+ glFuncTab()->generateBitmapFont(family, height, weight, (style & STYLE_ITALIC) != 0, (style & STYLE_UNDERLINE) != 0, 0, 256, base_);\r
#endif\r
}\r
\r
CV_EXPORTS void setDevice(int device);\r
CV_EXPORTS int getDevice();\r
\r
-//! Explicitly destroys and cleans up all resources associated with the current device in the current process. \r
+//! Explicitly destroys and cleans up all resources associated with the current device in the current process.\r
//! Any subsequent API call to this device will reinitialize the device.\r
CV_EXPORTS void resetDevice();\r
\r
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13\r
};\r
\r
-// Gives information about what GPU archs this OpenCV GPU module was \r
+// Gives information about what GPU archs this OpenCV GPU module was\r
// compiled for\r
class CV_EXPORTS TargetArchs\r
{\r
Impl *impl;\r
\r
friend struct StreamAccessor;\r
- \r
+\r
explicit Stream(Impl* impl);\r
};\r
- \r
+\r
\r
//////////////////////////////// Filter Engine ////////////////////////////////\r
\r
CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null());\r
\r
//! a synonym for normalized box filter\r
-static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null()) \r
-{ \r
- boxFilter(src, dst, -1, ksize, anchor, stream); \r
+static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null())\r
+{\r
+ boxFilter(src, dst, -1, ksize, anchor, stream);\r
}\r
\r
//! erodes the image (applies the local minimum operator)\r
CV_EXPORTS void erode(const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
-CV_EXPORTS void erode(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf, \r
- Point anchor = Point(-1, -1), int iterations = 1, \r
+CV_EXPORTS void erode(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf,\r
+ Point anchor = Point(-1, -1), int iterations = 1,\r
Stream& stream = Stream::Null());\r
\r
//! dilates the image (applies the local maximum operator)\r
CV_EXPORTS void dilate(const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
-CV_EXPORTS void dilate(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf, \r
- Point anchor = Point(-1, -1), int iterations = 1, \r
+CV_EXPORTS void dilate(const GpuMat& src, GpuMat& dst, const Mat& kernel, GpuMat& buf,\r
+ Point anchor = Point(-1, -1), int iterations = 1,\r
Stream& stream = Stream::Null());\r
\r
//! applies an advanced morphological operation to the image\r
CV_EXPORTS void morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
-CV_EXPORTS void morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, GpuMat& buf1, GpuMat& buf2, \r
+CV_EXPORTS void morphologyEx(const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, GpuMat& buf1, GpuMat& buf2,\r
Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());\r
\r
//! applies non-separable 2D linear filter to the image\r
CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,\r
Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);\r
CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, GpuMat& buf,\r
- Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, \r
+ Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1,\r
Stream& stream = Stream::Null());\r
\r
//! applies generalized Sobel operator to the image\r
////////////////////////////// Arithmetics ///////////////////////////////////\r
\r
//! implements generalized matrix product algorithm GEMM from BLAS\r
-CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha, \r
+CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha,\r
const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null());\r
\r
//! transposes the matrix\r
CV_EXPORTS void divide(double scale, const GpuMat& src2, GpuMat& dst, int dtype = -1, Stream& stream = Stream::Null());\r
\r
//! computes the weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma)\r
-CV_EXPORTS void addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst, \r
+CV_EXPORTS void addWeighted(const GpuMat& src1, double alpha, const GpuMat& src2, double beta, double gamma, GpuMat& dst,\r
int dtype = -1, Stream& stream = Stream::Null());\r
\r
//! adds scaled array to another one (dst = alpha*src1 + src2)\r
//! DST[x,y] = SRC[xmap[x,y],ymap[x,y]]\r
//! supports only CV_32FC1 map type\r
CV_EXPORTS void remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap,\r
- int interpolation, int borderMode = BORDER_CONSTANT, const Scalar& borderValue = Scalar(), \r
+ int interpolation, int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(),\r
Stream& stream = Stream::Null());\r
\r
//! Does mean shift filtering on GPU.\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
+ TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1),\r
Stream& stream = Stream::Null());\r
\r
//! Does mean shift procedure on GPU.\r
CV_EXPORTS void meanShiftProc(const GpuMat& src, GpuMat& dstr, GpuMat& dstsp, int sp, int sr,\r
- TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1), \r
+ TermCriteria criteria = TermCriteria(TermCriteria::MAX_ITER + TermCriteria::EPS, 5, 1),\r
Stream& stream = Stream::Null());\r
\r
//! Does mean shift segmentation with elimination of small regions.\r
\r
//! warps the image using affine transformation\r
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
-CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());\r
+CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR,\r
+ int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null());\r
+\r
+CV_EXPORTS void buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null());\r
\r
//! warps the image using perspective transformation\r
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
-CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());\r
+CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR,\r
+ int borderMode = BORDER_CONSTANT, Scalar borderValue = Scalar(), Stream& stream = Stream::Null());\r
+\r
+CV_EXPORTS void buildWarpPerspectiveMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream = Stream::Null());\r
\r
//! builds plane warping maps\r
CV_EXPORTS void buildWarpPlaneMaps(Size src_size, Rect dst_roi, const Mat &K, const Mat& R, const Mat &T, float scale,\r
//! rotates an image around the origin (0,0) and then shifts it\r
//! supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
//! supports 1, 3 or 4 channels images with CV_8U, CV_16U or CV_32F depth\r
-CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, \r
+CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0,\r
int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());\r
\r
//! copies 2D array to a larger destination array and pads borders with user-specifiable constant\r
-CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType, \r
+CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType,\r
const Scalar& value = Scalar(), Stream& stream = Stream::Null());\r
\r
//! computes the integral image\r
//! computes Harris cornerness criteria at each image pixel\r
CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101);\r
CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, double k, int borderType = BORDER_REFLECT101);\r
-CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, double k, \r
+CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, double k,\r
int borderType = BORDER_REFLECT101, Stream& stream = Stream::Null());\r
\r
//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria\r
CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, int borderType=BORDER_REFLECT101);\r
CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize, int borderType=BORDER_REFLECT101);\r
-CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize, \r
+CV_EXPORTS void cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuMat& Dy, GpuMat& buf, int blockSize, int ksize,\r
int borderType=BORDER_REFLECT101, Stream& stream = Stream::Null());\r
\r
//! performs per-element multiplication of two full (not packed) Fourier spectrums\r
\r
//! Performs a forward or inverse discrete Fourier transform (1D or 2D) of floating point matrix.\r
//! Param dft_size is the size of DFT transform.\r
-//! \r
+//!\r
//! If the source matrix is not continous, then additional copy will be done,\r
//! so to avoid copying ensure the source matrix is continous one. If you want to use\r
//! preallocated output ensure it is continuous too, otherwise it will be reallocated.\r
struct CV_EXPORTS ConvolveBuf\r
{\r
ConvolveBuf() {}\r
- ConvolveBuf(Size image_size, Size templ_size) \r
+ ConvolveBuf(Size image_size, Size templ_size)\r
{ create(image_size, templ_size); }\r
void create(Size image_size, Size templ_size);\r
void create(Size image_size, Size templ_size, Size block_size);\r
\r
//! performs linear blending of two images\r
//! to avoid accuracy errors sum of weigths shouldn't be very close to zero\r
-CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, \r
+CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2,\r
GpuMat& result, Stream& stream = Stream::Null());\r
\r
- \r
+\r
struct CV_EXPORTS CannyBuf;\r
\r
CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double low_thresh, double high_thresh, int apperture_size = 3, bool L2gradient = false);\r
CannyBuf(const GpuMat& dx_, const GpuMat& dy_);\r
\r
void create(const Size& image_size, int apperture_size = 3);\r
- \r
+\r
void release();\r
\r
GpuMat dx, dy;\r
GpuMat& dst, Stream& stream = Stream::Null());\r
\r
CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,\r
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, \r
+ const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,\r
Stream& stream = Stream::Null());\r
\r
CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,\r
const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false,\r
- int num_iters=100, float max_dist=8.0, int min_inlier_count=100, \r
+ int num_iters=100, float max_dist=8.0, int min_inlier_count=100,\r
std::vector<int>* inliers=NULL);\r
\r
//////////////////////////////// Image Labeling ////////////////////////////////\r
\r
-//!performs labeling via graph cuts of a 2D regular 4-connected graph. \r
-CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, \r
+//!performs labeling via graph cuts of a 2D regular 4-connected graph.\r
+CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels,\r
GpuMat& buf, Stream& stream = Stream::Null());\r
\r
-//!performs labeling via graph cuts of a 2D regular 8-connected graph. \r
-CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& topLeft, GpuMat& topRight, \r
+//!performs labeling via graph cuts of a 2D regular 8-connected graph.\r
+CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& topLeft, GpuMat& topRight,\r
GpuMat& bottom, GpuMat& bottomLeft, GpuMat& bottomRight,\r
- GpuMat& labels, \r
+ GpuMat& labels,\r
GpuMat& buf, Stream& stream = Stream::Null());\r
\r
////////////////////////////////// Histograms //////////////////////////////////\r
static vector<float> getPeopleDetector48x96();\r
static vector<float> getPeopleDetector64x128();\r
\r
- void detect(const GpuMat& img, vector<Point>& found_locations, \r
- double hit_threshold=0, Size win_stride=Size(), \r
+ void detect(const GpuMat& img, vector<Point>& found_locations,\r
+ double hit_threshold=0, Size win_stride=Size(),\r
Size padding=Size());\r
\r
void detectMultiScale(const GpuMat& img, vector<Rect>& found_locations,\r
- double hit_threshold=0, Size win_stride=Size(), \r
- Size padding=Size(), double scale0=1.05, \r
+ double hit_threshold=0, Size win_stride=Size(),\r
+ Size padding=Size(), double scale0=1.05,\r
int group_threshold=2);\r
\r
- void getDescriptors(const GpuMat& img, Size win_stride, \r
+ void getDescriptors(const GpuMat& img, Size win_stride,\r
GpuMat& descriptors,\r
int descr_format=DESCR_FORMAT_COL_BY_COL);\r
\r
// Gradients conputation results\r
GpuMat grad, qangle, grad_buf, qangle_buf;\r
\r
- // returns subbuffer with required size, reallocates buffer if nessesary.\r
- static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);\r
- static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);\r
+ // returns subbuffer with required size, reallocates buffer if nessesary.\r
+ static GpuMat getBuffer(const Size& sz, int type, GpuMat& buf);\r
+ static GpuMat getBuffer(int rows, int cols, int type, GpuMat& buf);\r
\r
- std::vector<GpuMat> image_scales;\r
+ std::vector<GpuMat> image_scales;\r
};\r
\r
\r
bool isMaskSupported() const;\r
\r
// Find one best match for each query descriptor\r
- void matchSingle(const GpuMat& query, const GpuMat& train, \r
- GpuMat& trainIdx, GpuMat& distance, \r
+ void matchSingle(const GpuMat& query, const GpuMat& train,\r
+ GpuMat& trainIdx, GpuMat& distance,\r
const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());\r
\r
// Download trainIdx and distance and convert it to CPU vector with DMatch\r
void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const std::vector<GpuMat>& masks = std::vector<GpuMat>());\r
\r
// Find one best match from train collection for each query descriptor\r
- void matchCollection(const GpuMat& query, const GpuMat& trainCollection, \r
+ void matchCollection(const GpuMat& query, const GpuMat& trainCollection,\r
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,\r
const GpuMat& masks = GpuMat(), Stream& stream = Stream::Null());\r
\r
class CV_EXPORTS SURF_GPU : public CvSURFParams\r
{\r
public:\r
- enum KeypointLayout \r
+ enum KeypointLayout\r
{\r
SF_X = 0,\r
SF_Y,\r
\r
//! download descriptors from device to host memory\r
void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);\r
- \r
+\r
//! finds the keypoints using fast hessian detector used in SURF\r
//! supports CV_8UC1 images\r
//! keypoints will have nFeature cols and 6 rows\r
//! keypoints.ptr<float>(SF_DIR)[i] will contain orientation of i'th feature\r
//! keypoints.ptr<float>(SF_HESSIAN)[i] will contain response of i'th feature\r
void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints);\r
- //! finds the keypoints and computes their descriptors. \r
+ //! finds the keypoints and computes their descriptors.\r
//! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction\r
- void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors, \r
+ void operator()(const GpuMat& img, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors,\r
bool useProvidedKeypoints = false);\r
\r
void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints);\r
- void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors, \r
+ void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,\r
bool useProvidedKeypoints = false);\r
\r
- void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors, \r
+ void operator()(const GpuMat& img, const GpuMat& mask, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,\r
bool useProvidedKeypoints = false);\r
\r
void releaseMemory();\r
\r
//! finds the keypoints using FAST detector\r
//! supports only CV_8UC1 images\r
- void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints); \r
+ void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints);\r
void operator ()(const GpuMat& image, const GpuMat& mask, std::vector<KeyPoint>& keypoints);\r
\r
//! download keypoints from device to host memory\r
GpuMat pattern_;\r
\r
std::vector<GpuMat> imagePyr_;\r
- std::vector<GpuMat> maskPyr_;\r
+ std::vector<GpuMat> maskPyr_;\r
\r
GpuMat buf_;\r
\r
{\r
public:\r
BroxOpticalFlow(float alpha_, float gamma_, float scale_factor_, int inner_iterations_, int outer_iterations_, int solver_iterations_) :\r
- alpha(alpha_), gamma(gamma_), scale_factor(scale_factor_), \r
+ alpha(alpha_), gamma(gamma_), scale_factor(scale_factor_),\r
inner_iterations(inner_iterations_), outer_iterations(outer_iterations_), solver_iterations(solver_iterations_)\r
{\r
}\r
GpuMat dy_calcBuf_;\r
\r
vector<GpuMat> prevPyr_;\r
- vector<GpuMat> nextPyr_; \r
+ vector<GpuMat> nextPyr_;\r
\r
GpuMat dx_buf_;\r
GpuMat dy_buf_;\r
//! occlusion masks 0, occlusion masks 1,\r
//! interpolated forward flow 0, interpolated forward flow 1,\r
//! interpolated backward flow 0, interpolated backward flow 1\r
-//! \r
-CV_EXPORTS void interpolateFrames(const GpuMat& frame0, const GpuMat& frame1, \r
+//!\r
+CV_EXPORTS void interpolateFrames(const GpuMat& frame0, const GpuMat& frame1,\r
const GpuMat& fu, const GpuMat& fv,\r
- const GpuMat& bu, const GpuMat& bv, \r
+ const GpuMat& bu, const GpuMat& bv,\r
float pos, GpuMat& newFrame, GpuMat& buf,\r
Stream& stream = Stream::Null());\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
- testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1), \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),\r
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC),\r
testing::Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_CONSTANT)));\r
\r
\r
cv::Mat img = readImage("gpu/meanshift/cones.png");\r
ASSERT_FALSE(img.empty());\r
- \r
+\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
\r
cv::Mat img = readImage("gpu/meanshift/cones.png");\r
ASSERT_FALSE(img.empty());\r
- \r
+\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
\r
cv::Mat img = readImage("gpu/meanshift/cones.png");\r
ASSERT_FALSE(img.empty());\r
- \r
+\r
cv::Mat rgba;\r
cv::cvtColor(img, rgba, cv::COLOR_BGR2BGRA);\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, DrawColorDisp, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_16SC1)));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_16SC1)));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1),\r
testing::Values(\r
- CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA), \r
- CvtColorInfo(4, 4, cv::COLOR_BGR2XYZ), CvtColorInfo(4, 4, cv::COLOR_BGR2YCrCb), CvtColorInfo(4, 4, cv::COLOR_YCrCb2BGR), \r
+ CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA), CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY), CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),\r
+ CvtColorInfo(4, 4, cv::COLOR_BGR2XYZ), CvtColorInfo(4, 4, cv::COLOR_BGR2YCrCb), CvtColorInfo(4, 4, cv::COLOR_YCrCb2BGR),\r
CvtColorInfo(4, 4, cv::COLOR_BGR2HSV), CvtColorInfo(4, 4, cv::COLOR_HSV2BGR))));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_16UC1, CV_32FC1)));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(\r
- ALL_DEVICES, \r
- testing::Values(perf::szSXGA, perf::sz1080p), \r
+ ALL_DEVICES,\r
+ testing::Values(perf::szSXGA, perf::sz1080p),\r
testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_32FC1),\r
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC),\r
testing::Values(0.5, 2.0)));\r
cv::gpu::GpuMat src(src_host);\r
cv::gpu::GpuMat dst;\r
\r
- double reflect[2][3] = { {-1, 0, 0},\r
- { 0, -1, 0}};\r
- reflect[0][2] = size.width;\r
- reflect[1][2] = size.height;\r
- cv::Mat M(2, 3, CV_64F, (void*) reflect); \r
+ const double aplha = CV_PI / 4;\r
+ double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},\r
+ {std::sin(aplha), std::cos(aplha), 0}};\r
+ cv::Mat M(2, 3, CV_64F, (void*) mat);\r
\r
TEST_CYCLE()\r
{\r
- cv::gpu::warpAffine(src, dst, M, size, interpolation);\r
+ cv::gpu::warpAffine(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar());\r
}\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
- testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),\r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));\r
\r
//////////////////////////////////////////////////////////////////////\r
cv::gpu::GpuMat src(src_host);\r
cv::gpu::GpuMat dst;\r
\r
- double reflect[3][3] = { {-1, 0, 0},\r
- { 0, -1, 0},\r
- { 0, 0, 1}};\r
- reflect[0][2] = size.width;\r
- reflect[1][2] = size.height;\r
- cv::Mat M(3, 3, CV_64F, (void*)reflect); \r
+ const double aplha = CV_PI / 4;\r
+ double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},\r
+ {std::sin(aplha), std::cos(aplha), 0},\r
+ {0.0, 0.0, 1.0}};\r
+ cv::Mat M(3, 3, CV_64F, (void*) mat);\r
\r
TEST_CYCLE()\r
{\r
- cv::gpu::warpPerspective(src, dst, M, size, interpolation);\r
+ cv::gpu::warpPerspective(src, dst, M, size, interpolation, cv::BORDER_CONSTANT, cv::Scalar());\r
}\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
- testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),\r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
+ testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));\r
\r
//////////////////////////////////////////////////////////////////////\r
\r
TEST_CYCLE()\r
{\r
- cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1), \r
+ cv::gpu::buildWarpPlaneMaps(size, cv::Rect(0, 0, size.width, size.height), cv::Mat::eye(3, 3, CV_32FC1),\r
cv::Mat::ones(3, 3, CV_32FC1), cv::Mat::zeros(1, 3, CV_32F), 1.0, map_x, map_y);\r
}\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpPlaneMaps, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpCylindricalMaps, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, BuildWarpSphericalMaps, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Rotate, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
testing::Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC)));\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine(\r
- ALL_DEVICES, \r
- GPU_TYPICAL_MAT_SIZES, \r
+ ALL_DEVICES,\r
+ GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC4, CV_32FC1),\r
testing::Values((int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT, (int) cv::BORDER_WRAP, (int) cv::BORDER_CONSTANT)));\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, IntegralSqr, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
int type = GET_PARAM(1);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
- \r
+\r
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);\r
ASSERT_FALSE(img.empty());\r
\r
cv::gpu::GpuMat Dy;\r
\r
int blockSize = 3;\r
- int ksize = 7; \r
+ int ksize = 7;\r
double k = 0.5;\r
\r
TEST_CYCLE()\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
testing::Values(CV_8UC1, CV_32FC1)));\r
\r
//////////////////////////////////////////////////////////////////////\r
int type = GET_PARAM(1);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
- \r
+\r
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);\r
ASSERT_FALSE(img.empty());\r
\r
cv::gpu::GpuMat Dy;\r
\r
int blockSize = 3;\r
- int ksize = 7; \r
+ int ksize = 7;\r
\r
TEST_CYCLE()\r
{\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
testing::Values(CV_8UC1, CV_32FC1)));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(3, 9, 27, 32, 64),\r
testing::Bool()));\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)));\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC4, CV_16SC3, CV_32FC1)));\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, BlendLinear, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_32FC1)));\r
\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, AlphaComp, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4),\r
testing::Values((int)cv::gpu::ALPHA_OVER, (int)cv::gpu::ALPHA_IN, (int)cv::gpu::ALPHA_OUT, (int)cv::gpu::ALPHA_ATOP, (int)cv::gpu::ALPHA_XOR, (int)cv::gpu::ALPHA_PLUS, (int)cv::gpu::ALPHA_OVER_PREMUL, (int)cv::gpu::ALPHA_IN_PREMUL, (int)cv::gpu::ALPHA_OUT_PREMUL, (int)cv::gpu::ALPHA_ATOP_PREMUL, (int)cv::gpu::ALPHA_XOR_PREMUL, (int)cv::gpu::ALPHA_PLUS_PREMUL, (int)cv::gpu::ALPHA_PREMUL)));\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES));\r
\r
//////////////////////////////////////////////////////////////////////\r
cv::gpu::GpuMat src(src_host);\r
\r
cv::gpu::ImagePyramid pyr;\r
- \r
+\r
TEST_CYCLE()\r
{\r
pyr.build(src, 5);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_build, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));\r
\r
cv::gpu::GpuMat dst;\r
\r
cv::gpu::ImagePyramid pyr(src, 3);\r
- \r
+\r
TEST_CYCLE()\r
{\r
pyr.getLayer(dst, cv::Size(size.width / 2 + 10, size.height / 2 + 10));\r
}\r
\r
INSTANTIATE_TEST_CASE_P(ImgProc, ImagePyramid_getLayer, testing::Combine(\r
- ALL_DEVICES, \r
+ ALL_DEVICES,\r
GPU_TYPICAL_MAT_SIZES,\r
testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4)));\r
\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
-namespace cv { namespace gpu { namespace device \r
+namespace cv { namespace gpu { namespace device\r
{\r
#define OPENCV_GPU_DECLARE_CVTCOLOR_ONE(name) \\r
void name(const DevMem2Db& src, const DevMem2Db& dst, cudaStream_t stream);\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgr_to_rgb_8u, 0, bgr_to_rgb_16u, 0, 0, bgr_to_rgb_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 3)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 3));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgr_to_bgra_8u, 0, bgr_to_bgra_16u, 0, 0, bgr_to_bgra_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 4)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 4));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgr_to_rgba_8u, 0, bgr_to_rgba_16u, 0, 0, bgr_to_rgba_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 4)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 4));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgra_to_bgr_8u, 0, bgra_to_bgr_16u, 0, 0, bgra_to_bgr_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 3)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 3));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgra_to_rgb_8u, 0, bgra_to_rgb_16u, 0, 0, bgra_to_rgb_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 3)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 3));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgra_to_rgba_8u, 0, bgra_to_rgba_16u, 0, 0, bgra_to_rgba_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 4)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 4));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr_to_bgr555(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::bgr_to_bgr555(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr_to_bgr565(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::bgr_to_bgr565(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void rgb_to_bgr555(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::rgb_to_bgr555(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void rgb_to_bgr565(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::rgb_to_bgr565(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgra_to_bgr555(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::bgra_to_bgr555(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgra_to_bgr565(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::bgra_to_bgr565(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void rgba_to_bgr555(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::rgba_to_bgr555(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void rgba_to_bgr565(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::rgba_to_bgr565(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr555_to_rgb(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC3); \r
+ dst.create(src.size(), CV_8UC3);\r
\r
device::bgr555_to_rgb(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr565_to_rgb(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC3); \r
+ dst.create(src.size(), CV_8UC3);\r
\r
device::bgr565_to_rgb(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr555_to_bgr(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC3); \r
+ dst.create(src.size(), CV_8UC3);\r
\r
device::bgr555_to_bgr(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr565_to_bgr(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC3); \r
+ dst.create(src.size(), CV_8UC3);\r
\r
device::bgr565_to_bgr(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr555_to_rgba(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC4); \r
+ dst.create(src.size(), CV_8UC4);\r
\r
device::bgr555_to_rgba(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr565_to_rgba(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC4); \r
+ dst.create(src.size(), CV_8UC4);\r
\r
device::bgr565_to_rgba(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr555_to_bgra(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC4); \r
+ dst.create(src.size(), CV_8UC4);\r
\r
device::bgr555_to_bgra(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr565_to_bgra(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC4); \r
+ dst.create(src.size(), CV_8UC4);\r
\r
device::bgr565_to_bgra(src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {gray_to_bgr_8u, 0, gray_to_bgr_16u, 0, 0, gray_to_bgr_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 1);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 3)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 3));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {gray_to_bgra_8u, 0, gray_to_bgra_16u, 0, 0, gray_to_bgra_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 1);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 4)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 4));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void gray_to_bgr555(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 1);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::gray_to_bgr555(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void gray_to_bgr565(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 1);\r
\r
- dst.create(src.size(), CV_8UC2); \r
+ dst.create(src.size(), CV_8UC2);\r
\r
device::gray_to_bgr565(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr555_to_gray(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC1); \r
+ dst.create(src.size(), CV_8UC1);\r
\r
device::bgr555_to_gray(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
void bgr565_to_gray(const GpuMat& src, GpuMat& dst, int, Stream& stream)\r
- { \r
+ {\r
CV_Assert(src.depth() == CV_8U);\r
CV_Assert(src.channels() == 2);\r
\r
- dst.create(src.size(), CV_8UC1); \r
+ dst.create(src.size(), CV_8UC1);\r
\r
device::bgr565_to_gray(src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {rgb_to_gray_8u, 0, rgb_to_gray_16u, 0, 0, rgb_to_gray_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 1)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 1));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgr_to_gray_8u, 0, bgr_to_gray_16u, 0, 0, bgr_to_gray_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 1)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 1));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {rgba_to_gray_8u, 0, rgba_to_gray_16u, 0, 0, rgba_to_gray_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 1)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 1));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
{\r
using namespace cv::gpu::device;\r
static const gpu_func_t funcs[] = {bgra_to_gray_8u, 0, bgra_to_gray_16u, 0, 0, bgra_to_gray_32f};\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), 1)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), 1));\r
\r
funcs[src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
- \r
+\r
void rgb_to_yuv(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_yuv_8u, 0, rgb_to_yuv_16u, 0, 0, rgb_to_yuv_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_yuv(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_yuv_8u, 0, bgr_to_yuv_16u, 0, 0, bgr_to_yuv_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void yuv_to_rgb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{yuv_to_rgb_8u, 0, yuv_to_rgb_16u, 0, 0, yuv_to_rgb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void yuv_to_bgr(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{yuv_to_bgr_8u, 0, yuv_to_bgr_16u, 0, 0, yuv_to_bgr_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
- \r
+\r
void rgb_to_YCrCb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_YCrCb_8u, 0, rgb_to_YCrCb_16u, 0, 0, rgb_to_YCrCb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_YCrCb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_YCrCb_8u, 0, bgr_to_YCrCb_16u, 0, 0, bgr_to_YCrCb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void YCrCb_to_rgb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{YCrCb_to_rgb_8u, 0, YCrCb_to_rgb_16u, 0, 0, YCrCb_to_rgb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void YCrCb_to_bgr(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{YCrCb_to_bgr_8u, 0, YCrCb_to_bgr_16u, 0, 0, YCrCb_to_bgr_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void rgb_to_xyz(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_xyz_8u, 0, rgb_to_xyz_16u, 0, 0, rgb_to_xyz_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_xyz(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_xyz_8u, 0, bgr_to_xyz_16u, 0, 0, bgr_to_xyz_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void xyz_to_rgb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{xyz_to_rgb_8u, 0, xyz_to_rgb_16u, 0, 0, xyz_to_rgb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void xyz_to_bgr(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{xyz_to_bgr_8u, 0, xyz_to_bgr_16u, 0, 0, xyz_to_bgr_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void rgb_to_hsv(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_hsv_8u, 0, 0, 0, 0, rgb_to_hsv_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_hsv(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_hsv_8u, 0, 0, 0, 0, bgr_to_hsv_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hsv_to_rgb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hsv_to_rgb_8u, 0, 0, 0, 0, hsv_to_rgb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hsv_to_bgr(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hsv_to_bgr_8u, 0, 0, 0, 0, hsv_to_bgr_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
- } \r
+ }\r
\r
void rgb_to_hls(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_hls_8u, 0, 0, 0, 0, rgb_to_hls_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_hls(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_hls_8u, 0, 0, 0, 0, bgr_to_hls_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hls_to_rgb(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hls_to_rgb_8u, 0, 0, 0, 0, hls_to_rgb_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hls_to_bgr(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hls_to_bgr_8u, 0, 0, 0, 0, hls_to_bgr_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
- } \r
+ }\r
\r
void rgb_to_hsv_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_hsv_full_8u, 0, 0, 0, 0, rgb_to_hsv_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_hsv_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_hsv_full_8u, 0, 0, 0, 0, bgr_to_hsv_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hsv_to_rgb_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hsv_to_rgb_full_8u, 0, 0, 0, 0, hsv_to_rgb_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hsv_to_bgr_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hsv_to_bgr_full_8u, 0, 0, 0, 0, hsv_to_bgr_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
- } \r
+ }\r
\r
void rgb_to_hls_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{rgb_to_hls_full_8u, 0, 0, 0, 0, rgb_to_hls_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void bgr_to_hls_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{bgr_to_hls_full_8u, 0, 0, 0, 0, bgr_to_hls_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hls_to_rgb_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hls_to_rgb_full_8u, 0, 0, 0, 0, hls_to_rgb_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void hls_to_bgr_full(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream)\r
{\r
using namespace cv::gpu::device;\r
- static const gpu_func_t funcs[2][2][6] = \r
+ static const gpu_func_t funcs[2][2][6] =\r
{\r
{\r
{hls_to_bgr_full_8u, 0, 0, 0, 0, hls_to_bgr_full_32f},\r
};\r
\r
if (dcn <= 0) dcn = 3;\r
- \r
+\r
CV_Assert(src.depth() == CV_8U || src.depth() == CV_32F);\r
CV_Assert(src.channels() == 3 || src.channels() == 4);\r
CV_Assert(dcn == 3 || dcn == 4);\r
\r
- dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn)); \r
+ dst.create(src.size(), CV_MAKETYPE(src.depth(), dcn));\r
\r
funcs[dcn == 4][src.channels() == 4][src.depth()](src, dst, StreamAccessor::getStream(stream));\r
}\r
void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, Stream& stream)\r
{\r
typedef void (*func_t)(const GpuMat& src, GpuMat& dst, int dcn, Stream& stream);\r
- static const func_t funcs[] = \r
+ static const func_t funcs[] =\r
{\r
bgr_to_bgra, // CV_BGR2BGRA =0\r
bgra_to_bgr, // CV_BGRA2BGR =1\r
0, // =42\r
0, // =43\r
\r
- 0, // CV_BGR2Lab =44 \r
+ 0, // CV_BGR2Lab =44\r
0, // CV_RGB2Lab =45\r
\r
0, // CV_BayerBG2BGR =46\r
0, // CV_Lab2RGB =57\r
0, // CV_Luv2BGR =58\r
0, // CV_Luv2RGB =59\r
- \r
+\r
hls_to_bgr, // CV_HLS2BGR =60\r
hls_to_rgb, // CV_HLS2RGB =61\r
\r
sz.width = image.cols;\r
sz.height = image.rows;\r
\r
- nppSafeCall( nppiSwapChannels_8u_C4IR(image.ptr<Npp8u>(), static_cast<int>(image.step), sz, dstOrder) ); \r
+ nppSafeCall( nppiSwapChannels_8u_C4IR(image.ptr<Npp8u>(), static_cast<int>(image.step), sz, dstOrder) );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
#endif /* !defined (HAVE_CUDA) */\r
#include "opencv2/gpu/device/saturate_cast.hpp"\r
#include "opencv2/gpu/device/filters.hpp"\r
\r
-namespace cv { namespace gpu { namespace device \r
+namespace cv { namespace gpu { namespace device\r
{\r
- namespace imgproc \r
- { \r
+ namespace imgproc\r
+ {\r
template <typename Ptr2D, typename T> __global__ void remap(const Ptr2D src, const PtrStepf mapx, const PtrStepf mapy, DevMem2D_<T> dst)\r
{\r
const int x = blockDim.x * blockIdx.x + threadIdx.x;\r
\r
template <template <typename> class Filter, template <typename> class B, typename T> struct RemapDispatcherStream\r
{\r
- static void call(DevMem2D_<T> src, DevMem2Df mapx, DevMem2Df mapy, DevMem2D_<T> dst, \r
- const float* borderValue, cudaStream_t stream, int)\r
+ static void call(DevMem2D_<T> src, DevMem2Df mapx, DevMem2Df mapy, DevMem2D_<T> dst, const float* borderValue, cudaStream_t stream, int)\r
{\r
typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_type; \r
- \r
+\r
dim3 block(32, 8);\r
dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
\r
\r
template <template <typename> class Filter, template <typename> class B, typename T> struct RemapDispatcherNonStream\r
{\r
- static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2Df mapx, DevMem2Df mapy, \r
- DevMem2D_<T> dst, const float* borderValue, int)\r
+ static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2Df mapx, DevMem2Df mapy, DevMem2D_<T> dst, const float* borderValue, int)\r
{\r
- typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_type; \r
- \r
+ typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_type;\r
+\r
dim3 block(32, 8);\r
dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
\r
#undef OPENCV_GPU_IMPLEMENT_REMAP_TEX\r
\r
template <template <typename> class Filter, template <typename> class B, typename T> struct RemapDispatcher\r
- { \r
+ {\r
static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2Df mapx, DevMem2Df mapy, \r
DevMem2D_<T> dst, const float* borderValue, cudaStream_t stream, int cc)\r
{\r
\r
static const caller_t callers[3][5] = \r
{\r
- { \r
- RemapDispatcher<PointFilter, BrdReflect101, T>::call, \r
- RemapDispatcher<PointFilter, BrdReplicate, T>::call, \r
- RemapDispatcher<PointFilter, BrdConstant, T>::call, \r
- RemapDispatcher<PointFilter, BrdReflect, T>::call, \r
- RemapDispatcher<PointFilter, BrdWrap, T>::call \r
+ {\r
+ RemapDispatcher<PointFilter, BrdReflect101, T>::call,\r
+ RemapDispatcher<PointFilter, BrdReplicate, T>::call,\r
+ RemapDispatcher<PointFilter, BrdConstant, T>::call,\r
+ RemapDispatcher<PointFilter, BrdReflect, T>::call,\r
+ RemapDispatcher<PointFilter, BrdWrap, T>::call\r
},\r
- { \r
- RemapDispatcher<LinearFilter, BrdReflect101, T>::call, \r
- RemapDispatcher<LinearFilter, BrdReplicate, T>::call, \r
- RemapDispatcher<LinearFilter, BrdConstant, T>::call, \r
- RemapDispatcher<LinearFilter, BrdReflect, T>::call, \r
- RemapDispatcher<LinearFilter, BrdWrap, T>::call \r
+ {\r
+ RemapDispatcher<LinearFilter, BrdReflect101, T>::call,\r
+ RemapDispatcher<LinearFilter, BrdReplicate, T>::call,\r
+ RemapDispatcher<LinearFilter, BrdConstant, T>::call,\r
+ RemapDispatcher<LinearFilter, BrdReflect, T>::call,\r
+ RemapDispatcher<LinearFilter, BrdWrap, T>::call\r
},\r
- { \r
- RemapDispatcher<CubicFilter, BrdReflect101, T>::call, \r
- RemapDispatcher<CubicFilter, BrdReplicate, T>::call, \r
- RemapDispatcher<CubicFilter, BrdConstant, T>::call, \r
- RemapDispatcher<CubicFilter, BrdReflect, T>::call, \r
- RemapDispatcher<CubicFilter, BrdWrap, T>::call \r
+ {\r
+ RemapDispatcher<CubicFilter, BrdReflect101, T>::call,\r
+ RemapDispatcher<CubicFilter, BrdReplicate, T>::call,\r
+ RemapDispatcher<CubicFilter, BrdConstant, T>::call,\r
+ RemapDispatcher<CubicFilter, BrdReflect, T>::call,\r
+ RemapDispatcher<CubicFilter, BrdWrap, T>::call\r
}\r
};\r
\r
#include "opencv2/gpu/device/saturate_cast.hpp"\r
#include "opencv2/gpu/device/filters.hpp"\r
\r
-namespace cv { namespace gpu { namespace device \r
+namespace cv { namespace gpu { namespace device\r
{\r
- namespace imgproc \r
- { \r
+ namespace imgproc\r
+ {\r
template <typename Ptr2D, typename T> __global__ void resize(const Ptr2D src, float fx, float fy, DevMem2D_<T> dst)\r
{\r
const int x = blockDim.x * blockIdx.x + threadIdx.x;\r
\r
if (x < dst.cols && y < dst.rows)\r
{\r
- const float xcoo = x / fx;\r
- const float ycoo = y / fy;\r
+ const float xcoo = x * fx;\r
+ const float ycoo = y * fy;\r
\r
- dst.ptr(y)[x] = saturate_cast<T>(src(ycoo, xcoo));\r
- }\r
- }\r
- template <typename Ptr2D, typename T> __global__ void resizeNN(const Ptr2D src, float fx, float fy, DevMem2D_<T> dst)\r
- {\r
- const int x = blockDim.x * blockIdx.x + threadIdx.x;\r
- const int y = blockDim.y * blockIdx.y + threadIdx.y;\r
-\r
- if (x < dst.cols && y < dst.rows)\r
- {\r
- const float xcoo = x / fx;\r
- const float ycoo = y / fy;\r
-\r
- dst.ptr(y)[x] = src(__float2int_rd(ycoo), __float2int_rd(xcoo));\r
+ dst(y, x) = saturate_cast<T>(src(ycoo, xcoo));\r
}\r
}\r
\r
template <template <typename> class Filter, typename T> struct ResizeDispatcherStream\r
{\r
static void call(DevMem2D_<T> src, float fx, float fy, DevMem2D_<T> dst, cudaStream_t stream)\r
- { \r
- dim3 block(32, 8);\r
- dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
-\r
- BrdReplicate<T> brd(src.rows, src.cols);\r
- BorderReader< PtrStep<T>, BrdReplicate<T> > brdSrc(src, brd);\r
- Filter< BorderReader< PtrStep<T>, BrdReplicate<T> > > filter_src(brdSrc);\r
-\r
- resize<<<grid, block, 0, stream>>>(filter_src, fx, fy, dst);\r
- cudaSafeCall( cudaGetLastError() );\r
- }\r
- };\r
- template <typename T> struct ResizeDispatcherStream<PointFilter, T>\r
- {\r
- static void call(DevMem2D_<T> src, float fx, float fy, DevMem2D_<T> dst, cudaStream_t stream)\r
- { \r
+ {\r
dim3 block(32, 8);\r
dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
\r
BrdReplicate<T> brd(src.rows, src.cols);\r
BorderReader< PtrStep<T>, BrdReplicate<T> > brdSrc(src, brd);\r
+ Filter< BorderReader< PtrStep<T>, BrdReplicate<T> > > filteredSrc(brdSrc);\r
\r
- resizeNN<<<grid, block, 0, stream>>>(brdSrc, fx, fy, dst);\r
+ resize<<<grid, block, 0, stream>>>(filteredSrc, fx, fy, dst);\r
cudaSafeCall( cudaGetLastError() );\r
}\r
};\r
template <template <typename> class Filter, typename T> struct ResizeDispatcherNonStream\r
{\r
static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, float fx, float fy, DevMem2D_<T> dst)\r
- { \r
- dim3 block(32, 8);\r
- dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
-\r
- BrdReplicate<T> brd(src.rows, src.cols);\r
- BorderReader< PtrStep<T>, BrdReplicate<T> > brdSrc(src, brd);\r
- Filter< BorderReader< PtrStep<T>, BrdReplicate<T> > > filter_src(brdSrc);\r
-\r
- resize<<<grid, block>>>(filter_src, fx, fy, dst);\r
- cudaSafeCall( cudaGetLastError() );\r
-\r
- cudaSafeCall( cudaDeviceSynchronize() );\r
- }\r
- };\r
- template <typename T> struct ResizeDispatcherNonStream<PointFilter, T>\r
- {\r
- static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, float fx, float fy, DevMem2D_<T> dst)\r
- { \r
+ {\r
dim3 block(32, 8);\r
dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
\r
BrdReplicate<T> brd(src.rows, src.cols);\r
BorderReader< PtrStep<T>, BrdReplicate<T> > brdSrc(src, brd);\r
+ Filter< BorderReader< PtrStep<T>, BrdReplicate<T> > > filteredSrc(brdSrc);\r
\r
- resizeNN<<<grid, block>>>(brdSrc, fx, fy, dst);\r
+ resize<<<grid, block>>>(filteredSrc, fx, fy, dst);\r
cudaSafeCall( cudaGetLastError() );\r
\r
cudaSafeCall( cudaDeviceSynchronize() );\r
{ \\r
typedef type elem_type; \\r
typedef int index_type; \\r
- int xoff, yoff; \\r
- tex_resize_ ## type ## _reader (int xoff_, int yoff_) : xoff(xoff_), yoff(yoff_) {} \\r
+ const int xoff; \\r
+ const int yoff; \\r
+ __host__ tex_resize_ ## type ## _reader(int xoff_, int yoff_) : xoff(xoff_), yoff(yoff_) {} \\r
__device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const \\r
{ \\r
- return tex2D(tex_resize_ ## type , x + xoff, y + yoff); \\r
+ return tex2D(tex_resize_ ## type, x + xoff, y + yoff); \\r
} \\r
}; \\r
- template <template <typename> class Filter> struct ResizeDispatcherNonStream<Filter, type> \\r
+ template <template <typename> class Filter> struct ResizeDispatcherNonStream<Filter, type > \\r
{ \\r
static void call(DevMem2D_< type > src, DevMem2D_< type > srcWhole, int xoff, int yoff, float fx, float fy, DevMem2D_< type > dst) \\r
{ \\r
dim3 block(32, 8); \\r
dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \\r
- bindTexture(&tex_resize_ ## type , srcWhole); \\r
- tex_resize_ ## type ##_reader texSrc(xoff, yoff); \\r
- BrdReplicate< type > brd(src.rows, src.cols); \\r
- BorderReader< tex_resize_ ## type ##_reader , BrdReplicate< type > > brdSrc(texSrc, brd); \\r
- Filter< BorderReader< tex_resize_ ## type ##_reader , BrdReplicate< type > > > filter_src(brdSrc); \\r
- resize<<<grid, block>>>(filter_src, fx, fy, dst); \\r
- cudaSafeCall( cudaGetLastError() ); \\r
- cudaSafeCall( cudaDeviceSynchronize() ); \\r
- } \\r
- }; \\r
- template <> struct ResizeDispatcherNonStream<PointFilter, type> \\r
- { \\r
- static void call(DevMem2D_< type > src, DevMem2D_< type > srcWhole, int xoff, int yoff, float fx, float fy, DevMem2D_< type > dst) \\r
- { \\r
- dim3 block(32, 8); \\r
- dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \\r
- bindTexture(&tex_resize_ ## type , srcWhole); \\r
- tex_resize_ ## type ##_reader texSrc(xoff, yoff); \\r
- BrdReplicate< type > brd(src.rows, src.cols); \\r
- BorderReader< tex_resize_ ## type ##_reader , BrdReplicate< type > > brdSrc(texSrc, brd); \\r
- resizeNN<<<grid, block>>>(brdSrc, fx, fy, dst); \\r
+ bindTexture(&tex_resize_ ## type, srcWhole); \\r
+ tex_resize_ ## type ## _reader texSrc(xoff, yoff); \\r
+ if (srcWhole.cols == src.cols && srcWhole.rows == src.rows) \\r
+ { \\r
+ Filter<tex_resize_ ## type ## _reader> filteredSrc(texSrc); \\r
+ resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \\r
+ } \\r
+ else \\r
+ { \\r
+ BrdReplicate< type > brd(src.rows, src.cols); \\r
+ BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > brdSrc(texSrc, brd); \\r
+ Filter< BorderReader<tex_resize_ ## type ## _reader, BrdReplicate< type > > > filteredSrc(brdSrc); \\r
+ resize<<<grid, block>>>(filteredSrc, fx, fy, dst); \\r
+ } \\r
cudaSafeCall( cudaGetLastError() ); \\r
cudaSafeCall( cudaDeviceSynchronize() ); \\r
} \\r
};\r
- \r
+\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(uchar)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(uchar2)\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(uchar4)\r
\r
//OPENCV_GPU_IMPLEMENT_RESIZE_TEX(schar)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(char2)\r
//OPENCV_GPU_IMPLEMENT_RESIZE_TEX(char4)\r
\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(ushort)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(ushort2)\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(ushort4)\r
\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(short)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(short2)\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(short4)\r
\r
//OPENCV_GPU_IMPLEMENT_RESIZE_TEX(int)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(int2)\r
//OPENCV_GPU_IMPLEMENT_RESIZE_TEX(int4)\r
\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(float)\r
- //OPENCV_GPU_IMPLEMENT_RESIZE_TEX(float2)\r
OPENCV_GPU_IMPLEMENT_RESIZE_TEX(float4)\r
\r
#undef OPENCV_GPU_IMPLEMENT_RESIZE_TEX\r
\r
template <template <typename> class Filter, typename T> struct ResizeDispatcher\r
- { \r
+ {\r
static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, float fx, float fy, DevMem2D_<T> dst, cudaStream_t stream)\r
{\r
if (stream == 0)\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "internal_shared.hpp"\r
+#include "opencv2/gpu/device/border_interpolate.hpp"\r
+#include "opencv2/gpu/device/vec_traits.hpp"\r
+#include "opencv2/gpu/device/vec_math.hpp"\r
+#include "opencv2/gpu/device/saturate_cast.hpp"\r
+#include "opencv2/gpu/device/filters.hpp"\r
+\r
+namespace cv { namespace gpu { namespace device\r
+{\r
+ namespace imgproc\r
+ {\r
+ __constant__ float c_warpMat[3 * 3];\r
+\r
+ struct AffineTransform\r
+ {\r
+ static __device__ __forceinline__ float2 calcCoord(int x, int y)\r
+ {\r
+ const float xcoo = c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2];\r
+ const float ycoo = c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5];\r
+\r
+ return make_float2(xcoo, ycoo);\r
+ }\r
+ };\r
+\r
+ struct PerspectiveTransform\r
+ {\r
+ static __device__ __forceinline__ float2 calcCoord(int x, int y)\r
+ {\r
+ const float coeff = 1.0f / (c_warpMat[6] * x + c_warpMat[7] * y + c_warpMat[8]);\r
+\r
+ const float xcoo = coeff * (c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2]);\r
+ const float ycoo = coeff * (c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5]);\r
+\r
+ return make_float2(xcoo, ycoo);\r
+ }\r
+ };\r
+\r
+ ///////////////////////////////////////////////////////////////////\r
+ // Build Maps\r
+\r
+ template <class Transform> __global__ void buildWarpMaps(DevMem2Df xmap, PtrStepf ymap)\r
+ {\r
+ const int x = blockDim.x * blockIdx.x + threadIdx.x;\r
+ const int y = blockDim.y * blockIdx.y + threadIdx.y;\r
+\r
+ if (x < xmap.cols && y < xmap.rows)\r
+ {\r
+ const float2 coord = Transform::calcCoord(x, y);\r
+\r
+ xmap(y, x) = coord.x;\r
+ ymap(y, x) = coord.y;\r
+ }\r
+ }\r
+\r
+ template <class Transform> void buildWarpMaps_caller(DevMem2Df xmap, DevMem2Df ymap, cudaStream_t stream)\r
+ {\r
+ dim3 block(32, 8);\r
+ dim3 grid(divUp(xmap.cols, block.x), divUp(xmap.rows, block.y));\r
+ \r
+ buildWarpMaps<Transform><<<grid, block, 0, stream>>>(xmap, ymap);\r
+ cudaSafeCall( cudaGetLastError() );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+ }\r
+\r
+ void buildWarpAffineMaps_gpu(float coeffs[2 * 3], DevMem2Df xmap, DevMem2Df ymap, cudaStream_t stream)\r
+ {\r
+ cudaSafeCall( cudaMemcpyToSymbol(c_warpMat, coeffs, 2 * 3 * sizeof(float)) );\r
+\r
+ buildWarpMaps_caller<AffineTransform>(xmap, ymap, stream);\r
+ }\r
+\r
+ void buildWarpPerspectiveMaps_gpu(float coeffs[3 * 3], DevMem2Df xmap, DevMem2Df ymap, cudaStream_t stream)\r
+ {\r
+ cudaSafeCall( cudaMemcpyToSymbol(c_warpMat, coeffs, 3 * 3 * sizeof(float)) );\r
+\r
+ buildWarpMaps_caller<PerspectiveTransform>(xmap, ymap, stream);\r
+ }\r
+\r
+ ///////////////////////////////////////////////////////////////////\r
+ // Warp\r
+\r
+ template <class Transform, class Ptr2D, typename T> __global__ void warp(const Ptr2D src, DevMem2D_<T> dst)\r
+ {\r
+ const int x = blockDim.x * blockIdx.x + threadIdx.x;\r
+ const int y = blockDim.y * blockIdx.y + threadIdx.y;\r
+\r
+ if (x < dst.cols && y < dst.rows)\r
+ {\r
+ const float2 coord = Transform::calcCoord(x, y);\r
+\r
+ dst.ptr(y)[x] = saturate_cast<T>(src(coord.y, coord.x));\r
+ }\r
+ }\r
+\r
+ template <class Transform, template <typename> class Filter, template <typename> class B, typename T> struct WarpDispatcherStream\r
+ {\r
+ static void call(DevMem2D_<T> src, DevMem2D_<T> dst, const float* borderValue, cudaStream_t stream, int)\r
+ {\r
+ typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_type;\r
+\r
+ dim3 block(32, 8);\r
+ dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
+\r
+ B<work_type> brd(src.rows, src.cols, VecTraits<work_type>::make(borderValue));\r
+ BorderReader< PtrStep<T>, B<work_type> > brdSrc(src, brd);\r
+ Filter< BorderReader< PtrStep<T>, B<work_type> > > filter_src(brdSrc);\r
+\r
+ warp<Transform><<<grid, block, 0, stream>>>(filter_src, dst);\r
+ cudaSafeCall( cudaGetLastError() );\r
+ }\r
+ };\r
+\r
+ template <class Transform, template <typename> class Filter, template <typename> class B, typename T> struct WarpDispatcherNonStream\r
+ {\r
+ static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2D_<T> dst, const float* borderValue, int)\r
+ {\r
+ typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_type; \r
+\r
+ dim3 block(32, 8);\r
+ dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y));\r
+\r
+ B<work_type> brd(src.rows, src.cols, VecTraits<work_type>::make(borderValue));\r
+ BorderReader< PtrStep<T>, B<work_type> > brdSrc(src, brd);\r
+ Filter< BorderReader< PtrStep<T>, B<work_type> > > filter_src(brdSrc);\r
+\r
+ warp<Transform><<<grid, block>>>(filter_src, dst);\r
+ cudaSafeCall( cudaGetLastError() );\r
+\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+ }\r
+ };\r
+\r
+ #define OPENCV_GPU_IMPLEMENT_WARP_TEX(type) \\r
+ texture< type , cudaTextureType2D > tex_warp_ ## type (0, cudaFilterModePoint, cudaAddressModeClamp); \\r
+ struct tex_warp_ ## type ## _reader \\r
+ { \\r
+ typedef type elem_type; \\r
+ typedef int index_type; \\r
+ int xoff, yoff; \\r
+ tex_warp_ ## type ## _reader (int xoff_, int yoff_) : xoff(xoff_), yoff(yoff_) {} \\r
+ __device__ __forceinline__ elem_type operator ()(index_type y, index_type x) const \\r
+ { \\r
+ return tex2D(tex_warp_ ## type , x + xoff, y + yoff); \\r
+ } \\r
+ }; \\r
+ template <class Transform, template <typename> class Filter, template <typename> class B> struct WarpDispatcherNonStream<Transform, Filter, B, type> \\r
+ { \\r
+ static void call(DevMem2D_< type > src, DevMem2D_< type > srcWhole, int xoff, int yoff, DevMem2D_< type > dst, const float* borderValue, int cc) \\r
+ { \\r
+ typedef typename TypeVec<float, VecTraits< type >::cn>::vec_type work_type; \\r
+ dim3 block(32, cc >= 20 ? 8 : 4); \\r
+ dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \\r
+ bindTexture(&tex_warp_ ## type , srcWhole); \\r
+ tex_warp_ ## type ##_reader texSrc(xoff, yoff); \\r
+ B<work_type> brd(src.rows, src.cols, VecTraits<work_type>::make(borderValue)); \\r
+ BorderReader< tex_warp_ ## type ##_reader, B<work_type> > brdSrc(texSrc, brd); \\r
+ Filter< BorderReader< tex_warp_ ## type ##_reader, B<work_type> > > filter_src(brdSrc); \\r
+ warp<Transform><<<grid, block>>>(filter_src, dst); \\r
+ cudaSafeCall( cudaGetLastError() ); \\r
+ cudaSafeCall( cudaDeviceSynchronize() ); \\r
+ } \\r
+ }; \\r
+ template <class Transform, template <typename> class Filter> struct WarpDispatcherNonStream<Transform, Filter, BrdReplicate, type> \\r
+ { \\r
+ static void call(DevMem2D_< type > src, DevMem2D_< type > srcWhole, int xoff, int yoff, DevMem2D_< type > dst, const float*, int) \\r
+ { \\r
+ dim3 block(32, 8); \\r
+ dim3 grid(divUp(dst.cols, block.x), divUp(dst.rows, block.y)); \\r
+ bindTexture(&tex_warp_ ## type , srcWhole); \\r
+ tex_warp_ ## type ##_reader texSrc(xoff, yoff); \\r
+ if (srcWhole.cols == src.cols && srcWhole.rows == src.rows) \\r
+ { \\r
+ Filter< tex_warp_ ## type ##_reader > filter_src(texSrc); \\r
+ warp<Transform><<<grid, block>>>(filter_src, dst); \\r
+ } \\r
+ else \\r
+ { \\r
+ BrdReplicate<type> brd(src.rows, src.cols); \\r
+ BorderReader< tex_warp_ ## type ##_reader, BrdReplicate<type> > brdSrc(texSrc, brd); \\r
+ Filter< BorderReader< tex_warp_ ## type ##_reader, BrdReplicate<type> > > filter_src(brdSrc); \\r
+ warp<Transform><<<grid, block>>>(filter_src, dst); \\r
+ } \\r
+ cudaSafeCall( cudaGetLastError() ); \\r
+ cudaSafeCall( cudaDeviceSynchronize() ); \\r
+ } \\r
+ };\r
+\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(uchar)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(uchar2)\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(uchar4)\r
+\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(schar)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(char2)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(char4)\r
+\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(ushort)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(ushort2)\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(ushort4)\r
+\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(short)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(short2)\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(short4)\r
+\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(int)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(int2)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(int4)\r
+\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(float)\r
+ //OPENCV_GPU_IMPLEMENT_WARP_TEX(float2)\r
+ OPENCV_GPU_IMPLEMENT_WARP_TEX(float4)\r
+\r
+ #undef OPENCV_GPU_IMPLEMENT_WARP_TEX\r
+\r
+ template <class Transform, template <typename> class Filter, template <typename> class B, typename T> struct WarpDispatcher\r
+ { \r
+ static void call(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2D_<T> dst, const float* borderValue, cudaStream_t stream, int cc)\r
+ {\r
+ if (stream == 0)\r
+ WarpDispatcherNonStream<Transform, Filter, B, T>::call(src, srcWhole, xoff, yoff, dst, borderValue, cc);\r
+ else\r
+ WarpDispatcherStream<Transform, Filter, B, T>::call(src, dst, borderValue, stream, cc);\r
+ }\r
+ };\r
+\r
+ template <class Transform, typename T> \r
+ void warp_caller(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc)\r
+ {\r
+ typedef void (*func_t)(DevMem2D_<T> src, DevMem2D_<T> srcWhole, int xoff, int yoff, DevMem2D_<T> dst, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ static const func_t funcs[3][5] =\r
+ {\r
+ {\r
+ WarpDispatcher<Transform, PointFilter, BrdReflect101, T>::call,\r
+ WarpDispatcher<Transform, PointFilter, BrdReplicate, T>::call,\r
+ WarpDispatcher<Transform, PointFilter, BrdConstant, T>::call,\r
+ WarpDispatcher<Transform, PointFilter, BrdReflect, T>::call,\r
+ WarpDispatcher<Transform, PointFilter, BrdWrap, T>::call\r
+ },\r
+ {\r
+ WarpDispatcher<Transform, LinearFilter, BrdReflect101, T>::call,\r
+ WarpDispatcher<Transform, LinearFilter, BrdReplicate, T>::call,\r
+ WarpDispatcher<Transform, LinearFilter, BrdConstant, T>::call,\r
+ WarpDispatcher<Transform, LinearFilter, BrdReflect, T>::call,\r
+ WarpDispatcher<Transform, LinearFilter, BrdWrap, T>::call\r
+ },\r
+ {\r
+ WarpDispatcher<Transform, CubicFilter, BrdReflect101, T>::call,\r
+ WarpDispatcher<Transform, CubicFilter, BrdReplicate, T>::call,\r
+ WarpDispatcher<Transform, CubicFilter, BrdConstant, T>::call,\r
+ WarpDispatcher<Transform, CubicFilter, BrdReflect, T>::call,\r
+ WarpDispatcher<Transform, CubicFilter, BrdWrap, T>::call\r
+ }\r
+ };\r
+\r
+ funcs[interpolation][borderMode](static_cast< DevMem2D_<T> >(src), static_cast< DevMem2D_<T> >(srcWhole), xoff, yoff,\r
+ static_cast< DevMem2D_<T> >(dst), borderValue, stream, cc);\r
+ }\r
+\r
+ template <typename T> void warpAffine_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc)\r
+ {\r
+ cudaSafeCall( cudaMemcpyToSymbol(c_warpMat, coeffs, 2 * 3 * sizeof(float)) );\r
+\r
+ warp_caller<AffineTransform, T>(src, srcWhole, xoff, yoff, dst, interpolation, borderMode, borderValue, stream, cc);\r
+ }\r
+\r
+ template void warpAffine_gpu<uchar >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<uchar2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<uchar3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<uchar4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ //template void warpAffine_gpu<schar>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<char2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<char3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<char4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpAffine_gpu<ushort >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<ushort2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<ushort3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<ushort4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpAffine_gpu<short >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<short2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<short3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<short4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ //template void warpAffine_gpu<int >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<int2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<int3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<int4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpAffine_gpu<float >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpAffine_gpu<float2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<float3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpAffine_gpu<float4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template <typename T> void warpPerspective_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc)\r
+ {\r
+ cudaSafeCall( cudaMemcpyToSymbol(c_warpMat, coeffs, 3 * 3 * sizeof(float)) );\r
+\r
+ warp_caller<PerspectiveTransform, T>(src, srcWhole, xoff, yoff, dst, interpolation, borderMode, borderValue, stream, cc);\r
+ }\r
+\r
+ template void warpPerspective_gpu<uchar >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<uchar2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<uchar3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<uchar4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ //template void warpPerspective_gpu<schar>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<char2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<char3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<char4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpPerspective_gpu<ushort >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<ushort2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<ushort3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<ushort4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpPerspective_gpu<short >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<short2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<short3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<short4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ //template void warpPerspective_gpu<int >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<int2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<int3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<int4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ template void warpPerspective_gpu<float >(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ //template void warpPerspective_gpu<float2>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<float3>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ template void warpPerspective_gpu<float4>(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ } // namespace imgproc\r
+}}} // namespace cv { namespace gpu { namespace device\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::remap(const GpuMat&, GpuMat&, const GpuMat&, const GpuMat&, int, int, const Scalar&, Stream&){ throw_nogpu(); }\r
void cv::gpu::meanShiftFiltering(const GpuMat&, GpuMat&, int, int, TermCriteria, Stream&) { throw_nogpu(); }\r
void cv::gpu::meanShiftProc(const GpuMat&, GpuMat&, GpuMat&, int, int, TermCriteria, Stream&) { throw_nogpu(); }\r
void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int, Stream&) { throw_nogpu(); }\r
void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&, Stream&) { throw_nogpu(); }\r
-void cv::gpu::resize(const GpuMat&, GpuMat&, Size, double, double, int, Stream&) { throw_nogpu(); }\r
void cv::gpu::copyMakeBorder(const GpuMat&, GpuMat&, int, int, int, int, int, const Scalar&, Stream&) { throw_nogpu(); }\r
-void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int, Stream&) { throw_nogpu(); }\r
-void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int, Stream&) { throw_nogpu(); }\r
void cv::gpu::buildWarpPlaneMaps(Size, Rect, const Mat&, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::buildWarpCylindricalMaps(Size, Rect, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::buildWarpSphericalMaps(Size, Rect, const Mat&, const Mat&, float, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
#else /* !defined (HAVE_CUDA) */\r
\r
////////////////////////////////////////////////////////////////////////\r
-// remap\r
-\r
-namespace cv { namespace gpu { namespace device \r
-{\r
- namespace imgproc \r
- {\r
- template <typename T> \r
- void remap_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst, \r
- int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
- }\r
-}}}\r
-\r
-void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode, const Scalar& borderValue, Stream& stream)\r
-{\r
- using namespace ::cv::gpu::device::imgproc;\r
-\r
- typedef void (*caller_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst, int interpolation, \r
- int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
-\r
- static const caller_t callers[6][4] = \r
- {\r
- {remap_gpu<uchar>, 0/*remap_gpu<uchar2>*/, remap_gpu<uchar3>, remap_gpu<uchar4>},\r
- {0/*remap_gpu<schar>*/, 0/*remap_gpu<char2>*/, 0/*remap_gpu<char3>*/, 0/*remap_gpu<char4>*/},\r
- {remap_gpu<ushort>, 0/*remap_gpu<ushort2>*/, remap_gpu<ushort3>, remap_gpu<ushort4>},\r
- {remap_gpu<short>, 0/*remap_gpu<short2>*/, remap_gpu<short3>, remap_gpu<short4>},\r
- {0/*remap_gpu<int>*/, 0/*remap_gpu<int2>*/, 0/*remap_gpu<int3>*/, 0/*remap_gpu<int4>*/},\r
- {remap_gpu<float>, 0/*remap_gpu<float2>*/, remap_gpu<float3>, remap_gpu<float4>}\r
- };\r
-\r
- CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);\r
- CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size());\r
-\r
- caller_t func = callers[src.depth()][src.channels() - 1];\r
- CV_Assert(func != 0);\r
-\r
- CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
-\r
- CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);\r
- int gpuBorderType;\r
- CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType));\r
-\r
- dst.create(xmap.size(), src.type());\r
- \r
- Scalar_<float> borderValueFloat;\r
- borderValueFloat = borderValue;\r
-\r
- DeviceInfo info;\r
- int cc = info.majorVersion() * 10 + info.minorVersion();\r
- \r
- Size wholeSize;\r
- Point ofs;\r
- src.locateROI(wholeSize, ofs);\r
-\r
- func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, xmap, ymap, \r
- dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(stream), cc);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
// meanShiftFiltering_GPU\r
\r
namespace cv { namespace gpu { namespace device \r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
-// resize\r
-\r
-namespace cv { namespace gpu { namespace device \r
-{\r
- namespace imgproc \r
- {\r
- template <typename T> void resize_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy, \r
- DevMem2Db dst, int interpolation, cudaStream_t stream);\r
- }\r
-}}}\r
-\r
-void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, double fy, int interpolation, Stream& s)\r
-{\r
- CV_Assert( src.depth() <= CV_32F && src.channels() <= 4 );\r
- CV_Assert( interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC );\r
- CV_Assert( !(dsize == Size()) || (fx > 0 && fy > 0) );\r
-\r
- if( dsize == Size() )\r
- {\r
- dsize = Size(saturate_cast<int>(src.cols * fx), saturate_cast<int>(src.rows * fy));\r
- }\r
- else\r
- {\r
- fx = (double)dsize.width / src.cols;\r
- fy = (double)dsize.height / src.rows;\r
- }\r
-\r
- dst.create(dsize, src.type());\r
-\r
- if (dsize == src.size())\r
- {\r
- if (s)\r
- s.enqueueCopy(src, dst);\r
- else\r
- src.copyTo(dst);\r
- return;\r
- }\r
-\r
- cudaStream_t stream = StreamAccessor::getStream(s);\r
- \r
- Size wholeSize;\r
- Point ofs;\r
- src.locateROI(wholeSize, ofs);\r
-\r
- if ((src.type() == CV_8UC1 || src.type() == CV_8UC4) && (interpolation == INTER_NEAREST || interpolation == INTER_LINEAR))\r
- {\r
- static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC, 0, NPPI_INTER_LANCZOS};\r
-\r
- NppiSize srcsz;\r
- srcsz.width = wholeSize.width;\r
- srcsz.height = wholeSize.height;\r
-\r
- NppiRect srcrect;\r
- srcrect.x = ofs.x;\r
- srcrect.y = ofs.y;\r
- srcrect.width = src.cols;\r
- srcrect.height = src.rows;\r
-\r
- NppiSize dstsz;\r
- dstsz.width = dst.cols;\r
- dstsz.height = dst.rows;\r
-\r
- NppStreamHandler h(stream);\r
-\r
- if (src.type() == CV_8UC1)\r
- {\r
- nppSafeCall( nppiResize_8u_C1R(src.datastart, srcsz, static_cast<int>(src.step), srcrect,\r
- dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) );\r
- }\r
- else\r
- {\r
- nppSafeCall( nppiResize_8u_C4R(src.datastart, srcsz, static_cast<int>(src.step), srcrect,\r
- dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) );\r
- }\r
-\r
- if (stream == 0)\r
- cudaSafeCall( cudaDeviceSynchronize() );\r
- }\r
- else\r
- {\r
- using namespace ::cv::gpu::device::imgproc;\r
-\r
- typedef void (*caller_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy, DevMem2Db dst, int interpolation, cudaStream_t stream);\r
-\r
- static const caller_t callers[6][4] = \r
- {\r
- {resize_gpu<uchar>, 0/*resize_gpu<uchar2>*/, resize_gpu<uchar3>, resize_gpu<uchar4>},\r
- {0/*resize_gpu<schar>*/, 0/*resize_gpu<char2>*/, 0/*resize_gpu<char3>*/, 0/*resize_gpu<char4>*/},\r
- {resize_gpu<ushort>, 0/*resize_gpu<ushort2>*/, resize_gpu<ushort3>, resize_gpu<ushort4>},\r
- {resize_gpu<short>, 0/*resize_gpu<short2>*/, resize_gpu<short3>, resize_gpu<short4>},\r
- {0/*resize_gpu<int>*/, 0/*resize_gpu<int2>*/, 0/*resize_gpu<int3>*/, 0/*resize_gpu<int4>*/},\r
- {resize_gpu<float>, 0/*resize_gpu<float2>*/, resize_gpu<float3>, resize_gpu<float4>}\r
- };\r
-\r
- callers[src.depth()][src.channels() - 1](src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, \r
- static_cast<float>(fx), static_cast<float>(fy), dst, interpolation, stream);\r
- }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
// copyMakeBorder\r
\r
namespace cv { namespace gpu { namespace device \r
}\r
}\r
\r
-////////////////////////////////////////////////////////////////////////\r
-// warp\r
-\r
-namespace\r
-{\r
- typedef NppStatus (*npp_warp_8u_t)(const Npp8u* pSrc, NppiSize srcSize, int srcStep, NppiRect srcRoi, Npp8u* pDst,\r
- int dstStep, NppiRect dstRoi, const double coeffs[][3],\r
- int interpolation);\r
- typedef NppStatus (*npp_warp_16u_t)(const Npp16u* pSrc, NppiSize srcSize, int srcStep, NppiRect srcRoi, Npp16u* pDst,\r
- int dstStep, NppiRect dstRoi, const double coeffs[][3],\r
- int interpolation);\r
- typedef NppStatus (*npp_warp_32s_t)(const Npp32s* pSrc, NppiSize srcSize, int srcStep, NppiRect srcRoi, Npp32s* pDst,\r
- int dstStep, NppiRect dstRoi, const double coeffs[][3],\r
- int interpolation);\r
- typedef NppStatus (*npp_warp_32f_t)(const Npp32f* pSrc, NppiSize srcSize, int srcStep, NppiRect srcRoi, Npp32f* pDst,\r
- int dstStep, NppiRect dstRoi, const double coeffs[][3],\r
- int interpolation);\r
-\r
- void nppWarpCaller(const GpuMat& src, GpuMat& dst, double coeffs[][3], const Size& dsize, int flags,\r
- npp_warp_8u_t npp_warp_8u[][2], npp_warp_16u_t npp_warp_16u[][2],\r
- npp_warp_32s_t npp_warp_32s[][2], npp_warp_32f_t npp_warp_32f[][2], cudaStream_t stream)\r
- {\r
- static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC};\r
-\r
- int interpolation = flags & INTER_MAX;\r
-\r
- CV_Assert((src.depth() == CV_8U || src.depth() == CV_16U || src.depth() == CV_32S || src.depth() == CV_32F) && src.channels() != 2);\r
- CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
-\r
- dst.create(dsize, src.type());\r
- \r
- Size wholeSize;\r
- Point ofs;\r
- src.locateROI(wholeSize, ofs);\r
-\r
- NppiSize srcsz;\r
- srcsz.height = wholeSize.height;\r
- srcsz.width = wholeSize.width;\r
-\r
- NppiRect srcroi;\r
- srcroi.x = ofs.x;\r
- srcroi.y = ofs.y;\r
- srcroi.height = src.rows;\r
- srcroi.width = src.cols;\r
-\r
- NppiRect dstroi;\r
- dstroi.x = dstroi.y = 0;\r
- dstroi.height = dst.rows;\r
- dstroi.width = dst.cols;\r
-\r
- int warpInd = (flags & WARP_INVERSE_MAP) >> 4;\r
-\r
- NppStreamHandler h(stream);\r
-\r
- switch (src.depth())\r
- {\r
- case CV_8U:\r
- nppSafeCall( npp_warp_8u[src.channels()][warpInd]((Npp8u*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,\r
- dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );\r
- break;\r
- case CV_16U:\r
- nppSafeCall( npp_warp_16u[src.channels()][warpInd]((Npp16u*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,\r
- dst.ptr<Npp16u>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );\r
- break;\r
- case CV_32S:\r
- nppSafeCall( npp_warp_32s[src.channels()][warpInd]((Npp32s*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,\r
- dst.ptr<Npp32s>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );\r
- break;\r
- case CV_32F:\r
- nppSafeCall( npp_warp_32f[src.channels()][warpInd]((Npp32f*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,\r
- dst.ptr<Npp32f>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );\r
- break;\r
- default:\r
- CV_Assert(!"Unsupported source type");\r
- }\r
-\r
- if (stream == 0)\r
- cudaSafeCall( cudaDeviceSynchronize() );\r
- }\r
-}\r
-\r
-void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, Stream& s)\r
-{\r
- static npp_warp_8u_t npp_warpAffine_8u[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpAffine_8u_C1R, nppiWarpAffineBack_8u_C1R},\r
- {0, 0},\r
- {nppiWarpAffine_8u_C3R, nppiWarpAffineBack_8u_C3R},\r
- {nppiWarpAffine_8u_C4R, nppiWarpAffineBack_8u_C4R}\r
- };\r
- static npp_warp_16u_t npp_warpAffine_16u[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpAffine_16u_C1R, nppiWarpAffineBack_16u_C1R},\r
- {0, 0},\r
- {nppiWarpAffine_16u_C3R, nppiWarpAffineBack_16u_C3R},\r
- {nppiWarpAffine_16u_C4R, nppiWarpAffineBack_16u_C4R}\r
- };\r
- static npp_warp_32s_t npp_warpAffine_32s[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpAffine_32s_C1R, nppiWarpAffineBack_32s_C1R},\r
- {0, 0},\r
- {nppiWarpAffine_32s_C3R, nppiWarpAffineBack_32s_C3R},\r
- {nppiWarpAffine_32s_C4R, nppiWarpAffineBack_32s_C4R}\r
- };\r
- static npp_warp_32f_t npp_warpAffine_32f[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpAffine_32f_C1R, nppiWarpAffineBack_32f_C1R},\r
- {0, 0},\r
- {nppiWarpAffine_32f_C3R, nppiWarpAffineBack_32f_C3R},\r
- {nppiWarpAffine_32f_C4R, nppiWarpAffineBack_32f_C4R}\r
- };\r
-\r
- CV_Assert(M.rows == 2 && M.cols == 3);\r
-\r
- double coeffs[2][3];\r
- Mat coeffsMat(2, 3, CV_64F, (void*)coeffs);\r
- M.convertTo(coeffsMat, coeffsMat.type());\r
-\r
- nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpAffine_8u, npp_warpAffine_16u, npp_warpAffine_32s, npp_warpAffine_32f, StreamAccessor::getStream(s));\r
-}\r
-\r
-void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, Stream& s)\r
-{\r
- static npp_warp_8u_t npp_warpPerspective_8u[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpPerspective_8u_C1R, nppiWarpPerspectiveBack_8u_C1R},\r
- {0, 0},\r
- {nppiWarpPerspective_8u_C3R, nppiWarpPerspectiveBack_8u_C3R},\r
- {nppiWarpPerspective_8u_C4R, nppiWarpPerspectiveBack_8u_C4R}\r
- };\r
- static npp_warp_16u_t npp_warpPerspective_16u[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpPerspective_16u_C1R, nppiWarpPerspectiveBack_16u_C1R},\r
- {0, 0},\r
- {nppiWarpPerspective_16u_C3R, nppiWarpPerspectiveBack_16u_C3R},\r
- {nppiWarpPerspective_16u_C4R, nppiWarpPerspectiveBack_16u_C4R}\r
- };\r
- static npp_warp_32s_t npp_warpPerspective_32s[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpPerspective_32s_C1R, nppiWarpPerspectiveBack_32s_C1R},\r
- {0, 0},\r
- {nppiWarpPerspective_32s_C3R, nppiWarpPerspectiveBack_32s_C3R},\r
- {nppiWarpPerspective_32s_C4R, nppiWarpPerspectiveBack_32s_C4R}\r
- };\r
- static npp_warp_32f_t npp_warpPerspective_32f[][2] =\r
- {\r
- {0, 0},\r
- {nppiWarpPerspective_32f_C1R, nppiWarpPerspectiveBack_32f_C1R},\r
- {0, 0},\r
- {nppiWarpPerspective_32f_C3R, nppiWarpPerspectiveBack_32f_C3R},\r
- {nppiWarpPerspective_32f_C4R, nppiWarpPerspectiveBack_32f_C4R}\r
- };\r
-\r
- CV_Assert(M.rows == 3 && M.cols == 3);\r
-\r
- double coeffs[3][3];\r
- Mat coeffsMat(3, 3, CV_64F, (void*)coeffs);\r
- M.convertTo(coeffsMat, coeffsMat.type());\r
-\r
- nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpPerspective_8u, npp_warpPerspective_16u, npp_warpPerspective_32s, npp_warpPerspective_32f, StreamAccessor::getStream(s));\r
-}\r
-\r
//////////////////////////////////////////////////////////////////////////////\r
// buildWarpPlaneMaps\r
\r
#include "saturate_cast.hpp"\r
#include "vec_traits.hpp"\r
#include "vec_math.hpp"\r
+#include "type_traits.hpp"\r
\r
-namespace cv { namespace gpu { namespace device \r
+namespace cv { namespace gpu { namespace device\r
{\r
template <typename Ptr2D> struct PointFilter\r
{\r
typedef float index_type;\r
\r
explicit __host__ __device__ __forceinline__ PointFilter(const Ptr2D& src_) : src(src_) {}\r
- \r
+\r
__device__ __forceinline__ elem_type operator ()(float y, float x) const\r
{\r
- return src(__float2int_rn(y), __float2int_rn(x));\r
+ return src(__float2int_rd(y), __float2int_rd(x));\r
}\r
\r
const Ptr2D src;\r
\r
work_type out = VecTraits<work_type>::all(0);\r
\r
+ x -= 0.5f;\r
+ y -= 0.5f;\r
+\r
const int x1 = __float2int_rd(x);\r
const int y1 = __float2int_rd(y);\r
const int x2 = x1 + 1;\r
typedef typename TypeVec<float, VecTraits<elem_type>::cn>::vec_type work_type;\r
\r
explicit __host__ __device__ __forceinline__ CubicFilter(const Ptr2D& src_) : src(src_) {}\r
- \r
- static __device__ __forceinline__ work_type cubicInterpolate(const work_type& p0, const work_type& p1, const work_type& p2, const work_type& p3, float x) \r
+\r
+ static __device__ __forceinline__ work_type cubicInterpolate(typename TypeTraits<work_type>::ParameterType p0, typename TypeTraits<work_type>::ParameterType p1, typename TypeTraits<work_type>::ParameterType p2, typename TypeTraits<work_type>::ParameterType p3, float x)\r
{\r
return p1 + 0.5f * x * (p2 - p0 + x * (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3 + x * (3.0f * (p1 - p2) + p3 - p0)));\r
}\r
{\r
const int xi = __float2int_rn(x);\r
const int yi = __float2int_rn(y);\r
- \r
+\r
work_type arr[4];\r
- \r
- arr[0] = cubicInterpolate(saturate_cast<work_type>(src(yi - 1, xi - 1)), saturate_cast<work_type>(src(yi - 1, xi)), saturate_cast<work_type>(src(yi - 1, xi + 1)), saturate_cast<work_type>(src(yi - 1, xi + 2)), x - xi);\r
- arr[1] = cubicInterpolate(saturate_cast<work_type>(src(yi , xi - 1)), saturate_cast<work_type>(src(yi , xi)), saturate_cast<work_type>(src(yi , xi + 1)), saturate_cast<work_type>(src(yi , xi + 2)), x - xi);\r
- arr[2] = cubicInterpolate(saturate_cast<work_type>(src(yi + 1, xi - 1)), saturate_cast<work_type>(src(yi + 1, xi)), saturate_cast<work_type>(src(yi + 1, xi + 1)), saturate_cast<work_type>(src(yi + 1, xi + 2)), x - xi);\r
- arr[3] = cubicInterpolate(saturate_cast<work_type>(src(yi + 2, xi - 1)), saturate_cast<work_type>(src(yi + 2, xi)), saturate_cast<work_type>(src(yi + 2, xi + 1)), saturate_cast<work_type>(src(yi + 2, xi + 2)), x - xi);\r
- \r
- return saturate_cast<elem_type>(cubicInterpolate(arr[0], arr[1], arr[2], arr[3], y - yi));\r
+\r
+ arr[0] = cubicInterpolate(saturate_cast<work_type>(src(yi - 2, xi - 2)), saturate_cast<work_type>(src(yi - 2, xi - 1)), saturate_cast<work_type>(src(yi - 2, xi)), saturate_cast<work_type>(src(yi - 2, xi + 1)), (x - xi + 2.0f) / 4.0f);\r
+ arr[1] = cubicInterpolate(saturate_cast<work_type>(src(yi - 1, xi - 2)), saturate_cast<work_type>(src(yi - 1, xi - 1)), saturate_cast<work_type>(src(yi - 1, xi)), saturate_cast<work_type>(src(yi - 1, xi + 1)), (x - xi + 2.0f) / 4.0f);\r
+ arr[2] = cubicInterpolate(saturate_cast<work_type>(src(yi , xi - 2)), saturate_cast<work_type>(src(yi , xi - 1)), saturate_cast<work_type>(src(yi , xi)), saturate_cast<work_type>(src(yi , xi + 1)), (x - xi + 2.0f) / 4.0f);\r
+ arr[3] = cubicInterpolate(saturate_cast<work_type>(src(yi + 1, xi - 2)), saturate_cast<work_type>(src(yi + 1, xi - 1)), saturate_cast<work_type>(src(yi + 1, xi)), saturate_cast<work_type>(src(yi + 1, xi + 1)), (x - xi + 2.0f) / 4.0f);\r
+\r
+ return saturate_cast<elem_type>(cubicInterpolate(arr[0], arr[1], arr[2], arr[3], (y - yi + 2.0f) / 4.0f));\r
}\r
\r
const Ptr2D src;\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifndef HAVE_CUDA\r
+\r
+void cv::gpu::remap(const GpuMat&, GpuMat&, const GpuMat&, const GpuMat&, int, int, Scalar, Stream&){ throw_nogpu(); }\r
+\r
+#else // HAVE_CUDA\r
+\r
+namespace cv { namespace gpu { namespace device \r
+{\r
+ namespace imgproc \r
+ {\r
+ template <typename T> \r
+ void remap_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst, \r
+ int interpolation, int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ }\r
+}}}\r
+\r
+void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const GpuMat& ymap, int interpolation, int borderMode, Scalar borderValue, Stream& stream)\r
+{\r
+ using namespace cv::gpu::device::imgproc;\r
+\r
+ typedef void (*func_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, DevMem2Df xmap, DevMem2Df ymap, DevMem2Db dst, int interpolation, \r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ static const func_t funcs[6][4] = \r
+ {\r
+ {remap_gpu<uchar> , 0 /*remap_gpu<uchar2>*/ , remap_gpu<uchar3> , remap_gpu<uchar4> },\r
+ {0 /*remap_gpu<schar>*/, 0 /*remap_gpu<char2>*/ , 0 /*remap_gpu<char3>*/, 0 /*remap_gpu<char4>*/},\r
+ {remap_gpu<ushort> , 0 /*remap_gpu<ushort2>*/, remap_gpu<ushort3> , remap_gpu<ushort4> },\r
+ {remap_gpu<short> , 0 /*remap_gpu<short2>*/ , remap_gpu<short3> , remap_gpu<short4> },\r
+ {0 /*remap_gpu<int>*/ , 0 /*remap_gpu<int2>*/ , 0 /*remap_gpu<int3>*/ , 0 /*remap_gpu<int4>*/ },\r
+ {remap_gpu<float> , 0 /*remap_gpu<float2>*/ , remap_gpu<float3> , remap_gpu<float4> }\r
+ };\r
+\r
+ CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);\r
+ CV_Assert(xmap.type() == CV_32F && ymap.type() == CV_32F && xmap.size() == ymap.size());\r
+ CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
+ CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);\r
+\r
+ const func_t func = funcs[src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ int gpuBorderType;\r
+ CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType));\r
+\r
+ dst.create(xmap.size(), src.type());\r
+\r
+ Scalar_<float> borderValueFloat;\r
+ borderValueFloat = borderValue;\r
+\r
+ DeviceInfo info;\r
+ int cc = info.majorVersion() * 10 + info.minorVersion();\r
+\r
+ Size wholeSize;\r
+ Point ofs;\r
+ src.locateROI(wholeSize, ofs);\r
+\r
+ func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, xmap, ymap, \r
+ dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(stream), cc);\r
+}\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifndef HAVE_CUDA\r
+\r
+void cv::gpu::resize(const GpuMat&, GpuMat&, Size, double, double, int, Stream&) { throw_nogpu(); }\r
+\r
+#else // HAVE_CUDA\r
+\r
+namespace cv { namespace gpu { namespace device\r
+{\r
+ namespace imgproc\r
+ {\r
+ template <typename T>\r
+ void resize_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy,\r
+ DevMem2Db dst, int interpolation, cudaStream_t stream);\r
+ }\r
+}}}\r
+\r
+void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, double fy, int interpolation, Stream& s)\r
+{\r
+ CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);\r
+ CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
+ CV_Assert(!(dsize == Size()) || (fx > 0 && fy > 0));\r
+\r
+ if (dsize == Size())\r
+ dsize = Size(saturate_cast<int>(src.cols * fx), saturate_cast<int>(src.rows * fy));\r
+ else\r
+ {\r
+ fx = static_cast<double>(dsize.width) / src.cols;\r
+ fy = static_cast<double>(dsize.height) / src.rows;\r
+ }\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ if (dsize == src.size())\r
+ {\r
+ if (s)\r
+ s.enqueueCopy(src, dst);\r
+ else\r
+ src.copyTo(dst);\r
+ return;\r
+ }\r
+\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ Size wholeSize;\r
+ Point ofs;\r
+ src.locateROI(wholeSize, ofs);\r
+\r
+ bool useNpp = (src.type() == CV_8UC1 || src.type() == CV_8UC4);\r
+ useNpp = useNpp && (interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || src.type() == CV_8UC4);\r
+\r
+ if (useNpp)\r
+ {\r
+ typedef NppStatus (*func_t)(const Npp8u * pSrc, NppiSize oSrcSize, int nSrcStep, NppiRect oSrcROI, Npp8u * pDst, int nDstStep, NppiSize dstROISize,\r
+ double xFactor, double yFactor, int eInterpolation);\r
+\r
+ const func_t funcs[4] = { nppiResize_8u_C1R, 0, 0, nppiResize_8u_C4R };\r
+\r
+ static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC, 0, NPPI_INTER_LANCZOS};\r
+\r
+ NppiSize srcsz;\r
+ srcsz.width = wholeSize.width;\r
+ srcsz.height = wholeSize.height;\r
+\r
+ NppiRect srcrect;\r
+ srcrect.x = ofs.x;\r
+ srcrect.y = ofs.y;\r
+ srcrect.width = src.cols;\r
+ srcrect.height = src.rows;\r
+\r
+ NppiSize dstsz;\r
+ dstsz.width = dst.cols;\r
+ dstsz.height = dst.rows;\r
+\r
+ NppStreamHandler h(stream);\r
+\r
+ nppSafeCall( funcs[src.channels() - 1](src.datastart, srcsz, static_cast<int>(src.step), srcrect,\r
+ dst.ptr<Npp8u>(), static_cast<int>(dst.step), dstsz, fx, fy, npp_inter[interpolation]) );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+ }\r
+ else\r
+ {\r
+ using namespace ::cv::gpu::device::imgproc;\r
+\r
+ typedef void (*func_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float fx, float fy, DevMem2Db dst, int interpolation, cudaStream_t stream);\r
+\r
+ static const func_t funcs[6][4] =\r
+ {\r
+ {resize_gpu<uchar> , 0 /*resize_gpu<uchar2>*/ , resize_gpu<uchar3> , resize_gpu<uchar4> },\r
+ {0 /*resize_gpu<schar>*/, 0 /*resize_gpu<char2>*/ , 0 /*resize_gpu<char3>*/, 0 /*resize_gpu<char4>*/},\r
+ {resize_gpu<ushort> , 0 /*resize_gpu<ushort2>*/, resize_gpu<ushort3> , resize_gpu<ushort4> },\r
+ {resize_gpu<short> , 0 /*resize_gpu<short2>*/ , resize_gpu<short3> , resize_gpu<short4> },\r
+ {0 /*resize_gpu<int>*/ , 0 /*resize_gpu<int2>*/ , 0 /*resize_gpu<int3>*/ , 0 /*resize_gpu<int4>*/ },\r
+ {resize_gpu<float> , 0 /*resize_gpu<float2>*/ , resize_gpu<float3> , resize_gpu<float4> }\r
+ };\r
+\r
+ const func_t func = funcs[src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y,\r
+ static_cast<float>(1.0 / fx), static_cast<float>(1.0 / fy), dst, interpolation, stream);\r
+ }\r
+}\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of the copyright holders may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifndef HAVE_CUDA\r
+\r
+void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int, int, Scalar, Stream&) { throw_nogpu(); }\r
+void cv::gpu::buildWarpAffineMaps(const Mat&, bool, Size, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+\r
+void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int, int, Scalar, Stream&) { throw_nogpu(); }\r
+void cv::gpu::buildWarpPerspectiveMaps(const Mat&, bool, Size, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+\r
+#else // HAVE_CUDA\r
+\r
+namespace cv { namespace gpu { namespace device\r
+{\r
+ namespace imgproc\r
+ {\r
+ void buildWarpAffineMaps_gpu(float coeffs[2 * 3], DevMem2Df xmap, DevMem2Df ymap, cudaStream_t stream);\r
+\r
+ template <typename T>\r
+ void warpAffine_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ void buildWarpPerspectiveMaps_gpu(float coeffs[3 * 3], DevMem2Df xmap, DevMem2Df ymap, cudaStream_t stream);\r
+\r
+ template <typename T>\r
+ void warpPerspective_gpu(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[3 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+ }\r
+}}}\r
+\r
+void cv::gpu::buildWarpAffineMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream)\r
+{\r
+ using namespace cv::gpu::device::imgproc;\r
+\r
+ CV_Assert(M.rows == 2 && M.cols == 3);\r
+\r
+ xmap.create(dsize, CV_32FC1);\r
+ ymap.create(dsize, CV_32FC1);\r
+\r
+ float coeffs[2 * 3];\r
+ Mat coeffsMat(2, 3, CV_32F, (void*)coeffs);\r
+\r
+ if (inverse)\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ invertAffineTransform(M, iM);\r
+ iM.convertTo(coeffsMat, coeffsMat.type());\r
+ }\r
+\r
+ buildWarpAffineMaps_gpu(coeffs, xmap, ymap, StreamAccessor::getStream(stream));\r
+}\r
+\r
+void cv::gpu::buildWarpPerspectiveMaps(const Mat& M, bool inverse, Size dsize, GpuMat& xmap, GpuMat& ymap, Stream& stream)\r
+{\r
+ using namespace cv::gpu::device::imgproc;\r
+\r
+ CV_Assert(M.rows == 3 && M.cols == 3);\r
+\r
+ xmap.create(dsize, CV_32FC1);\r
+ ymap.create(dsize, CV_32FC1);\r
+\r
+ float coeffs[3 * 3];\r
+ Mat coeffsMat(3, 3, CV_32F, (void*)coeffs);\r
+\r
+ if (inverse)\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ invert(M, iM);\r
+ iM.convertTo(coeffsMat, coeffsMat.type());\r
+ }\r
+\r
+ buildWarpPerspectiveMaps_gpu(coeffs, xmap, ymap, StreamAccessor::getStream(stream));\r
+}\r
+\r
+namespace\r
+{\r
+ template<int DEPTH> struct NppTypeTraits;\r
+ template<> struct NppTypeTraits<CV_8U> { typedef Npp8u npp_t; };\r
+ template<> struct NppTypeTraits<CV_8S> { typedef Npp8s npp_t; };\r
+ template<> struct NppTypeTraits<CV_16U> { typedef Npp16u npp_t; };\r
+ template<> struct NppTypeTraits<CV_16S> { typedef Npp16s npp_t; typedef Npp16sc npp_complex_type; };\r
+ template<> struct NppTypeTraits<CV_32S> { typedef Npp32s npp_t; typedef Npp32sc npp_complex_type; };\r
+ template<> struct NppTypeTraits<CV_32F> { typedef Npp32f npp_t; typedef Npp32fc npp_complex_type; };\r
+ template<> struct NppTypeTraits<CV_64F> { typedef Npp64f npp_t; typedef Npp64fc npp_complex_type; };\r
+\r
+ template <int DEPTH> struct NppWarpFunc\r
+ {\r
+ typedef typename NppTypeTraits<DEPTH>::npp_t npp_t;\r
+\r
+ typedef NppStatus (*func_t)(const npp_t* pSrc, NppiSize srcSize, int srcStep, NppiRect srcRoi, npp_t* pDst,\r
+ int dstStep, NppiRect dstRoi, const double coeffs[][3],\r
+ int interpolation);\r
+ };\r
+\r
+ template <int DEPTH, typename NppWarpFunc<DEPTH>::func_t func> struct NppWarp\r
+ {\r
+ typedef typename NppWarpFunc<DEPTH>::npp_t npp_t;\r
+\r
+ static void call(const cv::gpu::GpuMat& src, cv::Size wholeSize, cv::Point ofs, cv::gpu::GpuMat& dst,\r
+ double coeffs[][3], cv::Size dsize, int interpolation, cudaStream_t stream)\r
+ {\r
+ static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC};\r
+\r
+ dst.create(dsize, src.type());\r
+ dst.setTo(cv::Scalar::all(0));\r
+\r
+ NppiSize srcsz;\r
+ srcsz.height = wholeSize.height;\r
+ srcsz.width = wholeSize.width;\r
+\r
+ NppiRect srcroi;\r
+ srcroi.x = ofs.x;\r
+ srcroi.y = ofs.y;\r
+ srcroi.height = src.rows;\r
+ srcroi.width = src.cols;\r
+\r
+ NppiRect dstroi;\r
+ dstroi.x = dstroi.y = 0;\r
+ dstroi.height = dst.rows;\r
+ dstroi.width = dst.cols;\r
+\r
+ cv::gpu::NppStreamHandler h(stream);\r
+\r
+ nppSafeCall( func((npp_t*)src.datastart, srcsz, static_cast<int>(src.step), srcroi,\r
+ dst.ptr<npp_t>(), static_cast<int>(dst.step), dstroi, coeffs, npp_inter[interpolation]) );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+ }\r
+ };\r
+}\r
+\r
+void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& s)\r
+{\r
+ CV_Assert(M.rows == 2 && M.cols == 3);\r
+\r
+ int interpolation = flags & INTER_MAX;\r
+\r
+ CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);\r
+ CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
+ CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);\r
+\r
+ Size wholeSize;\r
+ Point ofs;\r
+ src.locateROI(wholeSize, ofs);\r
+\r
+ static const bool useNppTab[6][4][3] =\r
+ {\r
+ {\r
+ {false, false, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, true}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, true}\r
+ }\r
+ };\r
+\r
+ bool useNpp = borderMode == BORDER_CONSTANT;\r
+ useNpp = useNpp && useNppTab[src.depth()][src.channels() - 1][interpolation];\r
+ #ifdef linux\r
+ // NPP bug on float data\r
+ useNpp = useNpp && src.depth() != CV_32F;\r
+ #endif\r
+\r
+ if (useNpp)\r
+ {\r
+ typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::Size wholeSize, cv::Point ofs, cv::gpu::GpuMat& dst, double coeffs[][3], cv::Size dsize, int flags, cudaStream_t stream);\r
+\r
+ static const func_t funcs[2][6][4] =\r
+ {\r
+ {\r
+ {NppWarp<CV_8U, nppiWarpAffine_8u_C1R>::call, 0, NppWarp<CV_8U, nppiWarpAffine_8u_C3R>::call, NppWarp<CV_8U, nppiWarpAffine_8u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_16U, nppiWarpAffine_16u_C1R>::call, 0, NppWarp<CV_16U, nppiWarpAffine_16u_C3R>::call, NppWarp<CV_16U, nppiWarpAffine_16u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_32S, nppiWarpAffine_32s_C1R>::call, 0, NppWarp<CV_32S, nppiWarpAffine_32s_C3R>::call, NppWarp<CV_32S, nppiWarpAffine_32s_C4R>::call},\r
+ {NppWarp<CV_32F, nppiWarpAffine_32f_C1R>::call, 0, NppWarp<CV_32F, nppiWarpAffine_32f_C3R>::call, NppWarp<CV_32F, nppiWarpAffine_32f_C4R>::call}\r
+ },\r
+ {\r
+ {NppWarp<CV_8U, nppiWarpAffineBack_8u_C1R>::call, 0, NppWarp<CV_8U, nppiWarpAffineBack_8u_C3R>::call, NppWarp<CV_8U, nppiWarpAffineBack_8u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_16U, nppiWarpAffineBack_16u_C1R>::call, 0, NppWarp<CV_16U, nppiWarpAffineBack_16u_C3R>::call, NppWarp<CV_16U, nppiWarpAffineBack_16u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_32S, nppiWarpAffineBack_32s_C1R>::call, 0, NppWarp<CV_32S, nppiWarpAffineBack_32s_C3R>::call, NppWarp<CV_32S, nppiWarpAffineBack_32s_C4R>::call},\r
+ {NppWarp<CV_32F, nppiWarpAffineBack_32f_C1R>::call, 0, NppWarp<CV_32F, nppiWarpAffineBack_32f_C3R>::call, NppWarp<CV_32F, nppiWarpAffineBack_32f_C4R>::call}\r
+ }\r
+ };\r
+\r
+ double coeffs[2][3];\r
+ Mat coeffsMat(2, 3, CV_64F, (void*)coeffs);\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+\r
+ const func_t func = funcs[(flags & WARP_INVERSE_MAP) != 0][src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ func(src, wholeSize, ofs, dst, coeffs, dsize, interpolation, StreamAccessor::getStream(s));\r
+ }\r
+ else\r
+ {\r
+ using namespace cv::gpu::device::imgproc;\r
+\r
+ typedef void (*func_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ static const func_t funcs[6][4] =\r
+ {\r
+ {warpAffine_gpu<uchar> , 0 /*warpAffine_gpu<uchar2>*/ , warpAffine_gpu<uchar3> , warpAffine_gpu<uchar4> },\r
+ {0 /*warpAffine_gpu<schar>*/, 0 /*warpAffine_gpu<char2>*/ , 0 /*warpAffine_gpu<char3>*/, 0 /*warpAffine_gpu<char4>*/},\r
+ {warpAffine_gpu<ushort> , 0 /*warpAffine_gpu<ushort2>*/, warpAffine_gpu<ushort3> , warpAffine_gpu<ushort4> },\r
+ {warpAffine_gpu<short> , 0 /*warpAffine_gpu<short2>*/ , warpAffine_gpu<short3> , warpAffine_gpu<short4> },\r
+ {0 /*warpAffine_gpu<int>*/ , 0 /*warpAffine_gpu<int2>*/ , 0 /*warpAffine_gpu<int3>*/ , 0 /*warpAffine_gpu<int4>*/ },\r
+ {warpAffine_gpu<float> , 0 /*warpAffine_gpu<float2>*/ , warpAffine_gpu<float3> , warpAffine_gpu<float4> }\r
+ };\r
+\r
+ const func_t func = funcs[src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ int gpuBorderType;\r
+ CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType));\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ float coeffs[2 * 3];\r
+ Mat coeffsMat(2, 3, CV_32F, (void*)coeffs);\r
+\r
+ if (flags & WARP_INVERSE_MAP)\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ invertAffineTransform(M, iM);\r
+ iM.convertTo(coeffsMat, coeffsMat.type());\r
+ }\r
+\r
+ Scalar_<float> borderValueFloat;\r
+ borderValueFloat = borderValue;\r
+\r
+ DeviceInfo info;\r
+ int cc = info.majorVersion() * 10 + info.minorVersion();\r
+\r
+ func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, coeffs,\r
+ dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(s), cc);\r
+ }\r
+}\r
+\r
+void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, int borderMode, Scalar borderValue, Stream& s)\r
+{\r
+ CV_Assert(M.rows == 3 && M.cols == 3);\r
+\r
+ int interpolation = flags & INTER_MAX;\r
+\r
+ CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);\r
+ CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR || interpolation == INTER_CUBIC);\r
+ CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);\r
+\r
+ Size wholeSize;\r
+ Point ofs;\r
+ src.locateROI(wholeSize, ofs);\r
+\r
+ static const bool useNppTab[6][4][3] =\r
+ {\r
+ {\r
+ {false, false, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false},\r
+ {false, false, false}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, true}\r
+ },\r
+ {\r
+ {false, true, true},\r
+ {false, false, false},\r
+ {false, true, true},\r
+ {false, false, true}\r
+ }\r
+ };\r
+\r
+ bool useNpp = borderMode == BORDER_CONSTANT;\r
+ useNpp = useNpp && useNppTab[src.depth()][src.channels() - 1][interpolation];\r
+ #ifdef linux\r
+ // NPP bug on float data\r
+ useNpp = useNpp && src.depth() != CV_32F;\r
+ #endif\r
+\r
+ if (useNpp)\r
+ {\r
+ typedef void (*func_t)(const cv::gpu::GpuMat& src, cv::Size wholeSize, cv::Point ofs, cv::gpu::GpuMat& dst, double coeffs[][3], cv::Size dsize, int flags, cudaStream_t stream);\r
+\r
+ static const func_t funcs[2][6][4] =\r
+ {\r
+ {\r
+ {NppWarp<CV_8U, nppiWarpPerspective_8u_C1R>::call, 0, NppWarp<CV_8U, nppiWarpPerspective_8u_C3R>::call, NppWarp<CV_8U, nppiWarpPerspective_8u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_16U, nppiWarpPerspective_16u_C1R>::call, 0, NppWarp<CV_16U, nppiWarpPerspective_16u_C3R>::call, NppWarp<CV_16U, nppiWarpPerspective_16u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_32S, nppiWarpPerspective_32s_C1R>::call, 0, NppWarp<CV_32S, nppiWarpPerspective_32s_C3R>::call, NppWarp<CV_32S, nppiWarpPerspective_32s_C4R>::call},\r
+ {NppWarp<CV_32F, nppiWarpPerspective_32f_C1R>::call, 0, NppWarp<CV_32F, nppiWarpPerspective_32f_C3R>::call, NppWarp<CV_32F, nppiWarpPerspective_32f_C4R>::call}\r
+ },\r
+ {\r
+ {NppWarp<CV_8U, nppiWarpPerspectiveBack_8u_C1R>::call, 0, NppWarp<CV_8U, nppiWarpPerspectiveBack_8u_C3R>::call, NppWarp<CV_8U, nppiWarpPerspectiveBack_8u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_16U, nppiWarpPerspectiveBack_16u_C1R>::call, 0, NppWarp<CV_16U, nppiWarpPerspectiveBack_16u_C3R>::call, NppWarp<CV_16U, nppiWarpPerspectiveBack_16u_C4R>::call},\r
+ {0, 0, 0, 0},\r
+ {NppWarp<CV_32S, nppiWarpPerspectiveBack_32s_C1R>::call, 0, NppWarp<CV_32S, nppiWarpPerspectiveBack_32s_C3R>::call, NppWarp<CV_32S, nppiWarpPerspectiveBack_32s_C4R>::call},\r
+ {NppWarp<CV_32F, nppiWarpPerspectiveBack_32f_C1R>::call, 0, NppWarp<CV_32F, nppiWarpPerspectiveBack_32f_C3R>::call, NppWarp<CV_32F, nppiWarpPerspectiveBack_32f_C4R>::call}\r
+ }\r
+ };\r
+\r
+ double coeffs[3][3];\r
+ Mat coeffsMat(3, 3, CV_64F, (void*)coeffs);\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+\r
+ const func_t func = funcs[(flags & WARP_INVERSE_MAP) != 0][src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ func(src, wholeSize, ofs, dst, coeffs, dsize, interpolation, StreamAccessor::getStream(s));\r
+ }\r
+ else\r
+ {\r
+ using namespace cv::gpu::device::imgproc;\r
+\r
+ typedef void (*func_t)(DevMem2Db src, DevMem2Db srcWhole, int xoff, int yoff, float coeffs[2 * 3], DevMem2Db dst, int interpolation,\r
+ int borderMode, const float* borderValue, cudaStream_t stream, int cc);\r
+\r
+ static const func_t funcs[6][4] =\r
+ {\r
+ {warpPerspective_gpu<uchar> , 0 /*warpPerspective_gpu<uchar2>*/ , warpPerspective_gpu<uchar3> , warpPerspective_gpu<uchar4> },\r
+ {0 /*warpPerspective_gpu<schar>*/, 0 /*warpPerspective_gpu<char2>*/ , 0 /*warpPerspective_gpu<char3>*/, 0 /*warpPerspective_gpu<char4>*/},\r
+ {warpPerspective_gpu<ushort> , 0 /*warpPerspective_gpu<ushort2>*/, warpPerspective_gpu<ushort3> , warpPerspective_gpu<ushort4> },\r
+ {warpPerspective_gpu<short> , 0 /*warpPerspective_gpu<short2>*/ , warpPerspective_gpu<short3> , warpPerspective_gpu<short4> },\r
+ {0 /*warpPerspective_gpu<int>*/ , 0 /*warpPerspective_gpu<int2>*/ , 0 /*warpPerspective_gpu<int3>*/ , 0 /*warpPerspective_gpu<int4>*/ },\r
+ {warpPerspective_gpu<float> , 0 /*warpPerspective_gpu<float2>*/ , warpPerspective_gpu<float3> , warpPerspective_gpu<float4> }\r
+ };\r
+\r
+ const func_t func = funcs[src.depth()][src.channels() - 1];\r
+ CV_Assert(func != 0);\r
+\r
+ int gpuBorderType;\r
+ CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType));\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ float coeffs[3 * 3];\r
+ Mat coeffsMat(3, 3, CV_32F, (void*)coeffs);\r
+\r
+ if (flags & WARP_INVERSE_MAP)\r
+ M.convertTo(coeffsMat, coeffsMat.type());\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ invert(M, iM);\r
+ iM.convertTo(coeffsMat, coeffsMat.type());\r
+ }\r
+\r
+ Scalar_<float> borderValueFloat;\r
+ borderValueFloat = borderValue;\r
+\r
+ DeviceInfo info;\r
+ int cc = info.majorVersion() * 10 + info.minorVersion();\r
+\r
+ func(src, DevMem2Db(wholeSize.height, wholeSize.width, src.datastart, src.step), ofs.x, ofs.y, coeffs,\r
+ dst, interpolation, gpuBorderType, borderValueFloat.val, StreamAccessor::getStream(s), cc);\r
+ }\r
+}\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#ifndef __OPENCV_TEST_INTERPOLATION_HPP__\r
+#define __OPENCV_TEST_INTERPOLATION_HPP__\r
+\r
+template <typename T> T readVal(const cv::Mat& src, int y, int x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())\r
+{\r
+ if (border_type == cv::BORDER_CONSTANT)\r
+ return (y >= 0 && y < src.rows && x >= 0 && x < src.cols) ? src.at<T>(y, x * src.channels() + c) : cv::saturate_cast<T>(borderVal.val[c]);\r
+\r
+ return src.at<T>(cv::borderInterpolate(y, src.rows, border_type), cv::borderInterpolate(x, src.cols, border_type) * src.channels() + c);\r
+}\r
+\r
+template <typename T> struct NearestInterpolator\r
+{\r
+ static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())\r
+ {\r
+ return readVal<T>(src, cvFloor(y), cvFloor(x), c, border_type, borderVal);\r
+ }\r
+};\r
+\r
+template <typename T> struct LinearInterpolator\r
+{\r
+ static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())\r
+ {\r
+ x -= 0.5f;\r
+ y -= 0.5f;\r
+\r
+ int x1 = cvFloor(x);\r
+ int y1 = cvFloor(y);\r
+ int x2 = x1 + 1;\r
+ int y2 = y1 + 1;\r
+\r
+ float res = 0;\r
+\r
+ res += readVal<T>(src, y1, x1, c, border_type, borderVal) * ((x2 - x) * (y2 - y));\r
+ res += readVal<T>(src, y1, x2, c, border_type, borderVal) * ((x - x1) * (y2 - y));\r
+ res += readVal<T>(src, y2, x1, c, border_type, borderVal) * ((x2 - x) * (y - y1));\r
+ res += readVal<T>(src, y2, x2, c, border_type, borderVal) * ((x - x1) * (y - y1));\r
+\r
+ return cv::saturate_cast<T>(res);\r
+ }\r
+};\r
+\r
+template <typename T> struct CubicInterpolator\r
+{\r
+ static float getValue(float p[4], float x)\r
+ {\r
+ return p[1] + 0.5 * x * (p[2] - p[0] + x*(2.0*p[0] - 5.0*p[1] + 4.0*p[2] - p[3] + x*(3.0*(p[1] - p[2]) + p[3] - p[0])));\r
+ }\r
+\r
+ static float getValue(float p[4][4], float x, float y)\r
+ {\r
+ float arr[4];\r
+\r
+ arr[0] = getValue(p[0], x);\r
+ arr[1] = getValue(p[1], x);\r
+ arr[2] = getValue(p[2], x);\r
+ arr[3] = getValue(p[3], x);\r
+\r
+ return getValue(arr, y);\r
+ }\r
+\r
+ static T getValue(const cv::Mat& src, float y, float x, int c, int border_type, cv::Scalar borderVal = cv::Scalar())\r
+ {\r
+ int ix = cvRound(x);\r
+ int iy = cvRound(y);\r
+\r
+ float vals[4][4] =\r
+ {\r
+ {readVal<T>(src, iy - 2, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 2, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 2, ix, c, border_type, borderVal), readVal<T>(src, iy - 2, ix + 1, c, border_type, borderVal)},\r
+ {readVal<T>(src, iy - 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy - 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy - 1, ix, c, border_type, borderVal), readVal<T>(src, iy - 1, ix + 1, c, border_type, borderVal)},\r
+ {readVal<T>(src, iy , ix - 2, c, border_type, borderVal), readVal<T>(src, iy , ix - 1, c, border_type, borderVal), readVal<T>(src, iy , ix, c, border_type, borderVal), readVal<T>(src, iy , ix + 1, c, border_type, borderVal)},\r
+ {readVal<T>(src, iy + 1, ix - 2, c, border_type, borderVal), readVal<T>(src, iy + 1, ix - 1, c, border_type, borderVal), readVal<T>(src, iy + 1, ix, c, border_type, borderVal), readVal<T>(src, iy + 1, ix + 1, c, border_type, borderVal)},\r
+ };\r
+\r
+ return cv::saturate_cast<T>(getValue(vals, (x - ix + 2.0) / 4.0, (y - iy + 2.0) / 4.0));\r
+ }\r
+};\r
+\r
+#endif // __OPENCV_TEST_INTERPOLATION_HPP__\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
#include <iostream>\r
#include <fstream>\r
#include <sstream>\r
-#include <limits>\r
#include <string>\r
+#include <limits>\r
#include <algorithm>\r
#include <iterator>\r
+\r
#include "cvconfig.h"\r
#include "opencv2/core/core.hpp"\r
#include "opencv2/highgui/highgui.hpp"\r
#include "opencv2/ts/ts.hpp"\r
#include "opencv2/ts/ts_perf.hpp"\r
#include "opencv2/gpu/gpu.hpp"\r
-#include "test_gpu_base.hpp"\r
+\r
+#include "utility.hpp"\r
+#include "interpolation.hpp"\r
\r
#endif\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, \r
CV_32SC1, CV_32SC2, CV_32SC3, CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// subtract\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, \r
CV_32SC1, CV_32SC2, CV_32SC3, CV_32FC1, CV_32FC2, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// multiply\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC3, CV_16SC4, \r
CV_32SC1, CV_32SC3, CV_32FC1, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// divide\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC3, CV_16SC4, \r
CV_32SC1, CV_32SC3, CV_32FC1, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// transpose\r
INSTANTIATE_TEST_CASE_P(Arithm, Transpose, Combine(\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_8SC4, CV_16UC2, CV_16SC2, CV_32SC1, CV_32SC2, CV_32FC1, CV_32FC2, CV_64FC1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// absdiff\r
INSTANTIATE_TEST_CASE_P(Arithm, Absdiff, Combine(\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_16UC1, CV_32SC1, CV_32FC1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// abs\r
INSTANTIATE_TEST_CASE_P(Arithm, Abs, Combine(\r
ALL_DEVICES,\r
Values(CV_16SC1, CV_32FC1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// Sqr\r
INSTANTIATE_TEST_CASE_P(Arithm, Sqr, Combine(\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// Sqrt\r
INSTANTIATE_TEST_CASE_P(Arithm, Sqrt, Combine(\r
ALL_DEVICES,\r
Values(MatType(CV_32FC1)),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// compare\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_16UC1, CV_32SC1),\r
Values((int) cv::CMP_EQ, (int) cv::CMP_GT, (int) cv::CMP_GE, (int) cv::CMP_LT, (int) cv::CMP_LE, (int) cv::CMP_NE),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// meanStdDev\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, MeanStdDev, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// normDiff\r
INSTANTIATE_TEST_CASE_P(Arithm, NormDiff, Combine(\r
ALL_DEVICES,\r
Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// flip\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32SC1, CV_32SC3, CV_32SC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
Values((int)FLIP_BOTH, (int)FLIP_X, (int)FLIP_Y),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// LUT\r
INSTANTIATE_TEST_CASE_P(Arithm, LUT, Combine(\r
ALL_DEVICES,\r
Values(CV_8UC1, CV_8UC3),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// exp\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, Exp, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// pow\r
INSTANTIATE_TEST_CASE_P(Arithm, Pow, Combine(\r
ALL_DEVICES,\r
Values(CV_32F, CV_32FC3),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// log\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, Log, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// magnitude\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, Magnitude, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// phase\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, Phase, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// cartToPolar\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, CartToPolar, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// polarToCart\r
\r
INSTANTIATE_TEST_CASE_P(Arithm, PolarToCart, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// minMax\r
INSTANTIATE_TEST_CASE_P(Arithm, MinMax, Combine(\r
ALL_DEVICES,\r
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// minMaxLoc\r
INSTANTIATE_TEST_CASE_P(Arithm, MinMaxLoc, Combine(\r
ALL_DEVICES,\r
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////\r
// countNonZero\r
INSTANTIATE_TEST_CASE_P(Arithm, CountNonZero, Combine(\r
ALL_DEVICES,\r
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// sum\r
INSTANTIATE_TEST_CASE_P(Arithm, Sum, Combine(\r
ALL_DEVICES,\r
Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// bitwise\r
TYPES(CV_8U, CV_64F, 1, 1),\r
TYPES(CV_8U, CV_64F, 1, 1),\r
TYPES(CV_8U, CV_64F, 1, 1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// reduce\r
Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
Values(0, 1),\r
Values((int)CV_REDUCE_SUM, (int)CV_REDUCE_AVG, (int)CV_REDUCE_MAX, (int)CV_REDUCE_MIN),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// gemm\r
ALL_DEVICES,\r
Values(CV_32FC1, CV_32FC2),\r
Values(0, (int) cv::GEMM_1_T, (int) cv::GEMM_2_T, (int) cv::GEMM_3_T),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
#endif // HAVE_CUDA\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, int, Border, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
+ int border;\r
+ int borderType;\r
+ bool useRoi;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ border = GET_PARAM(3);\r
+ borderType = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(CopyMakeBorder, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Scalar val = randomScalar(0, 255);\r
+\r
+ cv::gpu::GpuMat dst = createMat(cv::Size(size.width + 2 * border, size.height + 2 * border), type, useRoi);\r
+ cv::gpu::copyMakeBorder(loadMat(src, useRoi), dst, border, border, border, border, borderType, val);\r
+\r
+ cv::Mat dst_gold;\r
+ cv::copyMakeBorder(src, dst_gold, border, border, border, border, borderType, val);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(\r
+ ALL_DEVICES, \r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ testing::Values(1, 10, 50),\r
+ testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_CONSTANT), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),\r
+ WHOLE_SUBMAT));\r
+\r
+#endif // HAVE_CUDA\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
INSTANTIATE_TEST_CASE_P(Filter, Blur, Combine(\r
ALL_DEVICES, \r
Values(cv::Size(3, 3), cv::Size(5, 5), cv::Size(7, 7)),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// sobel\r
Values(3, 5, 7), \r
Values(0, 1, 2),\r
Values(0, 1, 2),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// scharr\r
ALL_DEVICES, \r
Values(0, 1),\r
Values(0, 1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// gaussianBlur\r
INSTANTIATE_TEST_CASE_P(Filter, GaussianBlur, Combine(\r
ALL_DEVICES, \r
Values(cv::Size(3, 3), cv::Size(5, 5), cv::Size(7, 7), cv::Size(9, 9), cv::Size(11, 11), cv::Size(13, 13), cv::Size(15, 15), cv::Size(17, 17), cv::Size(19, 19), cv::Size(21, 21), cv::Size(23, 23), cv::Size(25, 25), cv::Size(27, 27), cv::Size(29, 29), cv::Size(31, 31)),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// laplacian\r
INSTANTIATE_TEST_CASE_P(Filter, Laplacian, Combine(\r
ALL_DEVICES,\r
Values(1, 3),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// erode\r
\r
INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// dilate\r
\r
INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(\r
ALL_DEVICES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// morphEx\r
INSTANTIATE_TEST_CASE_P(Filter, MorphEx, Combine(\r
ALL_DEVICES,\r
Values((int)cv::MORPH_OPEN, (int)cv::MORPH_CLOSE, (int)cv::MORPH_GRADIENT, (int)cv::MORPH_TOPHAT, (int)cv::MORPH_BLACKHAT),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// filter2D\r
INSTANTIATE_TEST_CASE_P(Filter, Filter2D, Combine(\r
ALL_DEVICES,\r
Values(3, 5, 7, 11, 13, 15),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
#endif // HAVE_CUDA\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "test_precomp.hpp"\r
-\r
-#ifdef HAVE_CUDA\r
-\r
-using namespace cvtest;\r
-using namespace testing;\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// threshold\r
-\r
-PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, MatType, ThreshOp, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int threshOp;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- double maxVal;\r
- double thresh;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- threshOp = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, type, 0.0, 127.0, false);\r
-\r
- maxVal = rng.uniform(20.0, 127.0);\r
- thresh = rng.uniform(0.0, maxVal);\r
-\r
- cv::threshold(src, dst_gold, thresh, maxVal, threshOp);\r
- }\r
-};\r
-\r
-TEST_P(Threshold, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::threshold(loadMat(src, useRoi), gpuRes, thresh, maxVal, threshOp);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_32FC1), \r
- Values((int)cv::THRESH_BINARY, (int)cv::THRESH_BINARY_INV, (int)cv::THRESH_TRUNC, (int)cv::THRESH_TOZERO, (int)cv::THRESH_TOZERO_INV),\r
- USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// resize\r
-\r
-PARAM_TEST_CASE(Resize, cv::gpu::DeviceInfo, MatType, Interpolation, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int interpolation;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
-\r
- cv::Mat dst_gold_up;\r
- cv::Mat dst_gold_down;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- interpolation = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, type, 0.0, CV_MAT_DEPTH(type) == CV_32F ? 1.0 : 255.0, false);\r
-\r
- cv::resize(src, dst_gold_up, cv::Size(), 2.0, 2.0, interpolation);\r
- cv::resize(src, dst_gold_down, cv::Size(), 0.5, 0.5, interpolation);\r
- }\r
-};\r
-\r
-TEST_P(Resize, Up)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::resize(loadMat(src, useRoi), gpuRes, cv::Size(), 2.0, 2.0, interpolation);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_SIMILAR(dst_gold_up, dst, 0.21);\r
-}\r
-\r
-TEST_P(Resize, Down)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::resize(loadMat(src, useRoi), gpuRes, cv::Size(), 0.5, 0.5, interpolation);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_SIMILAR(dst_gold_down, dst, 0.22);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Resize, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4), \r
- Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR, (int)cv::INTER_CUBIC),\r
- USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// remap\r
-\r
-PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, MatType, Interpolation, Border, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int interpolation;\r
- int borderType;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- cv::Mat xmap;\r
- cv::Mat ymap;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- interpolation = GET_PARAM(2);\r
- borderType = GET_PARAM(3);\r
- useRoi = GET_PARAM(4);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
-\r
- src = randomMat(rng, size, type, 0.0, 256.0, false);\r
-\r
- xmap = randomMat(rng, size, CV_32FC1, -20.0, src.cols + 20, false);\r
- ymap = randomMat(rng, size, CV_32FC1, -20.0, src.rows + 20, false);\r
- \r
- cv::remap(src, dst_gold, xmap, ymap, interpolation, borderType);\r
- }\r
-};\r
-\r
-TEST_P(Remap, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
- \r
- cv::gpu::remap(loadMat(src, useRoi), gpuRes, loadMat(xmap, useRoi), loadMat(ymap, useRoi), interpolation, borderType);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_SIMILAR(dst_gold, dst, 1e-1);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Remap, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- Values((int)cv::INTER_NEAREST, (int)cv::INTER_LINEAR, (int)cv::INTER_CUBIC),\r
- Values((int)cv::BORDER_REFLECT101, (int)cv::BORDER_REPLICATE, (int)cv::BORDER_CONSTANT, (int)cv::BORDER_REFLECT, (int)cv::BORDER_WRAP),\r
- USE_ROI));\r
- \r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// copyMakeBorder\r
-\r
-PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, MatType, Border, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int borderType;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- int top;\r
- int botton;\r
- int left;\r
- int right;\r
- cv::Scalar val;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- borderType = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, type, 0.0, 127.0, false);\r
- \r
- top = rng.uniform(1, 10);\r
- botton = rng.uniform(1, 10);\r
- left = rng.uniform(1, 10);\r
- right = rng.uniform(1, 10);\r
- val = cv::Scalar(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));\r
-\r
- cv::copyMakeBorder(src, dst_gold, top, botton, left, right, borderType, val);\r
- }\r
-};\r
-\r
-TEST_P(CopyMakeBorder, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::copyMakeBorder(loadMat(src, useRoi), gpuRes, top, botton, left, right, borderType, val);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_16SC1, CV_16SC3, CV_16SC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- Values((int)cv::BORDER_REFLECT101, (int)cv::BORDER_REPLICATE, (int)cv::BORDER_CONSTANT, (int)cv::BORDER_REFLECT, (int)cv::BORDER_WRAP),\r
- USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// warpAffine & warpPerspective\r
-\r
-PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, MatType, WarpFlags)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int flags;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- cv::Mat M;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- flags = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, type, 0.0, 127.0, false);\r
-\r
- static double reflect[2][3] = { {-1, 0, 0},\r
- { 0, -1, 0}};\r
- reflect[0][2] = size.width;\r
- reflect[1][2] = size.height;\r
- M = cv::Mat(2, 3, CV_64F, (void*)reflect); \r
-\r
- cv::warpAffine(src, dst_gold, M, src.size(), flags); \r
- }\r
-};\r
-\r
-TEST_P(WarpAffine, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::warpAffine(loadMat(src), gpuRes, M, src.size(), flags);\r
-\r
- gpuRes.download(dst);\r
-\r
- // Check inner parts (ignoring 1 pixel width border)\r
- cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);\r
- cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);\r
-\r
- EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC, \r
- (int) (cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), (int) (cv::INTER_LINEAR | cv::WARP_INVERSE_MAP), \r
- (int) (cv::INTER_CUBIC | cv::WARP_INVERSE_MAP))));\r
-\r
-PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, MatType, WarpFlags)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int flags;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- cv::Mat M;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- flags = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, type, 0.0, 127.0, false);\r
-\r
- static double reflect[3][3] = { { -1, 0, 0},\r
- { 0, -1, 0},\r
- { 0, 0, 1}};\r
- reflect[0][2] = size.width;\r
- reflect[1][2] = size.height;\r
- M = cv::Mat(3, 3, CV_64F, (void*)reflect);\r
-\r
- cv::warpPerspective(src, dst_gold, M, src.size(), flags); \r
- }\r
-};\r
-\r
-TEST_P(WarpPerspective, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::warpPerspective(loadMat(src), gpuRes, M, src.size(), flags);\r
-\r
- gpuRes.download(dst);\r
-\r
- // Check inner parts (ignoring 1 pixel width border)\r
- cv::Mat dst_gold_roi = dst_gold.rowRange(1, dst_gold.rows - 1).colRange(1, dst_gold.cols - 1);\r
- cv::Mat dst_roi = dst.rowRange(1, dst.rows - 1).colRange(1, dst.cols - 1);\r
-\r
- EXPECT_MAT_NEAR(dst_gold_roi, dst_roi, 1e-3);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- Values((int) cv::INTER_NEAREST, (int) cv::INTER_LINEAR, (int) cv::INTER_CUBIC, \r
- (int) (cv::INTER_NEAREST | cv::WARP_INVERSE_MAP), (int) (cv::INTER_LINEAR | cv::WARP_INVERSE_MAP), \r
- (int) (cv::INTER_CUBIC | cv::WARP_INVERSE_MAP))));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// integral\r
-\r
-PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- useRoi = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));\r
-\r
- src = randomMat(rng, size, CV_8UC1, 0.0, 255.0, false); \r
-\r
- cv::integral(src, dst_gold, CV_32S); \r
- }\r
-};\r
-\r
-TEST_P(Integral, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::integral(loadMat(src, useRoi), gpuRes);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Integral, Combine(\r
- ALL_DEVICES, \r
- USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// cvtColor\r
-\r
-PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, MatType, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- bool useRoi;\r
- \r
- cv::Mat img;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- useRoi = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::Mat imgBase = readImage("stereobm/aloe-L.png");\r
- ASSERT_FALSE(imgBase.empty());\r
-\r
- imgBase.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
- }\r
-};\r
-\r
-TEST_P(CvtColor, BGR2RGB)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2RGBA)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGBA);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGBA);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2BGRA)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGRA);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGRA);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2RGB)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2RGBA)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGBA);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGBA);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2GRAY)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2GRAY)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, GRAY2BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, GRAY2BGRA)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGRA, 4);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGRA, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2GRAY)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2GRAY)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2BGR565)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR565);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR565);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2BGR565)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR565);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR565);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5652BGR)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5652RGB)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2BGR565)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR565);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR565);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2BGR565)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR565);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR565);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5652BGRA)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGRA, 4);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGRA, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5652RGBA)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGBA, 4);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGBA, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, GRAY2BGR565)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR565);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR565);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5652GRAY)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2BGR555)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR555);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR555);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2BGR555)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR555);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR555);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5552BGR)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5552RGB)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2BGR555)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR555);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR555);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2BGR555)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR555);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR555);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5552BGRA)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGRA, 4);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGRA, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5552RGBA)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGBA, 4);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGBA, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, GRAY2BGR555)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR555);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR555);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR5552GRAY)\r
-{\r
- if (type != CV_8U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552GRAY);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552GRAY);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2XYZ)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2XYZ)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2XYZ4)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGRA2XYZ4)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, XYZ2BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, XYZ2RGB)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, XYZ42BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, XYZ42BGRA)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2YCrCb)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2YCrCb)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YCrCb);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YCrCb);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2YCrCb4)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2YCrCb4)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YCrCb2BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YCrCb2RGB)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YCrCb42RGB)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YCrCb42RGBA)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2HSV)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HSV)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HSV4)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2HSV4)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2HLS)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HLS)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HLS4)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2HLS4)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV2BGR)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV2RGB)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV42BGR)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV42BGRA)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS2BGR)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS2RGB)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS42RGB)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS42RGBA)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2HSV_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HSV_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HSV4_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2HSV4_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2HLS_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HLS_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2HLS4_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2HLS4_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV2BGR_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV2RGB_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV42RGB_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HSV42RGBA_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS2BGR_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS2RGB_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS42RGB_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, HLS42RGBA_FULL)\r
-{\r
- if (type == CV_16U)\r
- return;\r
-\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2YUV)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGB2YUV)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGB);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YUV2BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YUV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YUV42BGR)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YUV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YUV42BGRA)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2YUV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR, 4);\r
-\r
- cv::Mat channels[4];\r
- cv::split(src, channels);\r
- channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));\r
- cv::merge(channels, 4, src);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, YUV2RGB)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_RGB2YUV);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_YUV2RGB);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2RGB);\r
-\r
- gpuRes.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, BGR2YUV4)\r
-{\r
- cv::Mat src = img;\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-TEST_P(CvtColor, RGBA2YUV4)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);\r
- cv::Mat dst_gold;\r
- cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpuRes;\r
-\r
- cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV, 4);\r
-\r
- gpuRes.download(dst);\r
-\r
- ASSERT_EQ(4, dst.channels());\r
-\r
- cv::Mat channels[4];\r
- cv::split(dst, channels);\r
- cv::merge(channels, 3, dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8U, CV_16U, CV_32F),\r
- USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// swapChannels\r
-\r
-PARAM_TEST_CASE(SwapChannels, cv::gpu::DeviceInfo, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- bool useRoi;\r
- \r
- cv::Mat img;\r
- \r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- useRoi = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::Mat imgBase = readImage("stereobm/aloe-L.png");\r
- ASSERT_FALSE(imgBase.empty());\r
-\r
- cv::cvtColor(imgBase, img, cv::COLOR_BGR2BGRA);\r
-\r
- cv::cvtColor(img, dst_gold, cv::COLOR_BGRA2RGBA);\r
- }\r
-};\r
-\r
-TEST_P(SwapChannels, Accuracy)\r
-{\r
- cv::gpu::GpuMat gpuImage = loadMat(img, useRoi);\r
-\r
- const int dstOrder[] = {2, 1, 0, 3};\r
- cv::gpu::swapChannels(gpuImage, dstOrder);\r
-\r
- cv::Mat dst;\r
- gpuImage.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, Combine(ALL_DEVICES, USE_ROI));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// histograms\r
-\r
-struct HistEven : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- \r
- cv::Mat hsv;\r
- \r
- int hbins;\r
- float hranges[2];\r
-\r
- cv::Mat hist_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::Mat img = readImage("stereobm/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
- \r
- cv::cvtColor(img, hsv, CV_BGR2HSV);\r
-\r
- hbins = 30;\r
-\r
- hranges[0] = 0;\r
- hranges[1] = 180;\r
-\r
- int histSize[] = {hbins};\r
- const float* ranges[] = {hranges};\r
-\r
- cv::MatND histnd;\r
-\r
- int channels[] = {0};\r
- cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);\r
-\r
- hist_gold = histnd;\r
- hist_gold = hist_gold.t();\r
- hist_gold.convertTo(hist_gold, CV_32S);\r
- }\r
-};\r
-\r
-TEST_P(HistEven, Accuracy)\r
-{\r
- cv::Mat hist;\r
- \r
- std::vector<cv::gpu::GpuMat> srcs;\r
- cv::gpu::split(loadMat(hsv), srcs);\r
-\r
- cv::gpu::GpuMat gpuHist;\r
-\r
- cv::gpu::histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);\r
-\r
- gpuHist.download(hist);\r
-\r
- EXPECT_MAT_NEAR(hist_gold, hist, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, HistEven, ALL_DEVICES);\r
-\r
-struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- cv::Mat hist_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
- \r
- src = randomMat(rng, size, CV_8UC1, 0, 255, false);\r
-\r
- hist_gold.create(1, 256, CV_32SC1);\r
- hist_gold.setTo(cv::Scalar::all(0));\r
-\r
- int* hist = hist_gold.ptr<int>();\r
- for (int y = 0; y < src.rows; ++y)\r
- {\r
- const uchar* src_row = src.ptr(y);\r
-\r
- for (int x = 0; x < src.cols; ++x)\r
- ++hist[src_row[x]];\r
- }\r
- }\r
-};\r
-\r
-TEST_P(CalcHist, Accuracy)\r
-{\r
- cv::Mat hist;\r
- \r
- cv::gpu::GpuMat gpuHist;\r
-\r
- cv::gpu::calcHist(loadMat(src), gpuHist);\r
-\r
- gpuHist.download(hist);\r
-\r
- EXPECT_MAT_NEAR(hist_gold, hist, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, ALL_DEVICES);\r
-\r
-struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));\r
- \r
- src = randomMat(rng, size, CV_8UC1, 0, 255, false);\r
-\r
- cv::equalizeHist(src, dst_gold);\r
- }\r
-};\r
-\r
-TEST_P(EqualizeHist, Accuracy)\r
-{\r
- cv::Mat dst;\r
- \r
- cv::gpu::GpuMat gpuDst;\r
-\r
- cv::gpu::equalizeHist(loadMat(src), gpuDst);\r
-\r
- gpuDst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 3.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, ALL_DEVICES);\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// cornerHarris\r
-\r
-PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, Border, int, int)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int borderType;\r
- int blockSize;\r
- int apertureSize;\r
-\r
- cv::Mat src;\r
- double k;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- borderType = GET_PARAM(2);\r
- blockSize = GET_PARAM(3);\r
- apertureSize = GET_PARAM(4); \r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
- ASSERT_FALSE(img.empty());\r
-\r
- img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
-\r
- k = rng.uniform(0.1, 0.9);\r
-\r
- cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);\r
- }\r
-};\r
-\r
-TEST_P(CornerHarris, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::cornerHarris(loadMat(src), dev_dst, blockSize, apertureSize, k, borderType);\r
-\r
- dev_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.02);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_32FC1), \r
- Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),\r
- Values(3, 5, 7),\r
- Values(0, 3, 5, 7)));\r
-\r
-///////////////////////////////////////////////////////////////////////////////////////////////////////\r
-// cornerMinEigen\r
-\r
-PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, Border, int, int)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int borderType;\r
- int blockSize;\r
- int apertureSize;\r
-\r
- cv::Mat src;\r
-\r
- cv::Mat dst_gold;\r
- \r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- borderType = GET_PARAM(2);\r
- blockSize = GET_PARAM(3);\r
- apertureSize = GET_PARAM(4); \r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
- ASSERT_FALSE(img.empty());\r
-\r
- img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);\r
-\r
- cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);\r
- }\r
-};\r
-\r
-TEST_P(CornerMinEigen, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::cornerMinEigenVal(loadMat(src), dev_dst, blockSize, apertureSize, borderType);\r
-\r
- dev_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.02);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigen, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_32FC1), \r
- Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),\r
- Values(3, 5, 7),\r
- Values(0, 3, 5, 7)));\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// ColumnSum\r
-\r
-struct ColumnSum : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));\r
-\r
- src = randomMat(rng, size, CV_32F, 0.0, 1.0, false);\r
- }\r
-};\r
-\r
-TEST_P(ColumnSum, Accuracy)\r
-{\r
- cv::Mat dst;\r
- \r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::columnSum(loadMat(src), dev_dst);\r
-\r
- dev_dst.download(dst);\r
-\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- float gold = src.at<float>(0, j);\r
- float res = dst.at<float>(0, j);\r
- ASSERT_NEAR(res, gold, 0.5);\r
- }\r
-\r
- for (int i = 1; i < src.rows; ++i)\r
- {\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);\r
- float res = dst.at<float>(i, j);\r
- ASSERT_NEAR(res, gold, 0.5);\r
- }\r
- }\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, ALL_DEVICES);\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Norm\r
-\r
-PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, MatType, NormCode, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- int normType;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat src;\r
-\r
- double gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- normType = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));\r
-\r
- src = randomMat(rng, size, type, 0.0, 10.0, false);\r
-\r
- gold = cv::norm(src, normType);\r
- }\r
-};\r
-\r
-TEST_P(Norm, Accuracy)\r
-{\r
- double res = cv::gpu::norm(loadMat(src, useRoi), normType);\r
-\r
- ASSERT_NEAR(res, gold, 0.5);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Norm, Combine(\r
- ALL_DEVICES, \r
- TYPES(CV_8U, CV_32F, 1, 1),\r
- Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2),\r
- USE_ROI));\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// reprojectImageTo3D\r
-\r
-PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat disp;\r
- cv::Mat Q;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- useRoi = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(rng.uniform(100, 500), rng.uniform(100, 500));\r
-\r
- disp = randomMat(rng, size, CV_8UC1, 5.0, 30.0, false);\r
-\r
- Q = randomMat(rng, cv::Size(4, 4), CV_32FC1, 0.1, 1.0, false);\r
-\r
- cv::reprojectImageTo3D(disp, dst_gold, Q, false);\r
- }\r
-};\r
-\r
-TEST_P(ReprojectImageTo3D, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat gpures;\r
-\r
- cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), gpures, Q);\r
-\r
- gpures.download(dst);\r
-\r
- ASSERT_EQ(dst_gold.size(), dst.size());\r
-\r
- for (int y = 0; y < dst_gold.rows; ++y)\r
- {\r
- const cv::Vec3f* cpu_row = dst_gold.ptr<cv::Vec3f>(y);\r
- const cv::Vec4f* gpu_row = dst.ptr<cv::Vec4f>(y);\r
-\r
- for (int x = 0; x < dst_gold.cols; ++x)\r
- {\r
- cv::Vec3f gold = cpu_row[x];\r
- cv::Vec4f res = gpu_row[x];\r
-\r
- ASSERT_NEAR(res[0], gold[0], 1e-5);\r
- ASSERT_NEAR(res[1], gold[1], 1e-5);\r
- ASSERT_NEAR(res[2], gold[2], 1e-5);\r
- }\r
- }\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, Combine(ALL_DEVICES, USE_ROI));\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// meanShift\r
-\r
-struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- \r
- cv::Mat rgba;\r
-\r
- int spatialRad;\r
- int colorRad;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::Mat img = readImage("meanshift/cones.png");\r
- ASSERT_FALSE(img.empty());\r
- \r
- cv::cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
- spatialRad = 30;\r
- colorRad = 30;\r
- }\r
-};\r
-\r
-TEST_P(MeanShift, Filtering)\r
-{\r
- cv::Mat img_template;\r
- \r
- if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
- img_template = readImage("meanshift/con_result.png");\r
- else\r
- img_template = readImage("meanshift/con_result_CC1X.png");\r
-\r
- ASSERT_FALSE(img_template.empty());\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::meanShiftFiltering(loadMat(rgba), dev_dst, spatialRad, colorRad);\r
-\r
- dev_dst.download(dst);\r
-\r
- ASSERT_EQ(CV_8UC4, dst.type());\r
-\r
- cv::Mat result;\r
- cv::cvtColor(dst, result, CV_BGRA2BGR);\r
-\r
- EXPECT_MAT_NEAR(img_template, result, 0.0);\r
-}\r
-\r
-TEST_P(MeanShift, Proc)\r
-{\r
- cv::Mat spmap_template;\r
- cv::FileStorage fs;\r
-\r
- if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
- fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);\r
- else\r
- fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);\r
-\r
- ASSERT_TRUE(fs.isOpened());\r
-\r
- fs["spmap"] >> spmap_template;\r
-\r
- ASSERT_TRUE(!rgba.empty() && !spmap_template.empty());\r
-\r
- cv::Mat rmap_filtered;\r
- cv::Mat rmap;\r
- cv::Mat spmap;\r
-\r
- cv::gpu::GpuMat d_rmap_filtered;\r
- cv::gpu::meanShiftFiltering(loadMat(rgba), d_rmap_filtered, spatialRad, colorRad);\r
-\r
- cv::gpu::GpuMat d_rmap;\r
- cv::gpu::GpuMat d_spmap;\r
- cv::gpu::meanShiftProc(loadMat(rgba), d_rmap, d_spmap, spatialRad, colorRad);\r
-\r
- d_rmap_filtered.download(rmap_filtered);\r
- d_rmap.download(rmap);\r
- d_spmap.download(spmap);\r
-\r
- ASSERT_EQ(CV_8UC4, rmap.type());\r
- \r
- EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0); \r
- EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MeanShift, ALL_DEVICES);\r
-\r
-PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, int)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int minsize;\r
- \r
- cv::Mat rgba;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- minsize = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::Mat img = readImage("meanshift/cones.png");\r
- ASSERT_FALSE(img.empty());\r
- \r
- cv::cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
- std::ostringstream path;\r
- path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;\r
- if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))\r
- path << ".png";\r
- else\r
- path << "_CC1X.png";\r
-\r
- dst_gold = readImage(path.str());\r
- ASSERT_FALSE(dst_gold.empty());\r
- }\r
-};\r
-\r
-TEST_P(MeanShiftSegmentation, Regression)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::meanShiftSegmentation(loadMat(rgba), dst, 10, 10, minsize);\r
-\r
- cv::Mat dst_rgb;\r
- cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);\r
-\r
- EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-3);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, Combine(\r
- ALL_DEVICES,\r
- Values(0, 4, 20, 84, 340, 1364)));\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// matchTemplate\r
-\r
-PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, int, TemplateMethod)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int cn;\r
- int method;\r
-\r
- int n, m, h, w;\r
- cv::Mat image, templ;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- cn = GET_PARAM(1);\r
- method = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- n = rng.uniform(30, 100);\r
- m = rng.uniform(30, 100);\r
- h = rng.uniform(5, n - 1);\r
- w = rng.uniform(5, m - 1);\r
-\r
- image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);\r
- templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);\r
-\r
- cv::matchTemplate(image, templ, dst_gold, method);\r
- }\r
-};\r
-\r
-TEST_P(MatchTemplate8U, Regression)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);\r
-\r
- dev_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 5 * h * w * 1e-4);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate8U, Combine(\r
- ALL_DEVICES,\r
- Range(1, 5), \r
- Values((int)cv::TM_SQDIFF, (int) cv::TM_SQDIFF_NORMED, (int) cv::TM_CCORR, (int) cv::TM_CCORR_NORMED, (int) cv::TM_CCOEFF, (int) cv::TM_CCOEFF_NORMED)));\r
-\r
-\r
-PARAM_TEST_CASE(MatchTemplate32F, cv::gpu::DeviceInfo, int, TemplateMethod)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int cn;\r
- int method;\r
-\r
- int n, m, h, w;\r
- cv::Mat image, templ;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- cn = GET_PARAM(1);\r
- method = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- n = rng.uniform(30, 100);\r
- m = rng.uniform(30, 100);\r
- h = rng.uniform(5, n - 1);\r
- w = rng.uniform(5, m - 1);\r
-\r
- image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);\r
- templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);\r
-\r
- cv::matchTemplate(image, templ, dst_gold, method);\r
- }\r
-};\r
-\r
-TEST_P(MatchTemplate32F, Regression)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);\r
-\r
- dev_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.25 * h * w * 1e-4);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate32F, Combine(\r
- ALL_DEVICES, \r
- Range(1, 5), \r
- Values((int) cv::TM_SQDIFF, (int) cv::TM_CCORR)));\r
-\r
-\r
-PARAM_TEST_CASE(MatchTemplateBlackSource, cv::gpu::DeviceInfo, TemplateMethod)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int method;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- method = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- }\r
-};\r
-\r
-TEST_P(MatchTemplateBlackSource, Accuracy)\r
-{\r
- cv::Mat image = readImage("matchtemplate/black.png");\r
- ASSERT_FALSE(image.empty());\r
-\r
- cv::Mat pattern = readImage("matchtemplate/cat.png");\r
- ASSERT_FALSE(pattern.empty());\r
-\r
- cv::Point maxLocGold = cv::Point(284, 12);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, method);\r
-\r
- dev_dst.download(dst);\r
-\r
- double maxValue;\r
- cv::Point maxLoc;\r
- cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);\r
-\r
- ASSERT_EQ(maxLocGold, maxLoc);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplateBlackSource, Combine(\r
- ALL_DEVICES,\r
- Values((int) cv::TM_CCOEFF_NORMED, (int) cv::TM_CCORR_NORMED)));\r
-\r
-\r
-PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED, cv::gpu::DeviceInfo, std::pair<std::string, std::string>)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- std::string imageName;\r
- std::string patternName;\r
-\r
- cv::Mat image, pattern;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- imageName = GET_PARAM(1).first;\r
- patternName = GET_PARAM(1).second;\r
-\r
- image = readImage(imageName);\r
- ASSERT_FALSE(image.empty());\r
-\r
- pattern = readImage(patternName);\r
- ASSERT_FALSE(pattern.empty());\r
- }\r
-};\r
-\r
-TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)\r
-{\r
- cv::Mat dstGold;\r
- cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);\r
-\r
- double minValGold, maxValGold;\r
- cv::Point minLocGold, maxLocGold;\r
- cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);\r
-\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat dev_dst;\r
-\r
- cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, CV_TM_CCOEFF_NORMED);\r
-\r
- dev_dst.download(dst);\r
-\r
- cv::Point minLoc, maxLoc;\r
- double minVal, maxVal;\r
- cv::minMaxLoc(dst, &minVal, &maxVal, &minLoc, &maxLoc);\r
-\r
- ASSERT_EQ(minLocGold, minLoc);\r
- ASSERT_EQ(maxLocGold, maxLoc);\r
- ASSERT_LE(maxVal, 1.);\r
- ASSERT_GE(minVal, -1.);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_CCOEF_NORMED, Combine(\r
- ALL_DEVICES,\r
- Values(std::make_pair(std::string("matchtemplate/source-0.png"), std::string("matchtemplate/target-0.png")))));\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-// MulSpectrums\r
-\r
-PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, DftFlags)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int flag;\r
-\r
- cv::Mat a, b; \r
-\r
- virtual void SetUp() \r
- {\r
- devInfo = GET_PARAM(0);\r
- flag = GET_PARAM(1);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- a = randomMat(rng, cv::Size(rng.uniform(100, 200), rng.uniform(100, 200)), CV_32FC2, 0.0, 10.0, false);\r
- b = randomMat(rng, a.size(), CV_32FC2, 0.0, 10.0, false);\r
- }\r
-};\r
-\r
-TEST_P(MulSpectrums, Simple)\r
-{\r
- cv::Mat c_gold;\r
- cv::mulSpectrums(a, b, c_gold, flag, false);\r
- \r
- cv::Mat c;\r
-\r
- cv::gpu::GpuMat d_c;\r
-\r
- cv::gpu::mulSpectrums(loadMat(a), loadMat(b), d_c, flag, false);\r
-\r
- d_c.download(c);\r
-\r
- EXPECT_MAT_NEAR(c_gold, c, 1e-4);\r
-}\r
-\r
-TEST_P(MulSpectrums, Scaled)\r
-{\r
- float scale = 1.f / a.size().area();\r
-\r
- cv::Mat c_gold;\r
- cv::mulSpectrums(a, b, c_gold, flag, false);\r
- c_gold.convertTo(c_gold, c_gold.type(), scale);\r
-\r
- cv::Mat c;\r
-\r
- cv::gpu::GpuMat d_c;\r
-\r
- cv::gpu::mulAndScaleSpectrums(loadMat(a), loadMat(b), d_c, flag, scale, false);\r
-\r
- d_c.download(c);\r
-\r
- EXPECT_MAT_NEAR(c_gold, c, 1e-4);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, Combine(\r
- ALL_DEVICES, \r
- Values(0, (int) cv::DFT_ROWS)));\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-// Dft\r
-\r
-struct Dft : TestWithParam<cv::gpu::DeviceInfo>\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
-\r
- virtual void SetUp() \r
- {\r
- devInfo = GetParam();\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- }\r
-};\r
-\r
-\r
-void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)\r
-{\r
- SCOPED_TRACE(hint);\r
-\r
- cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
-\r
- cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC2, 0.0, 10.0, false);\r
-\r
- cv::Mat b_gold;\r
- cv::dft(a, b_gold, flags);\r
-\r
- cv::gpu::GpuMat d_b;\r
- cv::gpu::GpuMat d_b_data;\r
- if (inplace)\r
- {\r
- d_b_data.create(1, a.size().area(), CV_32FC2);\r
- d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
- }\r
- cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), flags);\r
-\r
- EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());\r
- ASSERT_EQ(CV_32F, d_b.depth());\r
- ASSERT_EQ(2, d_b.channels());\r
- EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);\r
-}\r
-\r
-TEST_P(Dft, C2C)\r
-{\r
- cv::RNG& rng = cvtest::TS::ptr()->get_rng();\r
-\r
- int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;\r
-\r
- for (int i = 0; i < 2; ++i)\r
- {\r
- bool inplace = i != 0;\r
-\r
- testC2C("no flags", cols, rows, 0, inplace);\r
- testC2C("no flags 0 1", cols, rows + 1, 0, inplace);\r
- testC2C("no flags 1 0", cols, rows + 1, 0, inplace);\r
- testC2C("no flags 1 1", cols + 1, rows, 0, inplace);\r
- testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);\r
- testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);\r
- testC2C("single col", 1, rows, 0, inplace);\r
- testC2C("single row", cols, 1, 0, inplace);\r
- testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);\r
- testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);\r
- testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);\r
- testC2C("size 1 2", 1, 2, 0, inplace);\r
- testC2C("size 2 1", 2, 1, 0, inplace);\r
- }\r
-}\r
-\r
-void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)\r
-{\r
- SCOPED_TRACE(hint);\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC1, 0.0, 10.0, false);\r
-\r
- cv::gpu::GpuMat d_b, d_c;\r
- cv::gpu::GpuMat d_b_data, d_c_data;\r
- if (inplace)\r
- {\r
- if (a.cols == 1)\r
- {\r
- d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);\r
- d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
- }\r
- else\r
- {\r
- d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);\r
- d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());\r
- }\r
- d_c_data.create(1, a.size().area(), CV_32F);\r
- d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());\r
- }\r
-\r
- cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);\r
- cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);\r
- \r
- EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());\r
- EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());\r
- ASSERT_EQ(CV_32F, d_c.depth());\r
- ASSERT_EQ(1, d_c.channels());\r
-\r
- cv::Mat c(d_c);\r
- EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);\r
-}\r
-\r
-TEST_P(Dft, R2CThenC2R)\r
-{\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;\r
-\r
- testR2CThenC2R("sanity", cols, rows, false);\r
- testR2CThenC2R("sanity 0 1", cols, rows + 1, false);\r
- testR2CThenC2R("sanity 1 0", cols + 1, rows, false);\r
- testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);\r
- testR2CThenC2R("single col", 1, rows, false);\r
- testR2CThenC2R("single col 1", 1, rows + 1, false);\r
- testR2CThenC2R("single row", cols, 1, false);\r
- testR2CThenC2R("single row 1", cols + 1, 1, false);\r
-\r
- testR2CThenC2R("sanity", cols, rows, true);\r
- testR2CThenC2R("sanity 0 1", cols, rows + 1, true);\r
- testR2CThenC2R("sanity 1 0", cols + 1, rows, true);\r
- testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);\r
- testR2CThenC2R("single row", cols, 1, true);\r
- testR2CThenC2R("single row 1", cols + 1, 1, true);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Dft, ALL_DEVICES);\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-// blend\r
-\r
-template <typename T> \r
-void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)\r
-{\r
- result_gold.create(img1.size(), img1.type());\r
-\r
- int cn = img1.channels();\r
-\r
- for (int y = 0; y < img1.rows; ++y)\r
- {\r
- const float* weights1_row = weights1.ptr<float>(y);\r
- const float* weights2_row = weights2.ptr<float>(y);\r
- const T* img1_row = img1.ptr<T>(y);\r
- const T* img2_row = img2.ptr<T>(y);\r
- T* result_gold_row = result_gold.ptr<T>(y);\r
-\r
- for (int x = 0; x < img1.cols * cn; ++x)\r
- {\r
- float w1 = weights1_row[x / cn];\r
- float w2 = weights2_row[x / cn];\r
- result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));\r
- }\r
- }\r
-}\r
-\r
-PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, MatType, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- bool useRoi;\r
-\r
- cv::Size size;\r
- cv::Mat img1;\r
- cv::Mat img2;\r
- cv::Mat weights1;\r
- cv::Mat weights2;\r
-\r
- cv::Mat result_gold;\r
-\r
- virtual void SetUp() \r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- useRoi = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- size = cv::Size(200 + randInt(rng) % 1000, 200 + randInt(rng) % 1000);\r
-\r
- int depth = CV_MAT_DEPTH(type);\r
-\r
- img1 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);\r
- img2 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);\r
- weights1 = randomMat(rng, size, CV_32F, 0, 1, false);\r
- weights2 = randomMat(rng, size, CV_32F, 0, 1, false);\r
- \r
- if (depth == CV_8U)\r
- blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);\r
- else\r
- blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);\r
- }\r
-};\r
-\r
-TEST_P(Blend, Accuracy)\r
-{\r
- cv::Mat result;\r
-\r
- cv::gpu::GpuMat d_result;\r
-\r
- cv::gpu::blendLinear(loadMat(img1, useRoi), loadMat(img2, useRoi), loadMat(weights1, useRoi), loadMat(weights2, useRoi), d_result);\r
-\r
- d_result.download(result);\r
-\r
- EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.0 : 1e-5);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Blend, Combine(\r
- ALL_DEVICES,\r
- testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
-\r
-////////////////////////////////////////////////////////\r
-// pyrDown\r
-\r
-PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi)\r
-{ \r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- bool useRoi;\r
-\r
- cv::Mat src;\r
-\r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- useRoi = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Size size(rng.uniform(100, 200), rng.uniform(100, 200));\r
-\r
- src = randomMat(rng, size, type, 0.0, 255.0, false);\r
- \r
- cv::pyrDown(src, dst_gold);\r
- }\r
-};\r
-\r
-TEST_P(PyrDown, Accuracy)\r
-{ \r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat d_dst;\r
- \r
- cv::gpu::pyrDown(loadMat(src, useRoi), d_dst);\r
- \r
- d_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
-\r
-////////////////////////////////////////////////////////\r
-// pyrUp\r
-\r
-PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, MatType, UseRoi)\r
-{ \r
- cv::gpu::DeviceInfo devInfo;\r
- int type;\r
- bool useRoi;\r
-\r
- cv::Mat src;\r
- \r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- type = GET_PARAM(1);\r
- useRoi = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));\r
-\r
- src = randomMat(rng, size, type, 0.0, 255.0, false);\r
- \r
- cv::pyrUp(src, dst_gold);\r
- }\r
-};\r
-\r
-TEST_P(PyrUp, Accuracy)\r
-{ \r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat d_dst;\r
- \r
- cv::gpu::pyrUp(loadMat(src, useRoi), d_dst, cv::BORDER_REFLECT);\r
- \r
- d_dst.download(dst);\r
-\r
- // results differs only on border left and top border due different border extrapolation type\r
- EXPECT_MAT_NEAR(dst_gold(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), dst(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), 1.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, Combine(\r
- ALL_DEVICES, \r
- Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),\r
- USE_ROI));\r
-\r
-////////////////////////////////////////////////////////\r
-// Canny\r
-\r
-PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)\r
-{\r
- cv::gpu::DeviceInfo devInfo;\r
- int apperture_size;\r
- bool L2gradient;\r
- bool useRoi;\r
- \r
- cv::Mat img;\r
-\r
- double low_thresh;\r
- double high_thresh;\r
-\r
- cv::Mat edges_gold;\r
-\r
- virtual void SetUp() \r
- {\r
- devInfo = GET_PARAM(0);\r
- apperture_size = GET_PARAM(1);\r
- L2gradient = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);\r
- ASSERT_FALSE(img.empty()); \r
-\r
- low_thresh = 50.0;\r
- high_thresh = 100.0;\r
- \r
- cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, L2gradient);\r
- }\r
-};\r
-\r
-TEST_P(Canny, Accuracy)\r
-{\r
- cv::Mat edges;\r
-\r
- cv::gpu::GpuMat d_edges;\r
-\r
- cv::gpu::Canny(loadMat(img, useRoi), d_edges, low_thresh, high_thresh, apperture_size, L2gradient);\r
-\r
- d_edges.download(edges);\r
-\r
- EXPECT_MAT_SIMILAR(edges_gold, edges, 1.0);\r
-}\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(\r
- DEVICES(cv::gpu::SHARED_ATOMICS),\r
- Values(3, 5),\r
- Values(false, true),\r
- USE_ROI));\r
-\r
-////////////////////////////////////////////////////////\r
-// convolve\r
-\r
-namespace\r
-{\r
- void convolveDFT(const cv::Mat& A, const cv::Mat& B, cv::Mat& C, bool ccorr = false)\r
- {\r
- // reallocate the output array if needed\r
- C.create(std::abs(A.rows - B.rows) + 1, std::abs(A.cols - B.cols) + 1, A.type());\r
- Size dftSize;\r
-\r
- // compute the size of DFT transform\r
- dftSize.width = cv::getOptimalDFTSize(A.cols + B.cols - 1);\r
- dftSize.height = cv::getOptimalDFTSize(A.rows + B.rows - 1);\r
-\r
- // allocate temporary buffers and initialize them with 0\92s\r
- cv::Mat tempA(dftSize, A.type(), cv::Scalar::all(0));\r
- cv::Mat tempB(dftSize, B.type(), cv::Scalar::all(0));\r
-\r
- // copy A and B to the top-left corners of tempA and tempB, respectively\r
- cv::Mat roiA(tempA, cv::Rect(0, 0, A.cols, A.rows));\r
- A.copyTo(roiA);\r
- cv::Mat roiB(tempB, cv::Rect(0, 0, B.cols, B.rows));\r
- B.copyTo(roiB);\r
-\r
- // now transform the padded A & B in-place;\r
- // use "nonzeroRows" hint for faster processing\r
- cv::dft(tempA, tempA, 0, A.rows);\r
- cv::dft(tempB, tempB, 0, B.rows);\r
-\r
- // multiply the spectrums;\r
- // the function handles packed spectrum representations well\r
- cv::mulSpectrums(tempA, tempB, tempA, 0, ccorr);\r
-\r
- // transform the product back from the frequency domain.\r
- // Even though all the result rows will be non-zero,\r
- // you need only the first C.rows of them, and thus you\r
- // pass nonzeroRows == C.rows\r
- cv::dft(tempA, tempA, cv::DFT_INVERSE + cv::DFT_SCALE, C.rows);\r
-\r
- // now copy the result back to C.\r
- tempA(cv::Rect(0, 0, C.cols, C.rows)).copyTo(C);\r
- }\r
-}\r
-\r
-PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, int, bool)\r
-{ \r
- cv::gpu::DeviceInfo devInfo;\r
- int ksize;\r
- bool ccorr;\r
- \r
- cv::Mat src;\r
- cv::Mat kernel;\r
- \r
- cv::Mat dst_gold;\r
-\r
- virtual void SetUp()\r
- {\r
- devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- ccorr = GET_PARAM(2);\r
-\r
- cv::gpu::setDevice(devInfo.deviceID());\r
- \r
- cv::RNG& rng = TS::ptr()->get_rng();\r
-\r
- cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));\r
-\r
- src = randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);\r
- kernel = randomMat(rng, cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0, false);\r
- \r
- convolveDFT(src, kernel, dst_gold, ccorr);\r
- }\r
-};\r
-\r
-TEST_P(Convolve, Accuracy)\r
-{\r
- cv::Mat dst;\r
-\r
- cv::gpu::GpuMat d_dst;\r
-\r
- cv::gpu::convolve(loadMat(src), loadMat(kernel), d_dst, ccorr);\r
-\r
- d_dst.download(dst);\r
-\r
- EXPECT_MAT_NEAR(dst, dst_gold, 1e-1);\r
-}\r
-\r
-\r
-INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, Combine(\r
- ALL_DEVICES, \r
- Values(3, 7, 11, 17, 19, 23, 45),\r
- Bool()));\r
-\r
-#endif // HAVE_CUDA\r
+/*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.
+//
+//
+// Intel License Agreement
+// For Open Source Computer Vision Library
+//
+// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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"
+
+#ifdef HAVE_CUDA
+
+using namespace cvtest;
+using namespace testing;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// integral
+
+PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ bool useRoi;
+
+ cv::Size size;
+ cv::Mat src;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ useRoi = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(20, 150), rng.uniform(20, 150));
+
+ src = randomMat(rng, size, CV_8UC1, 0.0, 255.0, false);
+
+ cv::integral(src, dst_gold, CV_32S);
+ }
+};
+
+TEST_P(Integral, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::integral(loadMat(src, useRoi), gpuRes);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Integral, Combine(
+ ALL_DEVICES,
+ WHOLE_SUBMAT));
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// cvtColor
+
+PARAM_TEST_CASE(CvtColor, cv::gpu::DeviceInfo, MatType, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ bool useRoi;
+
+ cv::Mat img;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ useRoi = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::Mat imgBase = readImage("stereobm/aloe-L.png");
+ ASSERT_FALSE(imgBase.empty());
+
+ imgBase.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
+ }
+};
+
+TEST_P(CvtColor, BGR2RGB)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR2RGBA)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2RGBA);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2RGBA);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR2BGRA)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGRA);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGRA);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2RGB)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2RGBA)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2RGBA);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2RGBA);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR2GRAY)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGB2GRAY)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, GRAY2BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, GRAY2BGRA)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGRA, 4);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGRA, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2GRAY)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGBA2GRAY)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2BGR565)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR565);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR565);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, RGB2BGR565)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR565);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR565);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5652BGR)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5652RGB)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2BGR565)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR565);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR565);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, RGBA2BGR565)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR565);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR565);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5652BGRA)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652BGRA, 4);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652BGRA, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5652RGBA)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652RGBA, 4);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652RGBA, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, GRAY2BGR565)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR565);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR565);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5652GRAY)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR565);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5652GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5652GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR2BGR555)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2BGR555);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2BGR555);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, RGB2BGR555)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2BGR555);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2BGR555);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5552BGR)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5552RGB)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGRA2BGR555)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGRA2BGR555);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGRA2BGR555);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, RGBA2BGR555)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGBA2BGR555);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGBA2BGR555);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5552BGRA)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552BGRA, 4);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552BGRA, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5552RGBA)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552RGBA, 4);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552RGBA, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, GRAY2BGR555)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2GRAY);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_GRAY2BGR555);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_GRAY2BGR555);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR5552GRAY)
+{
+ if (type != CV_8U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGR555);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR5552GRAY);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR5552GRAY);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+TEST_P(CvtColor, BGR2XYZ)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGB2XYZ)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2XYZ4)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGRA2XYZ4)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2BGRA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2XYZ);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2XYZ, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, XYZ2BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, XYZ2RGB)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, XYZ42BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, XYZ42BGRA)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2XYZ);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_XYZ2BGR, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_XYZ2BGR, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2YCrCb)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGB2YCrCb)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YCrCb);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YCrCb);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2YCrCb4)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGBA2YCrCb4)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YCrCb, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YCrCb2BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YCrCb2RGB)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YCrCb42RGB)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YCrCb42RGBA)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YCrCb);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YCrCb2RGB, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YCrCb2RGB, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2HSV)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HSV)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HSV4)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGBA2HSV4)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, BGR2HLS)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HLS)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HLS4)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGBA2HLS4)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV2BGR)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV2RGB)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV42BGR)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV42BGRA)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS2BGR)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS2RGB)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS42RGB)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS42RGBA)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, BGR2HSV_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HSV_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HSV_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HSV_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HSV4_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGBA2HSV4_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HSV_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HSV_FULL, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, BGR2HLS_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2HLS_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2HLS_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HLS_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGB2HLS4_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, RGBA2HLS4_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2HLS_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2HLS_FULL, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV2BGR_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2BGR_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2BGR_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV2RGB_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV42RGB_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HSV42RGBA_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HSV_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HSV2RGB_FULL, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HSV2RGB_FULL, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS2BGR_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2BGR_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2BGR_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS2RGB_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS42RGB_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, HLS42RGBA_FULL)
+{
+ if (type == CV_16U)
+ return;
+
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2HLS_FULL);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_HLS2RGB_FULL, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_HLS2RGB_FULL, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, type == CV_32F ? 1e-2 : 1);
+}
+
+TEST_P(CvtColor, BGR2YUV)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGB2YUV)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGB);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YUV2BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YUV42BGR)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YUV42BGRA)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2YUV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YUV2BGR, 4);
+
+ cv::Mat channels[4];
+ cv::split(src, channels);
+ channels[3] = cv::Mat(src.size(), type, cv::Scalar::all(0));
+ cv::merge(channels, 4, src);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2BGR, 4);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, YUV2RGB)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_RGB2YUV);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_YUV2RGB);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_YUV2RGB);
+
+ gpuRes.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, BGR2YUV4)
+{
+ cv::Mat src = img;
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YUV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_BGR2YUV, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+TEST_P(CvtColor, RGBA2YUV4)
+{
+ cv::Mat src;
+ cv::cvtColor(img, src, cv::COLOR_BGR2RGBA);
+ cv::Mat dst_gold;
+ cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YUV);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuRes;
+
+ cv::gpu::cvtColor(loadMat(src, useRoi), gpuRes, cv::COLOR_RGB2YUV, 4);
+
+ gpuRes.download(dst);
+
+ ASSERT_EQ(4, dst.channels());
+
+ cv::Mat channels[4];
+ cv::split(dst, channels);
+ cv::merge(channels, 3, dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, Combine(
+ ALL_DEVICES,
+ Values(CV_8U, CV_16U, CV_32F),
+ WHOLE_SUBMAT));
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// swapChannels
+
+PARAM_TEST_CASE(SwapChannels, cv::gpu::DeviceInfo, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ bool useRoi;
+
+ cv::Mat img;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ useRoi = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::Mat imgBase = readImage("stereobm/aloe-L.png");
+ ASSERT_FALSE(imgBase.empty());
+
+ cv::cvtColor(imgBase, img, cv::COLOR_BGR2BGRA);
+
+ cv::cvtColor(img, dst_gold, cv::COLOR_BGRA2RGBA);
+ }
+};
+
+TEST_P(SwapChannels, Accuracy)
+{
+ cv::gpu::GpuMat gpuImage = loadMat(img, useRoi);
+
+ const int dstOrder[] = {2, 1, 0, 3};
+ cv::gpu::swapChannels(gpuImage, dstOrder);
+
+ cv::Mat dst;
+ gpuImage.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, SwapChannels, Combine(ALL_DEVICES, WHOLE_SUBMAT));
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// histograms
+
+struct HistEven : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ cv::Mat hsv;
+
+ int hbins;
+ float hranges[2];
+
+ cv::Mat hist_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::Mat img = readImage("stereobm/aloe-L.png");
+ ASSERT_FALSE(img.empty());
+
+ cv::cvtColor(img, hsv, CV_BGR2HSV);
+
+ hbins = 30;
+
+ hranges[0] = 0;
+ hranges[1] = 180;
+
+ int histSize[] = {hbins};
+ const float* ranges[] = {hranges};
+
+ cv::MatND histnd;
+
+ int channels[] = {0};
+ cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);
+
+ hist_gold = histnd;
+ hist_gold = hist_gold.t();
+ hist_gold.convertTo(hist_gold, CV_32S);
+ }
+};
+
+TEST_P(HistEven, Accuracy)
+{
+ cv::Mat hist;
+
+ std::vector<cv::gpu::GpuMat> srcs;
+ cv::gpu::split(loadMat(hsv), srcs);
+
+ cv::gpu::GpuMat gpuHist;
+
+ cv::gpu::histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);
+
+ gpuHist.download(hist);
+
+ EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, HistEven, ALL_DEVICES);
+
+struct CalcHist : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ cv::Size size;
+ cv::Mat src;
+ cv::Mat hist_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
+
+ src = randomMat(rng, size, CV_8UC1, 0, 255, false);
+
+ hist_gold.create(1, 256, CV_32SC1);
+ hist_gold.setTo(cv::Scalar::all(0));
+
+ int* hist = hist_gold.ptr<int>();
+ for (int y = 0; y < src.rows; ++y)
+ {
+ const uchar* src_row = src.ptr(y);
+
+ for (int x = 0; x < src.cols; ++x)
+ ++hist[src_row[x]];
+ }
+ }
+};
+
+TEST_P(CalcHist, Accuracy)
+{
+ cv::Mat hist;
+
+ cv::gpu::GpuMat gpuHist;
+
+ cv::gpu::calcHist(loadMat(src), gpuHist);
+
+ gpuHist.download(hist);
+
+ EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, CalcHist, ALL_DEVICES);
+
+struct EqualizeHist : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ cv::Size size;
+ cv::Mat src;
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(100, 200), rng.uniform(100, 200));
+
+ src = randomMat(rng, size, CV_8UC1, 0, 255, false);
+
+ cv::equalizeHist(src, dst_gold);
+ }
+};
+
+TEST_P(EqualizeHist, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpuDst;
+
+ cv::gpu::equalizeHist(loadMat(src), gpuDst);
+
+ gpuDst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 3.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, ALL_DEVICES);
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// cornerHarris
+
+PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, Border, int, int)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ int borderType;
+ int blockSize;
+ int apertureSize;
+
+ cv::Mat src;
+ double k;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ borderType = GET_PARAM(2);
+ blockSize = GET_PARAM(3);
+ apertureSize = GET_PARAM(4);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
+ ASSERT_FALSE(img.empty());
+
+ img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
+
+ k = rng.uniform(0.1, 0.9);
+
+ cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
+ }
+};
+
+TEST_P(CornerHarris, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::cornerHarris(loadMat(src), dev_dst, blockSize, apertureSize, k, borderType);
+
+ dev_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, Combine(
+ ALL_DEVICES,
+ Values(CV_8UC1, CV_32FC1),
+ Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),
+ Values(3, 5, 7),
+ Values(0, 3, 5, 7)));
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////
+// cornerMinEigen
+
+PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, Border, int, int)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ int borderType;
+ int blockSize;
+ int apertureSize;
+
+ cv::Mat src;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ borderType = GET_PARAM(2);
+ blockSize = GET_PARAM(3);
+ apertureSize = GET_PARAM(4);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Mat img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
+ ASSERT_FALSE(img.empty());
+
+ img.convertTo(src, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
+
+ cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
+ }
+};
+
+TEST_P(CornerMinEigen, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::cornerMinEigenVal(loadMat(src), dev_dst, blockSize, apertureSize, borderType);
+
+ dev_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigen, Combine(
+ ALL_DEVICES,
+ Values(CV_8UC1, CV_32FC1),
+ Values((int) cv::BORDER_REFLECT101, (int) cv::BORDER_REPLICATE, (int) cv::BORDER_REFLECT),
+ Values(3, 5, 7),
+ Values(0, 3, 5, 7)));
+
+////////////////////////////////////////////////////////////////////////
+// ColumnSum
+
+struct ColumnSum : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ cv::Size size;
+ cv::Mat src;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
+
+ src = randomMat(rng, size, CV_32F, 0.0, 1.0, false);
+ }
+};
+
+TEST_P(ColumnSum, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::columnSum(loadMat(src), dev_dst);
+
+ dev_dst.download(dst);
+
+ for (int j = 0; j < src.cols; ++j)
+ {
+ float gold = src.at<float>(0, j);
+ float res = dst.at<float>(0, j);
+ ASSERT_NEAR(res, gold, 0.5);
+ }
+
+ for (int i = 1; i < src.rows; ++i)
+ {
+ for (int j = 0; j < src.cols; ++j)
+ {
+ float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);
+ float res = dst.at<float>(i, j);
+ ASSERT_NEAR(res, gold, 0.5);
+ }
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, ColumnSum, ALL_DEVICES);
+
+////////////////////////////////////////////////////////////////////////
+// Norm
+
+PARAM_TEST_CASE(Norm, cv::gpu::DeviceInfo, MatType, NormCode, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ int normType;
+ bool useRoi;
+
+ cv::Size size;
+ cv::Mat src;
+
+ double gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ normType = GET_PARAM(2);
+ useRoi = GET_PARAM(3);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(100, 400), rng.uniform(100, 400));
+
+ src = randomMat(rng, size, type, 0.0, 10.0, false);
+
+ gold = cv::norm(src, normType);
+ }
+};
+
+TEST_P(Norm, Accuracy)
+{
+ double res = cv::gpu::norm(loadMat(src, useRoi), normType);
+
+ ASSERT_NEAR(res, gold, 0.5);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Norm, Combine(
+ ALL_DEVICES,
+ TYPES(CV_8U, CV_32F, 1, 1),
+ Values((int) cv::NORM_INF, (int) cv::NORM_L1, (int) cv::NORM_L2),
+ WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////////////////////////////
+// reprojectImageTo3D
+
+PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ bool useRoi;
+
+ cv::Size size;
+ cv::Mat disp;
+ cv::Mat Q;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ useRoi = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(rng.uniform(100, 500), rng.uniform(100, 500));
+
+ disp = randomMat(rng, size, CV_8UC1, 5.0, 30.0, false);
+
+ Q = randomMat(rng, cv::Size(4, 4), CV_32FC1, 0.1, 1.0, false);
+
+ cv::reprojectImageTo3D(disp, dst_gold, Q, false);
+ }
+};
+
+TEST_P(ReprojectImageTo3D, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat gpures;
+
+ cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), gpures, Q);
+
+ gpures.download(dst);
+
+ ASSERT_EQ(dst_gold.size(), dst.size());
+
+ for (int y = 0; y < dst_gold.rows; ++y)
+ {
+ const cv::Vec3f* cpu_row = dst_gold.ptr<cv::Vec3f>(y);
+ const cv::Vec4f* gpu_row = dst.ptr<cv::Vec4f>(y);
+
+ for (int x = 0; x < dst_gold.cols; ++x)
+ {
+ cv::Vec3f gold = cpu_row[x];
+ cv::Vec4f res = gpu_row[x];
+
+ ASSERT_NEAR(res[0], gold[0], 1e-5);
+ ASSERT_NEAR(res[1], gold[1], 1e-5);
+ ASSERT_NEAR(res[2], gold[2], 1e-5);
+ }
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, Combine(ALL_DEVICES, WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////////////////////////////
+// meanShift
+
+struct MeanShift : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ cv::Mat rgba;
+
+ int spatialRad;
+ int colorRad;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::Mat img = readImage("meanshift/cones.png");
+ ASSERT_FALSE(img.empty());
+
+ cv::cvtColor(img, rgba, CV_BGR2BGRA);
+
+ spatialRad = 30;
+ colorRad = 30;
+ }
+};
+
+TEST_P(MeanShift, Filtering)
+{
+ cv::Mat img_template;
+
+ if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
+ img_template = readImage("meanshift/con_result.png");
+ else
+ img_template = readImage("meanshift/con_result_CC1X.png");
+
+ ASSERT_FALSE(img_template.empty());
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::meanShiftFiltering(loadMat(rgba), dev_dst, spatialRad, colorRad);
+
+ dev_dst.download(dst);
+
+ ASSERT_EQ(CV_8UC4, dst.type());
+
+ cv::Mat result;
+ cv::cvtColor(dst, result, CV_BGRA2BGR);
+
+ EXPECT_MAT_NEAR(img_template, result, 0.0);
+}
+
+TEST_P(MeanShift, Proc)
+{
+ cv::Mat spmap_template;
+ cv::FileStorage fs;
+
+ if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
+ fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
+ else
+ fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);
+
+ ASSERT_TRUE(fs.isOpened());
+
+ fs["spmap"] >> spmap_template;
+
+ ASSERT_TRUE(!rgba.empty() && !spmap_template.empty());
+
+ cv::Mat rmap_filtered;
+ cv::Mat rmap;
+ cv::Mat spmap;
+
+ cv::gpu::GpuMat d_rmap_filtered;
+ cv::gpu::meanShiftFiltering(loadMat(rgba), d_rmap_filtered, spatialRad, colorRad);
+
+ cv::gpu::GpuMat d_rmap;
+ cv::gpu::GpuMat d_spmap;
+ cv::gpu::meanShiftProc(loadMat(rgba), d_rmap, d_spmap, spatialRad, colorRad);
+
+ d_rmap_filtered.download(rmap_filtered);
+ d_rmap.download(rmap);
+ d_spmap.download(spmap);
+
+ ASSERT_EQ(CV_8UC4, rmap.type());
+
+ EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
+ EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MeanShift, ALL_DEVICES);
+
+PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, int)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int minsize;
+
+ cv::Mat rgba;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ minsize = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::Mat img = readImage("meanshift/cones.png");
+ ASSERT_FALSE(img.empty());
+
+ cv::cvtColor(img, rgba, CV_BGR2BGRA);
+
+ std::ostringstream path;
+ path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
+ if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
+ path << ".png";
+ else
+ path << "_CC1X.png";
+
+ dst_gold = readImage(path.str());
+ ASSERT_FALSE(dst_gold.empty());
+ }
+};
+
+TEST_P(MeanShiftSegmentation, Regression)
+{
+ cv::Mat dst;
+
+ cv::gpu::meanShiftSegmentation(loadMat(rgba), dst, 10, 10, minsize);
+
+ cv::Mat dst_rgb;
+ cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);
+
+ EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-3);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftSegmentation, Combine(
+ ALL_DEVICES,
+ Values(0, 4, 20, 84, 340, 1364)));
+
+////////////////////////////////////////////////////////////////////////////////
+// matchTemplate
+
+PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, int, TemplateMethod)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int cn;
+ int method;
+
+ int n, m, h, w;
+ cv::Mat image, templ;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ cn = GET_PARAM(1);
+ method = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ n = rng.uniform(30, 100);
+ m = rng.uniform(30, 100);
+ h = rng.uniform(5, n - 1);
+ w = rng.uniform(5, m - 1);
+
+ image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);
+ templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_8U, cn), 1.0, 10.0, false);
+
+ cv::matchTemplate(image, templ, dst_gold, method);
+ }
+};
+
+TEST_P(MatchTemplate8U, Regression)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);
+
+ dev_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 5 * h * w * 1e-4);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate8U, Combine(
+ ALL_DEVICES,
+ Range(1, 5),
+ Values((int)cv::TM_SQDIFF, (int) cv::TM_SQDIFF_NORMED, (int) cv::TM_CCORR, (int) cv::TM_CCORR_NORMED, (int) cv::TM_CCOEFF, (int) cv::TM_CCOEFF_NORMED)));
+
+
+PARAM_TEST_CASE(MatchTemplate32F, cv::gpu::DeviceInfo, int, TemplateMethod)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int cn;
+ int method;
+
+ int n, m, h, w;
+ cv::Mat image, templ;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ cn = GET_PARAM(1);
+ method = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ n = rng.uniform(30, 100);
+ m = rng.uniform(30, 100);
+ h = rng.uniform(5, n - 1);
+ w = rng.uniform(5, m - 1);
+
+ image = randomMat(rng, cv::Size(m, n), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);
+ templ = randomMat(rng, cv::Size(w, h), CV_MAKETYPE(CV_32F, cn), 0.001, 1.0, false);
+
+ cv::matchTemplate(image, templ, dst_gold, method);
+ }
+};
+
+TEST_P(MatchTemplate32F, Regression)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dev_dst, method);
+
+ dev_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.25 * h * w * 1e-4);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate32F, Combine(
+ ALL_DEVICES,
+ Range(1, 5),
+ Values((int) cv::TM_SQDIFF, (int) cv::TM_CCORR)));
+
+
+PARAM_TEST_CASE(MatchTemplateBlackSource, cv::gpu::DeviceInfo, TemplateMethod)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int method;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ method = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+ }
+};
+
+TEST_P(MatchTemplateBlackSource, Accuracy)
+{
+ cv::Mat image = readImage("matchtemplate/black.png");
+ ASSERT_FALSE(image.empty());
+
+ cv::Mat pattern = readImage("matchtemplate/cat.png");
+ ASSERT_FALSE(pattern.empty());
+
+ cv::Point maxLocGold = cv::Point(284, 12);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, method);
+
+ dev_dst.download(dst);
+
+ double maxValue;
+ cv::Point maxLoc;
+ cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);
+
+ ASSERT_EQ(maxLocGold, maxLoc);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplateBlackSource, Combine(
+ ALL_DEVICES,
+ Values((int) cv::TM_CCOEFF_NORMED, (int) cv::TM_CCORR_NORMED)));
+
+
+PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED, cv::gpu::DeviceInfo, std::pair<std::string, std::string>)
+{
+ cv::gpu::DeviceInfo devInfo;
+ std::string imageName;
+ std::string patternName;
+
+ cv::Mat image, pattern;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ imageName = GET_PARAM(1).first;
+ patternName = GET_PARAM(1).second;
+
+ image = readImage(imageName);
+ ASSERT_FALSE(image.empty());
+
+ pattern = readImage(patternName);
+ ASSERT_FALSE(pattern.empty());
+ }
+};
+
+TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)
+{
+ cv::Mat dstGold;
+ cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);
+
+ double minValGold, maxValGold;
+ cv::Point minLocGold, maxLocGold;
+ cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);
+
+ cv::Mat dst;
+
+ cv::gpu::GpuMat dev_dst;
+
+ cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), dev_dst, CV_TM_CCOEFF_NORMED);
+
+ dev_dst.download(dst);
+
+ cv::Point minLoc, maxLoc;
+ double minVal, maxVal;
+ cv::minMaxLoc(dst, &minVal, &maxVal, &minLoc, &maxLoc);
+
+ ASSERT_EQ(minLocGold, minLoc);
+ ASSERT_EQ(maxLocGold, maxLoc);
+ ASSERT_LE(maxVal, 1.);
+ ASSERT_GE(minVal, -1.);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_CCOEF_NORMED, Combine(
+ ALL_DEVICES,
+ Values(std::make_pair(std::string("matchtemplate/source-0.png"), std::string("matchtemplate/target-0.png")))));
+
+////////////////////////////////////////////////////////////////////////////
+// MulSpectrums
+
+PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, DftFlags)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int flag;
+
+ cv::Mat a, b;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ flag = GET_PARAM(1);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ a = randomMat(rng, cv::Size(rng.uniform(100, 200), rng.uniform(100, 200)), CV_32FC2, 0.0, 10.0, false);
+ b = randomMat(rng, a.size(), CV_32FC2, 0.0, 10.0, false);
+ }
+};
+
+TEST_P(MulSpectrums, Simple)
+{
+ cv::Mat c_gold;
+ cv::mulSpectrums(a, b, c_gold, flag, false);
+
+ cv::Mat c;
+
+ cv::gpu::GpuMat d_c;
+
+ cv::gpu::mulSpectrums(loadMat(a), loadMat(b), d_c, flag, false);
+
+ d_c.download(c);
+
+ EXPECT_MAT_NEAR(c_gold, c, 1e-4);
+}
+
+TEST_P(MulSpectrums, Scaled)
+{
+ float scale = 1.f / a.size().area();
+
+ cv::Mat c_gold;
+ cv::mulSpectrums(a, b, c_gold, flag, false);
+ c_gold.convertTo(c_gold, c_gold.type(), scale);
+
+ cv::Mat c;
+
+ cv::gpu::GpuMat d_c;
+
+ cv::gpu::mulAndScaleSpectrums(loadMat(a), loadMat(b), d_c, flag, scale, false);
+
+ d_c.download(c);
+
+ EXPECT_MAT_NEAR(c_gold, c, 1e-4);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, Combine(
+ ALL_DEVICES,
+ Values(0, (int) cv::DFT_ROWS)));
+
+////////////////////////////////////////////////////////////////////////////
+// Dft
+
+struct Dft : TestWithParam<cv::gpu::DeviceInfo>
+{
+ cv::gpu::DeviceInfo devInfo;
+
+ virtual void SetUp()
+ {
+ devInfo = GetParam();
+
+ cv::gpu::setDevice(devInfo.deviceID());
+ }
+};
+
+
+void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace)
+{
+ SCOPED_TRACE(hint);
+
+ cv::RNG& rng = cvtest::TS::ptr()->get_rng();
+
+ cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC2, 0.0, 10.0, false);
+
+ cv::Mat b_gold;
+ cv::dft(a, b_gold, flags);
+
+ cv::gpu::GpuMat d_b;
+ cv::gpu::GpuMat d_b_data;
+ if (inplace)
+ {
+ d_b_data.create(1, a.size().area(), CV_32FC2);
+ d_b = cv::gpu::GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
+ }
+ cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), flags);
+
+ EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
+ ASSERT_EQ(CV_32F, d_b.depth());
+ ASSERT_EQ(2, d_b.channels());
+ EXPECT_MAT_NEAR(b_gold, cv::Mat(d_b), rows * cols * 1e-4);
+}
+
+TEST_P(Dft, C2C)
+{
+ cv::RNG& rng = cvtest::TS::ptr()->get_rng();
+
+ int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;
+
+ for (int i = 0; i < 2; ++i)
+ {
+ bool inplace = i != 0;
+
+ testC2C("no flags", cols, rows, 0, inplace);
+ testC2C("no flags 0 1", cols, rows + 1, 0, inplace);
+ testC2C("no flags 1 0", cols, rows + 1, 0, inplace);
+ testC2C("no flags 1 1", cols + 1, rows, 0, inplace);
+ testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);
+ testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);
+ testC2C("single col", 1, rows, 0, inplace);
+ testC2C("single row", cols, 1, 0, inplace);
+ testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);
+ testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);
+ testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);
+ testC2C("size 1 2", 1, 2, 0, inplace);
+ testC2C("size 2 1", 2, 1, 0, inplace);
+ }
+}
+
+void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
+{
+ SCOPED_TRACE(hint);
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Mat a = randomMat(rng, cv::Size(cols, rows), CV_32FC1, 0.0, 10.0, false);
+
+ cv::gpu::GpuMat d_b, d_c;
+ cv::gpu::GpuMat d_b_data, d_c_data;
+ if (inplace)
+ {
+ if (a.cols == 1)
+ {
+ d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);
+ d_b = cv::gpu::GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());
+ }
+ else
+ {
+ d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);
+ d_b = cv::gpu::GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());
+ }
+ d_c_data.create(1, a.size().area(), CV_32F);
+ d_c = cv::gpu::GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());
+ }
+
+ cv::gpu::dft(loadMat(a), d_b, cv::Size(cols, rows), 0);
+ cv::gpu::dft(d_b, d_c, cv::Size(cols, rows), cv::DFT_REAL_OUTPUT | cv::DFT_SCALE);
+
+ EXPECT_TRUE(!inplace || d_b.ptr() == d_b_data.ptr());
+ EXPECT_TRUE(!inplace || d_c.ptr() == d_c_data.ptr());
+ ASSERT_EQ(CV_32F, d_c.depth());
+ ASSERT_EQ(1, d_c.channels());
+
+ cv::Mat c(d_c);
+ EXPECT_MAT_NEAR(a, c, rows * cols * 1e-5);
+}
+
+TEST_P(Dft, R2CThenC2R)
+{
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ int cols = 2 + rng.next() % 100, rows = 2 + rng.next() % 100;
+
+ testR2CThenC2R("sanity", cols, rows, false);
+ testR2CThenC2R("sanity 0 1", cols, rows + 1, false);
+ testR2CThenC2R("sanity 1 0", cols + 1, rows, false);
+ testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);
+ testR2CThenC2R("single col", 1, rows, false);
+ testR2CThenC2R("single col 1", 1, rows + 1, false);
+ testR2CThenC2R("single row", cols, 1, false);
+ testR2CThenC2R("single row 1", cols + 1, 1, false);
+
+ testR2CThenC2R("sanity", cols, rows, true);
+ testR2CThenC2R("sanity 0 1", cols, rows + 1, true);
+ testR2CThenC2R("sanity 1 0", cols + 1, rows, true);
+ testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);
+ testR2CThenC2R("single row", cols, 1, true);
+ testR2CThenC2R("single row 1", cols + 1, 1, true);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Dft, ALL_DEVICES);
+
+////////////////////////////////////////////////////////////////////////////
+// blend
+
+template <typename T>
+void blendLinearGold(const cv::Mat& img1, const cv::Mat& img2, const cv::Mat& weights1, const cv::Mat& weights2, cv::Mat& result_gold)
+{
+ result_gold.create(img1.size(), img1.type());
+
+ int cn = img1.channels();
+
+ for (int y = 0; y < img1.rows; ++y)
+ {
+ const float* weights1_row = weights1.ptr<float>(y);
+ const float* weights2_row = weights2.ptr<float>(y);
+ const T* img1_row = img1.ptr<T>(y);
+ const T* img2_row = img2.ptr<T>(y);
+ T* result_gold_row = result_gold.ptr<T>(y);
+
+ for (int x = 0; x < img1.cols * cn; ++x)
+ {
+ float w1 = weights1_row[x / cn];
+ float w2 = weights2_row[x / cn];
+ result_gold_row[x] = static_cast<T>((img1_row[x] * w1 + img2_row[x] * w2) / (w1 + w2 + 1e-5f));
+ }
+ }
+}
+
+PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, MatType, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ bool useRoi;
+
+ cv::Size size;
+ cv::Mat img1;
+ cv::Mat img2;
+ cv::Mat weights1;
+ cv::Mat weights2;
+
+ cv::Mat result_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ useRoi = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ size = cv::Size(200 + randInt(rng) % 1000, 200 + randInt(rng) % 1000);
+
+ int depth = CV_MAT_DEPTH(type);
+
+ img1 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);
+ img2 = randomMat(rng, size, type, 0.0, depth == CV_8U ? 255.0 : 1.0, false);
+ weights1 = randomMat(rng, size, CV_32F, 0, 1, false);
+ weights2 = randomMat(rng, size, CV_32F, 0, 1, false);
+
+ if (depth == CV_8U)
+ blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);
+ else
+ blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
+ }
+};
+
+TEST_P(Blend, Accuracy)
+{
+ cv::Mat result;
+
+ cv::gpu::GpuMat d_result;
+
+ cv::gpu::blendLinear(loadMat(img1, useRoi), loadMat(img2, useRoi), loadMat(weights1, useRoi), loadMat(weights2, useRoi), d_result);
+
+ d_result.download(result);
+
+ EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.0 : 1e-5);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Blend, Combine(
+ ALL_DEVICES,
+ testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4),
+ WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////
+// pyrDown
+
+PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, MatType, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ bool useRoi;
+
+ cv::Mat src;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ useRoi = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Size size(rng.uniform(100, 200), rng.uniform(100, 200));
+
+ src = randomMat(rng, size, type, 0.0, 255.0, false);
+
+ cv::pyrDown(src, dst_gold);
+ }
+};
+
+TEST_P(PyrDown, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat d_dst;
+
+ cv::gpu::pyrDown(loadMat(src, useRoi), d_dst);
+
+ d_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, Combine(
+ ALL_DEVICES,
+ Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),
+ WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////
+// pyrUp
+
+PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, MatType, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int type;
+ bool useRoi;
+
+ cv::Mat src;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ type = GET_PARAM(1);
+ useRoi = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));
+
+ src = randomMat(rng, size, type, 0.0, 255.0, false);
+
+ cv::pyrUp(src, dst_gold);
+ }
+};
+
+TEST_P(PyrUp, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat d_dst;
+
+ cv::gpu::pyrUp(loadMat(src, useRoi), d_dst, cv::BORDER_REFLECT);
+
+ d_dst.download(dst);
+
+ // results differs only on border left and top border due different border extrapolation type
+ EXPECT_MAT_NEAR(dst_gold(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), dst(cv::Range(1, dst_gold.rows), cv::Range(1, dst_gold.cols)), src.depth() == CV_32F ? 1e-4 : 1.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, Combine(
+ ALL_DEVICES,
+ Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_16UC3, CV_16UC4, CV_32FC1, CV_32FC3, CV_32FC4),
+ WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////
+// Canny
+
+PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, int, bool, UseRoi)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int apperture_size;
+ bool L2gradient;
+ bool useRoi;
+
+ cv::Mat img;
+
+ double low_thresh;
+ double high_thresh;
+
+ cv::Mat edges_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ apperture_size = GET_PARAM(1);
+ L2gradient = GET_PARAM(2);
+ useRoi = GET_PARAM(3);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ img = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
+ ASSERT_FALSE(img.empty());
+
+ low_thresh = 50.0;
+ high_thresh = 100.0;
+
+ cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, L2gradient);
+ }
+};
+
+TEST_P(Canny, Accuracy)
+{
+ cv::Mat edges;
+
+ cv::gpu::GpuMat d_edges;
+
+ cv::gpu::Canny(loadMat(img, useRoi), d_edges, low_thresh, high_thresh, apperture_size, L2gradient);
+
+ d_edges.download(edges);
+
+ EXPECT_MAT_SIMILAR(edges_gold, edges, 1.0);
+}
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
+ DEVICES(cv::gpu::SHARED_ATOMICS),
+ Values(3, 5),
+ Values(false, true),
+ WHOLE_SUBMAT));
+
+////////////////////////////////////////////////////////
+// convolve
+
+namespace
+{
+ void convolveDFT(const cv::Mat& A, const cv::Mat& B, cv::Mat& C, bool ccorr = false)
+ {
+ // reallocate the output array if needed
+ C.create(std::abs(A.rows - B.rows) + 1, std::abs(A.cols - B.cols) + 1, A.type());
+ Size dftSize;
+
+ // compute the size of DFT transform
+ dftSize.width = cv::getOptimalDFTSize(A.cols + B.cols - 1);
+ dftSize.height = cv::getOptimalDFTSize(A.rows + B.rows - 1);
+
+ // allocate temporary buffers and initialize them with 0s
+ cv::Mat tempA(dftSize, A.type(), cv::Scalar::all(0));
+ cv::Mat tempB(dftSize, B.type(), cv::Scalar::all(0));
+
+ // copy A and B to the top-left corners of tempA and tempB, respectively
+ cv::Mat roiA(tempA, cv::Rect(0, 0, A.cols, A.rows));
+ A.copyTo(roiA);
+ cv::Mat roiB(tempB, cv::Rect(0, 0, B.cols, B.rows));
+ B.copyTo(roiB);
+
+ // now transform the padded A & B in-place;
+ // use "nonzeroRows" hint for faster processing
+ cv::dft(tempA, tempA, 0, A.rows);
+ cv::dft(tempB, tempB, 0, B.rows);
+
+ // multiply the spectrums;
+ // the function handles packed spectrum representations well
+ cv::mulSpectrums(tempA, tempB, tempA, 0, ccorr);
+
+ // transform the product back from the frequency domain.
+ // Even though all the result rows will be non-zero,
+ // you need only the first C.rows of them, and thus you
+ // pass nonzeroRows == C.rows
+ cv::dft(tempA, tempA, cv::DFT_INVERSE + cv::DFT_SCALE, C.rows);
+
+ // now copy the result back to C.
+ tempA(cv::Rect(0, 0, C.cols, C.rows)).copyTo(C);
+ }
+}
+
+PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, int, bool)
+{
+ cv::gpu::DeviceInfo devInfo;
+ int ksize;
+ bool ccorr;
+
+ cv::Mat src;
+ cv::Mat kernel;
+
+ cv::Mat dst_gold;
+
+ virtual void SetUp()
+ {
+ devInfo = GET_PARAM(0);
+ ksize = GET_PARAM(1);
+ ccorr = GET_PARAM(2);
+
+ cv::gpu::setDevice(devInfo.deviceID());
+
+ cv::RNG& rng = TS::ptr()->get_rng();
+
+ cv::Size size(rng.uniform(200, 400), rng.uniform(200, 400));
+
+ src = randomMat(rng, size, CV_32FC1, 0.0, 100.0, false);
+ kernel = randomMat(rng, cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0, false);
+
+ convolveDFT(src, kernel, dst_gold, ccorr);
+ }
+};
+
+TEST_P(Convolve, Accuracy)
+{
+ cv::Mat dst;
+
+ cv::gpu::GpuMat d_dst;
+
+ cv::gpu::convolve(loadMat(src), loadMat(kernel), d_dst, ccorr);
+
+ d_dst.download(dst);
+
+ EXPECT_MAT_NEAR(dst, dst_gold, 1e-1);
+}
+
+
+INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, Combine(
+ ALL_DEVICES,
+ Values(3, 7, 11, 17, 19, 23, 45),
+ Bool()));
+
+#endif // HAVE_CUDA
+
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
INSTANTIATE_TEST_CASE_P(MatOp, Merge, Combine(\r
ALL_DEVICES, \r
ALL_TYPES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// split\r
INSTANTIATE_TEST_CASE_P(MatOp, Split, Combine(\r
ALL_DEVICES, \r
ALL_TYPES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// split_merge_consistency\r
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, Combine(\r
ALL_DEVICES, \r
ALL_TYPES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// copyTo\r
INSTANTIATE_TEST_CASE_P(MatOp, CopyTo, Combine(\r
ALL_DEVICES, \r
ALL_TYPES,\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// convertTo\r
ALL_DEVICES, \r
TYPES(CV_8U, CV_64F, 1, 1),\r
TYPES(CV_8U, CV_64F, 1, 1),\r
- USE_ROI));\r
+ WHOLE_SUBMAT));\r
\r
////////////////////////////////////////////////////////////////////////////////\r
// async\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Gold implementation\r
+\r
+namespace\r
+{\r
+ template <typename T, template <typename> class Interpolator> void remapImpl(const cv::Mat& src, const cv::Mat& xmap, const cv::Mat& ymap, cv::Mat& dst, int borderType, cv::Scalar borderVal)\r
+ {\r
+ const int cn = src.channels();\r
+\r
+ cv::Size dsize = xmap.size();\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ for (int y = 0; y < dsize.height; ++y)\r
+ {\r
+ for (int x = 0; x < dsize.width; ++x)\r
+ {\r
+ for (int c = 0; c < cn; ++c)\r
+ dst.at<T>(y, x * cn + c) = Interpolator<T>::getValue(src, ymap.at<float>(y, x), xmap.at<float>(y, x), c, borderType, borderVal);\r
+ }\r
+ }\r
+ }\r
+\r
+ void remapGold(const cv::Mat& src, const cv::Mat& xmap, const cv::Mat& ymap, cv::Mat& dst, int interpolation, int borderType, cv::Scalar borderVal)\r
+ {\r
+ typedef void (*func_t)(const cv::Mat& src, const cv::Mat& xmap, const cv::Mat& ymap, cv::Mat& dst, int borderType, cv::Scalar borderVal);\r
+\r
+ static const func_t nearest_funcs[] = \r
+ {\r
+ remapImpl<unsigned char, NearestInterpolator>,\r
+ remapImpl<signed char, NearestInterpolator>,\r
+ remapImpl<unsigned short, NearestInterpolator>,\r
+ remapImpl<short, NearestInterpolator>,\r
+ remapImpl<int, NearestInterpolator>,\r
+ remapImpl<float, NearestInterpolator>\r
+ };\r
+\r
+ static const func_t linear_funcs[] = \r
+ {\r
+ remapImpl<unsigned char, LinearInterpolator>,\r
+ remapImpl<signed char, LinearInterpolator>,\r
+ remapImpl<unsigned short, LinearInterpolator>,\r
+ remapImpl<short, LinearInterpolator>,\r
+ remapImpl<int, LinearInterpolator>,\r
+ remapImpl<float, LinearInterpolator>\r
+ };\r
+\r
+ static const func_t cubic_funcs[] = \r
+ {\r
+ remapImpl<unsigned char, CubicInterpolator>,\r
+ remapImpl<signed char, CubicInterpolator>,\r
+ remapImpl<unsigned short, CubicInterpolator>,\r
+ remapImpl<short, CubicInterpolator>,\r
+ remapImpl<int, CubicInterpolator>,\r
+ remapImpl<float, CubicInterpolator>\r
+ };\r
+\r
+ static const func_t* funcs[] = {nearest_funcs, linear_funcs, cubic_funcs};\r
+\r
+ funcs[interpolation][src.depth()](src, xmap, ymap, dst, borderType, borderVal);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test\r
+\r
+PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Border, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
+ int interpolation;\r
+ int borderType;\r
+ bool useRoi;\r
+\r
+ cv::Mat xmap;\r
+ cv::Mat ymap;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ interpolation = GET_PARAM(3);\r
+ borderType = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+\r
+ // rotation matrix\r
+\r
+ const double aplha = CV_PI / 4;\r
+ static double M[2][3] = { {std::cos(aplha), -std::sin(aplha), size.width / 2.0},\r
+ {std::sin(aplha), std::cos(aplha), 0.0}};\r
+\r
+ xmap.create(size, CV_32FC1);\r
+ ymap.create(size, CV_32FC1);\r
+\r
+ for (int y = 0; y < size.height; ++y)\r
+ {\r
+ for (int x = 0; x < size.width; ++x)\r
+ {\r
+ xmap.at<float>(y, x) = static_cast<float>(M[0][0] * x + M[0][1] * y + M[0][2]);\r
+ ymap.at<float>(y, x) = static_cast<float>(M[1][0] * x + M[1][1] * y + M[1][2]);\r
+ }\r
+ }\r
+ }\r
+};\r
+\r
+TEST_P(Remap, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Scalar val = randomScalar(0.0, 255.0);\r
+\r
+ cv::gpu::GpuMat dst = createMat(xmap.size(), type, useRoi);\r
+ cv::gpu::remap(loadMat(src, useRoi), dst, loadMat(xmap, useRoi), loadMat(ymap, useRoi), interpolation, borderType, val);\r
+\r
+ cv::Mat dst_gold;\r
+ remapGold(src, xmap, ymap, dst_gold, interpolation, borderType, val);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Remap, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_CONSTANT), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),\r
+ WHOLE_SUBMAT));\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Gold implementation\r
+\r
+namespace\r
+{\r
+ template <typename T, template <typename> class Interpolator> void resizeImpl(const cv::Mat& src, cv::Mat& dst, double fx, double fy)\r
+ {\r
+ const int cn = src.channels();\r
+\r
+ cv::Size dsize(cv::saturate_cast<int>(src.cols * fx), cv::saturate_cast<int>(src.rows * fy));\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ float ifx = static_cast<float>(1.0 / fx);\r
+ float ify = static_cast<float>(1.0 / fy);\r
+\r
+ for (int y = 0; y < dsize.height; ++y)\r
+ {\r
+ for (int x = 0; x < dsize.width; ++x)\r
+ {\r
+ for (int c = 0; c < cn; ++c)\r
+ dst.at<T>(y, x * cn + c) = Interpolator<T>::getValue(src, y * ify, x * ifx, c, cv::BORDER_REPLICATE);\r
+ }\r
+ }\r
+ }\r
+\r
+ void resizeGold(const cv::Mat& src, cv::Mat& dst, double fx, double fy, int interpolation)\r
+ {\r
+ typedef void (*func_t)(const cv::Mat& src, cv::Mat& dst, double fx, double fy);\r
+\r
+ static const func_t nearest_funcs[] =\r
+ {\r
+ resizeImpl<unsigned char, NearestInterpolator>,\r
+ resizeImpl<signed char, NearestInterpolator>,\r
+ resizeImpl<unsigned short, NearestInterpolator>,\r
+ resizeImpl<short, NearestInterpolator>,\r
+ resizeImpl<int, NearestInterpolator>,\r
+ resizeImpl<float, NearestInterpolator>\r
+ };\r
+\r
+\r
+ static const func_t linear_funcs[] =\r
+ {\r
+ resizeImpl<unsigned char, LinearInterpolator>,\r
+ resizeImpl<signed char, LinearInterpolator>,\r
+ resizeImpl<unsigned short, LinearInterpolator>,\r
+ resizeImpl<short, LinearInterpolator>,\r
+ resizeImpl<int, LinearInterpolator>,\r
+ resizeImpl<float, LinearInterpolator>\r
+ };\r
+\r
+ static const func_t cubic_funcs[] =\r
+ {\r
+ resizeImpl<unsigned char, CubicInterpolator>,\r
+ resizeImpl<signed char, CubicInterpolator>,\r
+ resizeImpl<unsigned short, CubicInterpolator>,\r
+ resizeImpl<short, CubicInterpolator>,\r
+ resizeImpl<int, CubicInterpolator>,\r
+ resizeImpl<float, CubicInterpolator>\r
+ };\r
+\r
+ static const func_t* funcs[] = {nearest_funcs, linear_funcs, cubic_funcs};\r
+\r
+ funcs[interpolation][src.depth()](src, dst, fx, fy);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test\r
+\r
+PARAM_TEST_CASE(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpolation, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ double coeff;\r
+ int interpolation;\r
+ int type;\r
+ bool useRoi;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ coeff = GET_PARAM(3);\r
+ interpolation = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(Resize, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+\r
+ cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);\r
+ cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);\r
+\r
+ cv::Mat dst_gold;\r
+ resizeGold(src, dst_gold, coeff, coeff, interpolation);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Resize, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC3), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ testing::Values(0.3, 0.5, 1.5, 2.0),\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ WHOLE_SUBMAT));\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test NPP\r
+\r
+PARAM_TEST_CASE(ResizeNPP, cv::gpu::DeviceInfo, MatType, double, Interpolation)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ double coeff;\r
+ int interpolation;\r
+ int type;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ type = GET_PARAM(1);\r
+ coeff = GET_PARAM(2);\r
+ interpolation = GET_PARAM(3);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(ResizeNPP, Accuracy)\r
+{\r
+ if (type == CV_8UC1 && interpolation == cv::INTER_CUBIC)\r
+ return;\r
+\r
+ cv::Mat src = readImageType("stereobp/aloe-L.png", type);\r
+\r
+ cv::gpu::GpuMat dst;\r
+ cv::gpu::resize(loadMat(src), dst, cv::Size(), coeff, coeff, interpolation);\r
+\r
+ cv::Mat dst_gold;\r
+ resizeGold(src, dst_gold, coeff, coeff, interpolation);\r
+\r
+ EXPECT_MAT_SIMILAR(dst_gold, dst, 1e-1);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeNPP, testing::Combine(\r
+ ALL_DEVICES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
+ testing::Values(0.3, 0.5, 1.5, 2.0),\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))));\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
+ int threshOp;\r
+ bool useRoi;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ threshOp = GET_PARAM(3);\r
+ useRoi = GET_PARAM(4);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(Threshold, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+ double maxVal = randomDouble(20.0, 127.0);\r
+ double thresh = randomDouble(0.0, maxVal);\r
+\r
+ cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi);\r
+ cv::gpu::threshold(loadMat(src, useRoi), dst, thresh, maxVal, threshOp);\r
+\r
+ cv::Mat dst_gold;\r
+ cv::threshold(src, dst_gold, thresh, maxVal, threshOp);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Threshold, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)),\r
+ testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV)),\r
+ WHOLE_SUBMAT));\r
+\r
+#endif // HAVE_CUDA\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
#ifdef HAVE_CUDA\r
\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+namespace\r
+{\r
+ cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)\r
+ {\r
+ cv::Mat M(2, 3, CV_64FC1);\r
+ M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;\r
+ M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;\r
+\r
+ return M;\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test buildWarpAffineMaps\r
+\r
+PARAM_TEST_CASE(BuildWarpAffineMaps, cv::gpu::DeviceInfo, cv::Size, Inverse)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ bool inverse;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ inverse = GET_PARAM(2);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(BuildWarpAffineMaps, Accuracy)\r
+{\r
+ cv::Mat M = createTransfomMatrix(size, CV_PI / 4);\r
+ cv::gpu::GpuMat xmap, ymap;\r
+ cv::gpu::buildWarpAffineMaps(M, inverse, size, xmap, ymap);\r
+\r
+ int interpolation = cv::INTER_NEAREST;\r
+ int borderMode = cv::BORDER_CONSTANT;\r
+\r
+ cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);\r
+ cv::Mat dst;\r
+ cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);\r
+\r
+ int flags = interpolation;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+ cv::Mat dst_gold;\r
+ cv::warpAffine(src, dst_gold, M, size, flags, borderMode);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, BuildWarpAffineMaps, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ DIRECT_INVERSE));\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Gold implementation\r
+\r
+namespace\r
+{\r
+ template <typename T, template <typename> class Interpolator> void warpAffineImpl(const cv::Mat& src, const cv::Mat& M, cv::Size dsize, cv::Mat& dst, int borderType, cv::Scalar borderVal)\r
+ {\r
+ const int cn = src.channels();\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ for (int y = 0; y < dsize.height; ++y)\r
+ {\r
+ for (int x = 0; x < dsize.width; ++x)\r
+ {\r
+ float xcoo = static_cast<float>(M.at<double>(0, 0) * x + M.at<double>(0, 1) * y + M.at<double>(0, 2));\r
+ float ycoo = static_cast<float>(M.at<double>(1, 0) * x + M.at<double>(1, 1) * y + M.at<double>(1, 2));\r
+\r
+ for (int c = 0; c < cn; ++c)\r
+ dst.at<T>(y, x * cn + c) = Interpolator<T>::getValue(src, ycoo, xcoo, c, borderType, borderVal);\r
+ }\r
+ }\r
+ }\r
+\r
+ void warpAffineGold(const cv::Mat& src, const cv::Mat& M, bool inverse, cv::Size dsize, cv::Mat& dst, int interpolation, int borderType, cv::Scalar borderVal)\r
+ {\r
+ typedef void (*func_t)(const cv::Mat& src, const cv::Mat& M, cv::Size dsize, cv::Mat& dst, int borderType, cv::Scalar borderVal);\r
+\r
+ static const func_t nearest_funcs[] =\r
+ {\r
+ warpAffineImpl<unsigned char, NearestInterpolator>,\r
+ warpAffineImpl<signed char, NearestInterpolator>,\r
+ warpAffineImpl<unsigned short, NearestInterpolator>,\r
+ warpAffineImpl<short, NearestInterpolator>,\r
+ warpAffineImpl<int, NearestInterpolator>,\r
+ warpAffineImpl<float, NearestInterpolator>\r
+ };\r
+\r
+ static const func_t linear_funcs[] =\r
+ {\r
+ warpAffineImpl<unsigned char, LinearInterpolator>,\r
+ warpAffineImpl<signed char, LinearInterpolator>,\r
+ warpAffineImpl<unsigned short, LinearInterpolator>,\r
+ warpAffineImpl<short, LinearInterpolator>,\r
+ warpAffineImpl<int, LinearInterpolator>,\r
+ warpAffineImpl<float, LinearInterpolator>\r
+ };\r
+\r
+ static const func_t cubic_funcs[] =\r
+ {\r
+ warpAffineImpl<unsigned char, CubicInterpolator>,\r
+ warpAffineImpl<signed char, CubicInterpolator>,\r
+ warpAffineImpl<unsigned short, CubicInterpolator>,\r
+ warpAffineImpl<short, CubicInterpolator>,\r
+ warpAffineImpl<int, CubicInterpolator>,\r
+ warpAffineImpl<float, CubicInterpolator>\r
+ };\r
+\r
+ static const func_t* funcs[] = {nearest_funcs, linear_funcs, cubic_funcs};\r
+\r
+ if (inverse)\r
+ funcs[interpolation][src.depth()](src, M, dsize, dst, borderType, borderVal);\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ cv::invertAffineTransform(M, iM);\r
+ funcs[interpolation][src.depth()](src, iM, dsize, dst, borderType, borderVal);\r
+ }\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test\r
+\r
+PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, Border, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
+ bool inverse;\r
+ int interpolation;\r
+ int borderType;\r
+ bool useRoi;\r
+\r
+ cv::Mat M;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ inverse = GET_PARAM(3);\r
+ interpolation = GET_PARAM(4);\r
+ borderType = GET_PARAM(5);\r
+ useRoi = GET_PARAM(6);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(WarpAffine, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat M = createTransfomMatrix(size, CV_PI / 3);\r
+ int flags = interpolation;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+ cv::Scalar val = randomScalar(0.0, 255.0);\r
+\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::warpAffine(loadMat(src, useRoi), dst, M, size, flags, borderType, val);\r
+\r
+ cv::Mat dst_gold;\r
+ warpAffineGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpAffine, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ DIRECT_INVERSE,\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),\r
+ WHOLE_SUBMAT));\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test NPP\r
+\r
+PARAM_TEST_CASE(WarpAffineNPP, cv::gpu::DeviceInfo, MatType, Inverse, Interpolation)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ int type;\r
+ bool inverse;\r
+ int interpolation;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ type = GET_PARAM(1);\r
+ inverse = GET_PARAM(2);\r
+ interpolation = GET_PARAM(3);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(WarpAffineNPP, Accuracy)\r
+{\r
+ cv::Mat src = readImageType("stereobp/aloe-L.png", type);\r
+ cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);\r
+ int flags = interpolation;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+\r
+ cv::gpu::GpuMat dst;\r
+ cv::gpu::warpAffine(loadMat(src), dst, M, src.size(), flags);\r
+\r
+ cv::Mat dst_gold;\r
+ warpAffineGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));\r
+\r
+ EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpAffineNPP, testing::Combine(\r
+ ALL_DEVICES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ DIRECT_INVERSE,\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))));\r
+\r
+#endif // HAVE_CUDA\r
--- /dev/null
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+// By downloading, copying, installing or using the software you agree to this license.\r
+// If you do not agree to this license, do not download, install,\r
+// copy or use the software.\r
+//\r
+//\r
+// Intel License Agreement\r
+// For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+// * Redistribution's of source code must retain the above copyright notice,\r
+// this list of conditions and the following disclaimer.\r
+//\r
+// * Redistribution's in binary form must reproduce the above copyright notice,\r
+// this list of conditions and the following disclaimer in the documentation\r
+// and/or other materials provided with the distribution.\r
+//\r
+// * The name of Intel Corporation may not be used to endorse or promote products\r
+// derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "precomp.hpp"\r
+\r
+#ifdef HAVE_CUDA\r
+\r
+namespace\r
+{\r
+ cv::Mat createTransfomMatrix(cv::Size srcSize, double angle)\r
+ {\r
+ cv::Mat M(3, 3, CV_64FC1);\r
+ M.at<double>(0, 0) = std::cos(angle); M.at<double>(0, 1) = -std::sin(angle); M.at<double>(0, 2) = srcSize.width / 2;\r
+ M.at<double>(1, 0) = std::sin(angle); M.at<double>(1, 1) = std::cos(angle); M.at<double>(1, 2) = 0.0;\r
+ M.at<double>(2, 0) = 0.0 ; M.at<double>(2, 1) = 0.0 ; M.at<double>(2, 2) = 1.0;\r
+\r
+ return M;\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test buildWarpPerspectiveMaps\r
+\r
+PARAM_TEST_CASE(BuildWarpPerspectiveMaps, cv::gpu::DeviceInfo, cv::Size, Inverse)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ bool inverse;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ inverse = GET_PARAM(2);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(BuildWarpPerspectiveMaps, Accuracy)\r
+{\r
+ cv::Mat M = createTransfomMatrix(size, CV_PI / 4);\r
+ cv::gpu::GpuMat xmap, ymap;\r
+ cv::gpu::buildWarpPerspectiveMaps(M, inverse, size, xmap, ymap);\r
+\r
+ cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);\r
+ cv::Mat dst;\r
+ cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), cv::INTER_NEAREST, cv::BORDER_CONSTANT);\r
+\r
+ int flags = cv::INTER_NEAREST;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+ cv::Mat dst_gold;\r
+ cv::warpPerspective(src, dst_gold, M, size, flags, cv::BORDER_CONSTANT);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, BuildWarpPerspectiveMaps, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ DIRECT_INVERSE));\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Gold implementation\r
+\r
+namespace\r
+{\r
+ template <typename T, template <typename> class Interpolator> void warpPerspectiveImpl(const cv::Mat& src, const cv::Mat& M, cv::Size dsize, cv::Mat& dst, int borderType, cv::Scalar borderVal)\r
+ {\r
+ const int cn = src.channels();\r
+\r
+ dst.create(dsize, src.type());\r
+\r
+ for (int y = 0; y < dsize.height; ++y)\r
+ {\r
+ for (int x = 0; x < dsize.width; ++x)\r
+ {\r
+ float coeff = static_cast<float>(M.at<double>(2, 0) * x + M.at<double>(2, 1) * y + M.at<double>(2, 2));\r
+\r
+ float xcoo = static_cast<float>((M.at<double>(0, 0) * x + M.at<double>(0, 1) * y + M.at<double>(0, 2)) / coeff);\r
+ float ycoo = static_cast<float>((M.at<double>(1, 0) * x + M.at<double>(1, 1) * y + M.at<double>(1, 2)) / coeff);\r
+\r
+ for (int c = 0; c < cn; ++c)\r
+ dst.at<T>(y, x * cn + c) = Interpolator<T>::getValue(src, ycoo, xcoo, c, borderType, borderVal);\r
+ }\r
+ }\r
+ }\r
+\r
+ void warpPerspectiveGold(const cv::Mat& src, const cv::Mat& M, bool inverse, cv::Size dsize, cv::Mat& dst, int interpolation, int borderType, cv::Scalar borderVal)\r
+ {\r
+ typedef void (*func_t)(const cv::Mat& src, const cv::Mat& M, cv::Size dsize, cv::Mat& dst, int borderType, cv::Scalar borderVal);\r
+\r
+ static const func_t nearest_funcs[] =\r
+ {\r
+ warpPerspectiveImpl<unsigned char, NearestInterpolator>,\r
+ warpPerspectiveImpl<signed char, NearestInterpolator>,\r
+ warpPerspectiveImpl<unsigned short, NearestInterpolator>,\r
+ warpPerspectiveImpl<short, NearestInterpolator>,\r
+ warpPerspectiveImpl<int, NearestInterpolator>,\r
+ warpPerspectiveImpl<float, NearestInterpolator>\r
+ };\r
+\r
+ static const func_t linear_funcs[] =\r
+ {\r
+ warpPerspectiveImpl<unsigned char, LinearInterpolator>,\r
+ warpPerspectiveImpl<signed char, LinearInterpolator>,\r
+ warpPerspectiveImpl<unsigned short, LinearInterpolator>,\r
+ warpPerspectiveImpl<short, LinearInterpolator>,\r
+ warpPerspectiveImpl<int, LinearInterpolator>,\r
+ warpPerspectiveImpl<float, LinearInterpolator>\r
+ };\r
+\r
+ static const func_t cubic_funcs[] =\r
+ {\r
+ warpPerspectiveImpl<unsigned char, CubicInterpolator>,\r
+ warpPerspectiveImpl<signed char, CubicInterpolator>,\r
+ warpPerspectiveImpl<unsigned short, CubicInterpolator>,\r
+ warpPerspectiveImpl<short, CubicInterpolator>,\r
+ warpPerspectiveImpl<int, CubicInterpolator>,\r
+ warpPerspectiveImpl<float, CubicInterpolator>\r
+ };\r
+\r
+ static const func_t* funcs[] = {nearest_funcs, linear_funcs, cubic_funcs};\r
+\r
+ if (inverse)\r
+ funcs[interpolation][src.depth()](src, M, dsize, dst, borderType, borderVal);\r
+ else\r
+ {\r
+ cv::Mat iM;\r
+ cv::invert(M, iM);\r
+ funcs[interpolation][src.depth()](src, iM, dsize, dst, borderType, borderVal);\r
+ }\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test\r
+\r
+PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Interpolation, Border, UseRoi)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
+ bool inverse;\r
+ int interpolation;\r
+ int borderType;\r
+ bool useRoi;\r
+\r
+ cv::Mat M;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ inverse = GET_PARAM(3);\r
+ interpolation = GET_PARAM(4);\r
+ borderType = GET_PARAM(5);\r
+ useRoi = GET_PARAM(6);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(WarpPerspective, Accuracy)\r
+{\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat M = createTransfomMatrix(size, CV_PI / 3);\r
+ int flags = interpolation;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+ cv::Scalar val = randomScalar(0.0, 255.0);\r
+\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::warpPerspective(loadMat(src, useRoi), dst, M, size, flags, borderType, val);\r
+\r
+ cv::Mat dst_gold;\r
+ warpPerspectiveGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);\r
+\r
+ EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpPerspective, testing::Combine(\r
+ ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ DIRECT_INVERSE,\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),\r
+ testing::Values(Border(cv::BORDER_REFLECT101), Border(cv::BORDER_REPLICATE), Border(cv::BORDER_REFLECT), Border(cv::BORDER_WRAP)),\r
+ WHOLE_SUBMAT));\r
+\r
+///////////////////////////////////////////////////////////////////\r
+// Test NPP\r
+\r
+PARAM_TEST_CASE(WarpPerspectiveNPP, cv::gpu::DeviceInfo, MatType, Inverse, Interpolation)\r
+{\r
+ cv::gpu::DeviceInfo devInfo;\r
+ int type;\r
+ bool inverse;\r
+ int interpolation;\r
+\r
+ virtual void SetUp()\r
+ {\r
+ devInfo = GET_PARAM(0);\r
+ type = GET_PARAM(1);\r
+ inverse = GET_PARAM(2);\r
+ interpolation = GET_PARAM(3);\r
+\r
+ cv::gpu::setDevice(devInfo.deviceID());\r
+ }\r
+};\r
+\r
+TEST_P(WarpPerspectiveNPP, Accuracy)\r
+{\r
+ cv::Mat src = readImageType("stereobp/aloe-L.png", type);\r
+ cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);\r
+ int flags = interpolation;\r
+ if (inverse)\r
+ flags |= cv::WARP_INVERSE_MAP;\r
+\r
+ cv::gpu::GpuMat dst;\r
+ cv::gpu::warpPerspective(loadMat(src), dst, M, src.size(), flags);\r
+\r
+ cv::Mat dst_gold;\r
+ warpPerspectiveGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));\r
+\r
+ EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);\r
+}\r
+\r
+INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpPerspectiveNPP, testing::Combine(\r
+ ALL_DEVICES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),\r
+ DIRECT_INVERSE,\r
+ testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC))));\r
+\r
+#endif // HAVE_CUDA\r
//\r
//M*/\r
\r
-#include "test_precomp.hpp"\r
+#include "precomp.hpp"\r
\r
using namespace std;\r
using namespace cv;\r
using namespace cv::gpu;\r
using namespace cvtest;\r
\r
-GpuMat loadMat(const Mat& m, bool useRoi)\r
+int randomInt(int minVal, int maxVal)\r
+{\r
+ RNG& rng = TS::ptr()->get_rng();\r
+ return rng.uniform(minVal, maxVal);\r
+}\r
+\r
+double randomDouble(double minVal, double maxVal)\r
+{\r
+ RNG& rng = TS::ptr()->get_rng();\r
+ return rng.uniform(minVal, maxVal);\r
+}\r
+\r
+Size randomSize(int minVal, int maxVal)\r
+{\r
+ return cv::Size(randomInt(minVal, maxVal), randomInt(minVal, maxVal));\r
+}\r
+\r
+Scalar randomScalar(double minVal, double maxVal)\r
+{\r
+ return Scalar(randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal), randomDouble(minVal, maxVal));\r
+}\r
+\r
+Mat randomMat(Size size, int type, double minVal, double maxVal)\r
+{\r
+ return randomMat(TS::ptr()->get_rng(), size, type, minVal, maxVal, false);\r
+}\r
+\r
+cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi)\r
{\r
- Size size = m.size();\r
Size size0 = size;\r
\r
if (useRoi)\r
{\r
- RNG& rng = TS::ptr()->get_rng();\r
-\r
- size0.width += rng.uniform(5, 15);\r
- size0.height += rng.uniform(5, 15);\r
+ size0.width += randomInt(5, 15);\r
+ size0.height += randomInt(5, 15);\r
}\r
\r
- GpuMat d_m(size0, m.type());\r
+ GpuMat d_m(size0, type);\r
\r
if (size0 != size)\r
d_m = d_m(Rect((size0.width - size.width) / 2, (size0.height - size.height) / 2, size.width, size.height));\r
\r
- d_m.upload(m);\r
+ return d_m;\r
+}\r
\r
+GpuMat loadMat(const Mat& m, bool useRoi)\r
+{\r
+ GpuMat d_m = createMat(m.size(), m.type(), useRoi);\r
+ d_m.upload(m);\r
return d_m;\r
}\r
\r
+void showDiff(InputArray gold_, InputArray actual_, double eps)\r
+{\r
+ Mat gold;\r
+ if (gold_.kind() == _InputArray::MAT)\r
+ gold = gold_.getMat();\r
+ else\r
+ gold_.getGpuMat().download(gold);\r
+\r
+ Mat actual;\r
+ if (actual_.kind() == _InputArray::MAT)\r
+ actual = actual_.getMat();\r
+ else\r
+ actual_.getGpuMat().download(actual);\r
+\r
+ Mat diff;\r
+ absdiff(gold, actual, diff);\r
+ threshold(diff, diff, eps, 255.0, cv::THRESH_BINARY);\r
+\r
+ namedWindow("gold", WINDOW_NORMAL);\r
+ namedWindow("actual", WINDOW_NORMAL);\r
+ namedWindow("diff", WINDOW_NORMAL);\r
+\r
+ imshow("gold", gold);\r
+ imshow("actual", actual);\r
+ imshow("diff", diff);\r
+\r
+ waitKey();\r
+}\r
+\r
bool supportFeature(const DeviceInfo& info, FeatureSet feature)\r
{\r
return TargetArchs::builtWith(feature) && info.supports(feature);\r
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);\r
}\r
\r
+Mat readImageType(const string& fname, int type)\r
+{\r
+ Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);\r
+ if (CV_MAT_CN(type) == 4)\r
+ {\r
+ Mat temp;\r
+ cvtColor(src, temp, cv::COLOR_BGR2BGRA);\r
+ swap(src, temp);\r
+ }\r
+ src.convertTo(src, CV_MAT_DEPTH(type));\r
+ return src;\r
+}\r
+\r
+double checkNorm(const Mat& m)\r
+{\r
+ return norm(m, NORM_INF);\r
+}\r
+\r
double checkNorm(const Mat& m1, const Mat& m2)\r
{\r
return norm(m1, m2, NORM_INF);\r
else\r
(*os) << "whole matrix";\r
}\r
+\r
+void PrintTo(const Inverse& inverse, std::ostream* os)\r
+{\r
+ if (inverse)\r
+ (*os) << "inverse";\r
+ else\r
+ (*os) << "direct";\r
+}\r
//\r
//M*/\r
\r
-#ifndef __OPENCV_TEST_GPU_BASE_HPP__\r
-#define __OPENCV_TEST_GPU_BASE_HPP__\r
+#ifndef __OPENCV_TEST_UTILITY_HPP__\r
+#define __OPENCV_TEST_UTILITY_HPP__\r
\r
+int randomInt(int minVal, int maxVal);\r
+double randomDouble(double minVal, double maxVal);\r
+cv::Size randomSize(int minVal, int maxVal);\r
+cv::Scalar randomScalar(double minVal, double maxVal);\r
+cv::Mat randomMat(cv::Size size, int type, double minVal = 0.0, double maxVal = 255.0);\r
+\r
+cv::gpu::GpuMat createMat(cv::Size size, int type, bool useRoi = false);\r
cv::gpu::GpuMat loadMat(const cv::Mat& m, bool useRoi = false);\r
\r
+void showDiff(cv::InputArray gold, cv::InputArray actual, double eps);\r
+\r
//! return true if device supports specified feature and gpu module was built with support the feature.\r
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);\r
\r
\r
//! read image from testdata folder.\r
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);\r
+cv::Mat readImageType(const std::string& fname, int type);\r
\r
+double checkNorm(const cv::Mat& m);\r
double checkNorm(const cv::Mat& m1, const cv::Mat& m2);\r
double checkSimilarity(const cv::Mat& m1, const cv::Mat& m2);\r
\r
+#define EXPECT_MAT_NORM(mat, eps) \\r
+ { \\r
+ EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \\r
+ }\r
+\r
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \\r
{ \\r
ASSERT_EQ(mat1.type(), mat2.type()); \\r
ASSERT_EQ(mat1.size(), mat2.size()); \\r
- EXPECT_LE(checkNorm(mat1, mat2), eps); \\r
+ EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \\r
}\r
\r
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \\r
{ \\r
ASSERT_EQ(mat1.type(), mat2.type()); \\r
ASSERT_EQ(mat1.size(), mat2.size()); \\r
- EXPECT_LE(checkSimilarity(mat1, mat2), eps); \\r
+ EXPECT_LE(checkSimilarity(cv::Mat(mat1), cv::Mat(mat2)), eps); \\r
}\r
\r
namespace cv { namespace gpu \r
\r
void PrintTo(const UseRoi& useRoi, std::ostream* os);\r
\r
+class Inverse\r
+{\r
+public:\r
+ inline Inverse(bool val = false) : val_(val) {}\r
+\r
+ inline operator bool() const { return val_; }\r
+\r
+private:\r
+ bool val_;\r
+};\r
+\r
+void PrintTo(const Inverse& useRoi, std::ostream* os);\r
+\r
CV_ENUM(CmpCode, cv::CMP_EQ, cv::CMP_GT, cv::CMP_GE, cv::CMP_LT, cv::CMP_LE, cv::CMP_NE)\r
\r
CV_ENUM(NormCode, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_TYPE_MASK, cv::NORM_RELATIVE, cv::NORM_MINMAX)\r
CV_FLAGS(DftFlags, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)\r
\r
#define PARAM_TEST_CASE(name, ...) struct name : testing::TestWithParam< std::tr1::tuple< __VA_ARGS__ > >\r
+\r
#define GET_PARAM(k) std::tr1::get< k >(GetParam())\r
+\r
#define ALL_DEVICES testing::ValuesIn(devices())\r
#define DEVICES(feature) testing::ValuesIn(devices(feature))\r
+\r
#define ALL_TYPES testing::ValuesIn(all_types())\r
#define TYPES(depth_start, depth_end, cn_start, cn_end) testing::ValuesIn(types(depth_start, depth_end, cn_start, cn_end))\r
-#define USE_ROI testing::Values(false, true)\r
\r
-#endif // __OPENCV_TEST_GPU_BASE_HPP__\r
+#define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113))\r
+\r
+#define WHOLE_SUBMAT testing::Values(UseRoi(false), UseRoi(true))\r
+\r
+#define DIRECT_INVERSE testing::Values(Inverse(false), Inverse(true))\r
+\r
+#endif // __OPENCV_TEST_UTILITY_HPP__\r