mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 11:45:30 +08:00
Merge pull request #17088 from mpashchenkov:mp/ocv-gapi-kernel-laplacian
G-API: Laplacian and bilateralFilter standard kernels * Added Laplacian kernel and tests * Added: Laplacian kernel, Bilateral kernel (CPU, GPU); Performance and accuracy tests for this kernels * Changed tolerance for GPU test * boner * Some changes with alignment; Tests's parameters are the same as for OCV * Cut tests * Compressed tests * Minor changes (rsrt bb) * Returned types
This commit is contained in:
parent
189fc43765
commit
51a42c0647
@ -90,6 +90,20 @@ namespace imgproc {
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GLaplacian, <GMat(GMat,int, int, double, double, int)>,
|
||||
"org.opencv.imgproc.filters.laplacian") {
|
||||
static GMatDesc outMeta(GMatDesc in, int ddepth, int, double, double, int) {
|
||||
return in.withDepth(ddepth);
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GBilateralFilter, <GMat(GMat,int, double, double, int)>,
|
||||
"org.opencv.imgproc.filters.bilateralfilter") {
|
||||
static GMatDesc outMeta(GMatDesc in, int, double, double, int) {
|
||||
return in;
|
||||
}
|
||||
};
|
||||
|
||||
G_TYPED_KERNEL(GEqHist, <GMat(GMat)>, "org.opencv.imgproc.equalizeHist"){
|
||||
static GMatDesc outMeta(GMatDesc in) {
|
||||
return in.withType(CV_8U, 1);
|
||||
@ -643,6 +657,68 @@ GAPI_EXPORTS std::tuple<GMat, GMat> SobelXY(const GMat& src, int ddepth, int ord
|
||||
int borderType = BORDER_DEFAULT,
|
||||
const Scalar& borderValue = Scalar(0));
|
||||
|
||||
/** @brief Calculates the Laplacian of an image.
|
||||
|
||||
The function calculates the Laplacian of the source image by adding up the second x and y
|
||||
derivatives calculated using the Sobel operator:
|
||||
|
||||
\f[\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\f]
|
||||
|
||||
This is done when `ksize > 1`. When `ksize == 1`, the Laplacian is computed by filtering the image
|
||||
with the following \f$3 \times 3\f$ aperture:
|
||||
|
||||
\f[\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\f]
|
||||
|
||||
@note Function textual ID is "org.opencv.imgproc.filters.laplacian"
|
||||
|
||||
@param src Source image.
|
||||
@param ddepth Desired depth of the destination image.
|
||||
@param ksize Aperture size used to compute the second-derivative filters. See #getDerivKernels for
|
||||
details. The size must be positive and odd.
|
||||
@param scale Optional scale factor for the computed Laplacian values. By default, no scaling is
|
||||
applied. See #getDerivKernels for details.
|
||||
@param delta Optional delta value that is added to the results prior to storing them in dst .
|
||||
@param borderType Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
|
||||
@return Destination image of the same size and the same number of channels as src.
|
||||
@sa Sobel, Scharr
|
||||
*/
|
||||
GAPI_EXPORTS GMat Laplacian(const GMat& src, int ddepth, int ksize = 1,
|
||||
double scale = 1, double delta = 0, int borderType = BORDER_DEFAULT);
|
||||
|
||||
/** @brief Applies the bilateral filter to an image.
|
||||
|
||||
The function applies bilateral filtering to the input image, as described in
|
||||
http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
|
||||
bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
|
||||
very slow compared to most filters.
|
||||
|
||||
_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\<
|
||||
10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very
|
||||
strong effect, making the image look "cartoonish".
|
||||
|
||||
_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time
|
||||
applications, and perhaps d=9 for offline applications that need heavy noise filtering.
|
||||
|
||||
This filter does not work inplace.
|
||||
|
||||
@note Function textual ID is "org.opencv.imgproc.filters.bilateralfilter"
|
||||
|
||||
@param src Source 8-bit or floating-point, 1-channel or 3-channel image.
|
||||
@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
|
||||
it is computed from sigmaSpace.
|
||||
@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that
|
||||
farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting
|
||||
in larger areas of semi-equal color.
|
||||
@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that
|
||||
farther pixels will influence each other as long as their colors are close enough (see sigmaColor
|
||||
). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is
|
||||
proportional to sigmaSpace.
|
||||
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes
|
||||
@return Destination image of the same size and type as src.
|
||||
*/
|
||||
GAPI_EXPORTS GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace,
|
||||
int borderType = BORDER_DEFAULT);
|
||||
|
||||
/** @brief Finds edges in an image using the Canny algorithm.
|
||||
|
||||
The function finds edges in the input image and marks them in the output map edges using the
|
||||
|
@ -20,33 +20,38 @@ namespace opencv_test
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
class SepFilterPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, int, cv::GCompileArgs>> {};
|
||||
class Filter2DPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class BoxFilterPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class BlurPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class GaussianBlurPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, cv::GCompileArgs>> {};
|
||||
class MedianBlurPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size, cv::GCompileArgs>> {};
|
||||
class ErodePerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class Erode3x3PerfTest : public TestPerfParams<tuple<compare_f, MatType, cv::Size, int, cv::GCompileArgs>> {};
|
||||
class DilatePerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class Dilate3x3PerfTest : public TestPerfParams<tuple<compare_f, MatType,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class SobelPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int,int, cv::GCompileArgs>> {};
|
||||
class SobelXYPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class CannyPerfTest : public TestPerfParams<tuple<compare_f, MatType,cv::Size,double,double,int,bool, cv::GCompileArgs>> {};
|
||||
class GoodFeaturesPerfTest : public TestPerfParams<tuple<compare_vector_f<cv::Point2f>, std::string,
|
||||
int,int,double,double,int,bool,
|
||||
cv::GCompileArgs>> {};
|
||||
class EqHistPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs >> {};
|
||||
class RGB2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs >> {};
|
||||
class BGR2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs >> {};
|
||||
class RGB2YUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs >> {};
|
||||
class YUV2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs >> {};
|
||||
class RGB2LabPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BGR2LUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class LUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BGR2YUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class YUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2HSVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class SepFilterPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class Filter2DPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class BoxFilterPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class BlurPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class GaussianBlurPerfTest : public TestPerfParams<tuple<compare_f, MatType,int, cv::Size, cv::GCompileArgs>> {};
|
||||
class MedianBlurPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size, cv::GCompileArgs>> {};
|
||||
class ErodePerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class Erode3x3PerfTest : public TestPerfParams<tuple<compare_f, MatType,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class DilatePerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class Dilate3x3PerfTest : public TestPerfParams<tuple<compare_f, MatType,cv::Size,int, cv::GCompileArgs>> {};
|
||||
class SobelPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int,int, cv::GCompileArgs>> {};
|
||||
class SobelXYPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,int, cv::GCompileArgs>> {};
|
||||
class LaplacianPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int,
|
||||
cv::GCompileArgs>> {};
|
||||
class BilateralFilterPerfTest : public TestPerfParams<tuple<compare_f, MatType,int,cv::Size,int, double,double,
|
||||
cv::GCompileArgs>> {};
|
||||
class CannyPerfTest : public TestPerfParams<tuple<compare_f, MatType,cv::Size,double,double,int,bool,
|
||||
cv::GCompileArgs>> {};
|
||||
class GoodFeaturesPerfTest : public TestPerfParams<tuple<compare_vector_f<cv::Point2f>, std::string,
|
||||
int,int,double,double,int,bool,
|
||||
cv::GCompileArgs>> {};
|
||||
class EqHistPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BGR2GrayPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2YUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class YUV2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2LabPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BGR2LUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class LUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BGR2YUVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class YUV2BGRPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2HSVPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class BayerGR2RGBPerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
class RGB2YUV422PerfTest : public TestPerfParams<tuple<compare_f, cv::Size, cv::GCompileArgs>> {};
|
||||
} // opencv_test
|
||||
|
@ -579,6 +579,89 @@ PERF_TEST_P_(SobelXYPerfTest, TestPerformance)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(LaplacianPerfTest, TestPerformance)
|
||||
{
|
||||
compare_f cmpF;
|
||||
MatType type = 0;
|
||||
int kernSize = 0, dtype = 0;
|
||||
cv::Size sz;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(cmpF, type, kernSize, sz, dtype, compile_args) = GetParam();
|
||||
|
||||
initMatrixRandN(type, sz, dtype, false);
|
||||
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
{
|
||||
cv::Laplacian(in_mat1, out_mat_ocv, dtype, kernSize);
|
||||
}
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::Laplacian(in, dtype, kernSize);
|
||||
cv::GComputation c(in, out);
|
||||
|
||||
// Warm-up graph engine:
|
||||
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
c.apply(in_mat1, out_mat_gapi);
|
||||
}
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(BilateralFilterPerfTest, TestPerformance)
|
||||
{
|
||||
compare_f cmpF;
|
||||
MatType type = 0;
|
||||
int dtype = 0, d = 0, borderType = BORDER_DEFAULT;
|
||||
double sigmaColor = 0, sigmaSpace = 0;
|
||||
cv::Size sz;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(cmpF, type, dtype, sz, d, sigmaColor, sigmaSpace,
|
||||
compile_args) = GetParam();
|
||||
|
||||
initMatrixRandN(type, sz, dtype, false);
|
||||
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
{
|
||||
cv::bilateralFilter(in_mat1, out_mat_ocv, d, sigmaColor, sigmaSpace, borderType);
|
||||
}
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::bilateralFilter(in, d, sigmaColor, sigmaSpace, borderType);
|
||||
cv::GComputation c(in, out);
|
||||
|
||||
// Warm-up graph engine:
|
||||
c.apply(in_mat1, out_mat_gapi, std::move(compile_args));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
c.apply(in_mat1, out_mat_gapi);
|
||||
}
|
||||
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
PERF_TEST_P_(CannyPerfTest, TestPerformance)
|
||||
{
|
||||
compare_f cmpF;
|
||||
|
@ -124,6 +124,24 @@ INSTANTIATE_TEST_CASE_P(SobelPerfTestCPU32F, SobelPerfTest,
|
||||
Values(1, 2),
|
||||
Values(cv::compile_args(IMGPROC_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(LaplacianPerfTestCPU, LaplacianPerfTest,
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_8UC3),
|
||||
Values(3),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(-1),
|
||||
Values(cv::compile_args(IMGPROC_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BilateralFilterPerfTestCPU, BilateralFilterPerfTest,
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_32FC1, CV_32FC3),
|
||||
Values(-1),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(3),
|
||||
Values(20),
|
||||
Values(10),
|
||||
Values(cv::compile_args(IMGPROC_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CannyPerfTestCPU, CannyPerfTest,
|
||||
Combine(Values(AbsExact().to_compare_f()),
|
||||
Values(CV_8UC1, CV_8UC3),
|
||||
|
@ -126,6 +126,24 @@ INSTANTIATE_TEST_CASE_P(SobelPerfTestGPU32F, SobelPerfTest,
|
||||
Values(1, 2),
|
||||
Values(cv::compile_args(IMGPROC_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(LaplacianPerfTestGPU, LaplacianPerfTest,
|
||||
Combine(Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
|
||||
Values(CV_8UC1, CV_8UC3),
|
||||
Values(5),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(-1),
|
||||
Values(cv::compile_args(IMGPROC_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BilateralFilterPerfTestGPU, BilateralFilterPerfTest,
|
||||
Combine(Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
|
||||
Values(CV_32FC1, CV_32FC3),
|
||||
Values(-1),
|
||||
Values(szVGA, sz720p, sz1080p),
|
||||
Values(5),
|
||||
Values(100),
|
||||
Values(40),
|
||||
Values(cv::compile_args(IMGPROC_GPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(CannyPerfTestGPU, CannyPerfTest,
|
||||
Combine(Values(AbsSimilarPoints(1, 0.05).to_compare_f()),
|
||||
Values(CV_8UC1, CV_8UC3),
|
||||
|
@ -87,6 +87,16 @@ std::tuple<GMat, GMat> SobelXY(const GMat& src, int ddepth, int order, int ksize
|
||||
return imgproc::GSobelXY::on(src, ddepth, order, ksize, scale, delta, borderType, bordVal);
|
||||
}
|
||||
|
||||
GMat Laplacian(const GMat& src, int ddepth, int ksize, double scale, double delta, int borderType)
|
||||
{
|
||||
return imgproc::GLaplacian::on(src, ddepth, ksize, scale, delta, borderType);
|
||||
}
|
||||
|
||||
GMat bilateralFilter(const GMat& src, int d, double sigmaColor, double sigmaSpace, int borderType)
|
||||
{
|
||||
return imgproc::GBilateralFilter::on(src, d, sigmaColor, sigmaSpace, borderType);
|
||||
}
|
||||
|
||||
GMat equalizeHist(const GMat& src)
|
||||
{
|
||||
return imgproc::GEqHist::on(src);
|
||||
|
@ -166,6 +166,24 @@ GAPI_OCV_KERNEL(GCPUSobelXY, cv::gapi::imgproc::GSobelXY)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPULaplacian, cv::gapi::imgproc::GLaplacian)
|
||||
{
|
||||
static void run(const cv::Mat& in, int ddepth, int ksize, double scale,
|
||||
double delta, int borderType, cv::Mat &out)
|
||||
{
|
||||
cv::Laplacian(in, out, ddepth, ksize, scale, delta, borderType);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUBilateralFilter, cv::gapi::imgproc::GBilateralFilter)
|
||||
{
|
||||
static void run(const cv::Mat& in, int d, double sigmaColor,
|
||||
double sigmaSpace, int borderType, cv::Mat &out)
|
||||
{
|
||||
cv::bilateralFilter(in, out, d, sigmaColor, sigmaSpace, borderType);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCV_KERNEL(GCPUEqualizeHist, cv::gapi::imgproc::GEqHist)
|
||||
{
|
||||
static void run(const cv::Mat& in, cv::Mat &out)
|
||||
@ -422,6 +440,8 @@ cv::gapi::GKernelPackage cv::gapi::imgproc::cpu::kernels()
|
||||
, GCPUDilate
|
||||
, GCPUSobel
|
||||
, GCPUSobelXY
|
||||
, GCPULaplacian
|
||||
, GCPUBilateralFilter
|
||||
, GCPUCanny
|
||||
, GCPUGoodFeatures
|
||||
, GCPUEqualizeHist
|
||||
|
@ -147,6 +147,24 @@ GAPI_OCL_KERNEL(GOCLSobel, cv::gapi::imgproc::GSobel)
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLLaplacian, cv::gapi::imgproc::GLaplacian)
|
||||
{
|
||||
static void run(const cv::UMat& in, int ddepth, int ksize, double scale,
|
||||
double delta, int borderType, cv::UMat &out)
|
||||
{
|
||||
cv::Laplacian(in, out, ddepth, ksize, scale, delta, borderType);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLBilateralFilter, cv::gapi::imgproc::GBilateralFilter)
|
||||
{
|
||||
static void run(const cv::UMat& in, int ddepth, double sigmaColor,
|
||||
double sigmaSpace, int borderType, cv::UMat &out)
|
||||
{
|
||||
cv::bilateralFilter(in, out, ddepth, sigmaColor, sigmaSpace, borderType);
|
||||
}
|
||||
};
|
||||
|
||||
GAPI_OCL_KERNEL(GOCLEqualizeHist, cv::gapi::imgproc::GEqHist)
|
||||
{
|
||||
static void run(const cv::UMat& in, cv::UMat &out)
|
||||
@ -260,6 +278,8 @@ cv::gapi::GKernelPackage cv::gapi::imgproc::ocl::kernels()
|
||||
, GOCLErode
|
||||
, GOCLDilate
|
||||
, GOCLSobel
|
||||
, GOCLLaplacian
|
||||
, GOCLBilateralFilter
|
||||
, GOCLCanny
|
||||
, GOCLEqualizeHist
|
||||
, GOCLRGB2YUV
|
||||
|
@ -50,6 +50,12 @@ GAPI_TEST_FIXTURE(SobelTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,in
|
||||
cmpF, kernSize, dx, dy)
|
||||
GAPI_TEST_FIXTURE(SobelXYTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,int,int), 5,
|
||||
cmpF, kernSize, order, border_type, border_val)
|
||||
GAPI_TEST_FIXTURE(LaplacianTest, initMatrixRandN,
|
||||
FIXTURE_API(CompareMats,int,double,int), 4,
|
||||
cmpF, kernSize, scale, borderType)
|
||||
GAPI_TEST_FIXTURE(BilateralFilterTest, initMatrixRandN,
|
||||
FIXTURE_API(CompareMats,int,double,double,int), 5,
|
||||
cmpF, d, sigmaColor, sigmaSpace, borderType)
|
||||
GAPI_TEST_FIXTURE(EqHistTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
|
||||
GAPI_TEST_FIXTURE(CannyTest, initMatrixRandN, FIXTURE_API(CompareMats,double,double,int,bool), 5,
|
||||
cmpF, thrLow, thrUp, apSize, l2gr)
|
||||
|
@ -342,6 +342,45 @@ TEST_P(SobelXYTest, AccuracyTest)
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(LaplacianTest, AccuracyTest)
|
||||
{
|
||||
double delta = 10;
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::Laplacian(in, dtype, kernSize, scale, delta, borderType);
|
||||
|
||||
cv::GComputation c(in, out);
|
||||
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
{
|
||||
cv::Laplacian(in_mat1, out_mat_ocv, dtype, kernSize, scale, delta, borderType);
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(BilateralFilterTest, AccuracyTest)
|
||||
{
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::bilateralFilter(in, d, sigmaColor, sigmaSpace, borderType);
|
||||
|
||||
cv::GComputation c(in, out);
|
||||
c.apply(in_mat1, out_mat_gapi, getCompileArgs());
|
||||
// OpenCV code /////////////////////////////////////////////////////////////
|
||||
{
|
||||
cv::bilateralFilter(in_mat1, out_mat_ocv, d, sigmaColor, sigmaSpace, borderType);
|
||||
}
|
||||
// Comparison //////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));
|
||||
EXPECT_EQ(out_mat_gapi.size(), sz);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(EqHistTest, AccuracyTest)
|
||||
{
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
|
@ -176,6 +176,29 @@ INSTANTIATE_TEST_CASE_P(SobelXYTestCPU32F, SobelXYTest,
|
||||
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT),
|
||||
Values(0, 1, 255)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(LaplacianTestCPU, LaplacianTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(IMGPROC_CPU),
|
||||
Values(AbsExact().to_compare_obj()),
|
||||
Values(1, 3),
|
||||
Values(0.2, 1.0),
|
||||
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BilateralFilterTestCPU, BilateralFilterTest,
|
||||
Combine(Values(CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(IMGPROC_CPU),
|
||||
Values(AbsExact().to_compare_obj()),
|
||||
Values(3, 5),
|
||||
Values(20),
|
||||
Values(10),
|
||||
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(EqHistTestCPU, EqHistTest,
|
||||
Combine(Values(CV_8UC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
|
@ -152,6 +152,29 @@ INSTANTIATE_TEST_CASE_P(SobelTestGPU32F, SobelTest,
|
||||
Values(0, 1),
|
||||
Values(1, 2)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(LaplacianTestGPU, LaplacianTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(IMGPROC_GPU),
|
||||
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
|
||||
Values(5),
|
||||
Values(3.0),
|
||||
Values(BORDER_DEFAULT)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BilateralFilterTestGPU, BilateralFilterTest,
|
||||
Combine(Values(CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3),
|
||||
Values(cv::Size(1280, 720),
|
||||
cv::Size(640, 480)),
|
||||
Values(-1),
|
||||
Values(IMGPROC_GPU),
|
||||
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
|
||||
Values(9),
|
||||
Values(100),
|
||||
Values(40),
|
||||
Values(BORDER_DEFAULT)));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(EqHistTestGPU, EqHistTest,
|
||||
Combine(Values(CV_8UC1),
|
||||
Values(cv::Size(1280, 720),
|
||||
|
Loading…
Reference in New Issue
Block a user