diff --git a/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp b/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp index f57f84cdeb..5a13cfeebe 100644 --- a/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp +++ b/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp @@ -754,7 +754,7 @@ PERF_TEST_P_(RGB2LabPerfTest, TestPerformance) TEST_CYCLE() { - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi); } // Comparison ////////////////////////////////////////////////////////////// @@ -792,7 +792,7 @@ PERF_TEST_P_(BGR2LUVPerfTest, TestPerformance) TEST_CYCLE() { - c.apply(in_mat1, out_mat_gapi, std::move(compile_args)); + c.apply(in_mat1, out_mat_gapi); } // Comparison ////////////////////////////////////////////////////////////// diff --git a/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp b/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp index f0846a7dee..a5d13e661d 100644 --- a/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp +++ b/modules/gapi/perf/cpu/gapi_imgproc_perf_tests_fluid.cpp @@ -63,4 +63,14 @@ namespace opencv_test Values(szVGA, sz720p, sz1080p), Values(cv::compile_args(IMGPROC_FLUID)))); + INSTANTIATE_TEST_CASE_P(BGR2LUVPerfTestFluid, BGR2LUVPerfTest, + Combine(Values(AbsSimilarPoints(1, 0.05).to_compare_f()), + Values(szVGA, sz720p, sz1080p), + Values(cv::compile_args(IMGPROC_FLUID)))); + + INSTANTIATE_TEST_CASE_P(RGB2LabPerfTestFluid, RGB2LabPerfTest, + Combine(Values(AbsSimilarPoints(1, 0.05).to_compare_f()), + Values(szVGA, sz720p, sz1080p), + Values(cv::compile_args(IMGPROC_FLUID)))); + } diff --git a/modules/gapi/src/backends/fluid/gfluidimgproc.cpp b/modules/gapi/src/backends/fluid/gfluidimgproc.cpp index 01d166472e..e2e4c4f754 100644 --- a/modules/gapi/src/backends/fluid/gfluidimgproc.cpp +++ b/modules/gapi/src/backends/fluid/gfluidimgproc.cpp @@ -27,7 +27,8 @@ #include "gfluidimgproc_func.hpp" -#include +#include "opencv2/imgproc/hal/hal.hpp" +#include "opencv2/core/hal/intrin.hpp" #include #include @@ -173,6 +174,10 @@ GAPI_FLUID_KERNEL(GFluidYUV2RGB, cv::gapi::imgproc::GYUV2RGB, false) enum LabLUV { LL_Lab, LL_LUV }; +#define LabLuv_reference 0 // 1=use reference code of RGB/BGR to LUV/Lab, 0=don't + +#if LabLuv_reference + // gamma-correction (inverse) for sRGB, 1/gamma=2.4 for inverse, like for Mac OS (?) static inline float f_gamma(float x) { @@ -230,22 +235,9 @@ static inline void f_xyz2luv(float X, float Y, float Z, v = 13*L * (v1 - vn); } -// compile-time parameters: output format (Lab/LUV), -// and position of blue channel in BGR/RGB (0 or 2) template -static void run_rgb2labluv(Buffer &dst, const View &src) +static void run_rgb2labluv_reference(uchar out[], const uchar in[], int width) { - GAPI_Assert(src.meta().depth == CV_8U); - GAPI_Assert(dst.meta().depth == CV_8U); - GAPI_Assert(src.meta().chan == 3); - GAPI_Assert(dst.meta().chan == 3); - GAPI_Assert(src.length() == dst.length()); - - const auto *in = src.InLine(0); - auto *out = dst.OutLine(); - - int width = dst.length(); - for (int w=0; w < width; w++) { float R, G, B; @@ -284,6 +276,42 @@ static void run_rgb2labluv(Buffer &dst, const View &src) } } +#endif // LabLuv_reference + +// compile-time parameters: output format (Lab/LUV), +// and position of blue channel in BGR/RGB (0 or 2) +template +static void run_rgb2labluv(Buffer &dst, const View &src) +{ + GAPI_Assert(src.meta().depth == CV_8U); + GAPI_Assert(dst.meta().depth == CV_8U); + GAPI_Assert(src.meta().chan == 3); + GAPI_Assert(dst.meta().chan == 3); + GAPI_Assert(src.length() == dst.length()); + + const auto *in = src.InLine(0); + auto *out = dst.OutLine(); + + int width = dst.length(); + +#if LabLuv_reference + run_rgb2labluv_reference(out, in, width); +#else + uchar *dst_data = out; + const uchar *src_data = in; + size_t src_step = width; + size_t dst_step = width; + int height = 1; + int depth = CV_8U; + int scn = 3; + bool swapBlue = (blue == 2); + bool isLab = (LL_Lab == labluv); + bool srgb = true; + cv::hal::cvtBGRtoLab(src_data, src_step, dst_data, dst_step, + width, height, depth, scn, swapBlue, isLab, srgb); +#endif +} + GAPI_FLUID_KERNEL(GFluidRGB2Lab, cv::gapi::imgproc::GRGB2Lab, false) { static const int Window = 1;