Path: blob/master/modules/gapi/perf/common/gapi_imgproc_perf_tests_inl.hpp
16358 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.3//4// Copyright (C) 2018 Intel Corporation567#ifndef OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP8#define OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP91011#include <iostream>1213#include "gapi_imgproc_perf_tests.hpp"1415namespace opencv_test16{1718using namespace perf;1920//------------------------------------------------------------------------------2122PERF_TEST_P_(SepFilterPerfTest, TestPerformance)23{24compare_f cmpF;25MatType type = 0;26int kernSize = 0, dtype = 0;27cv::Size sz;28cv::GCompileArgs compile_args;29std::tie(cmpF, type, kernSize, sz, dtype, compile_args) = GetParam();3031cv::Mat kernelX(kernSize, 1, CV_32F);32cv::Mat kernelY(kernSize, 1, CV_32F);33randu(kernelX, -1, 1);34randu(kernelY, -1, 1);35initMatsRandN(type, sz, dtype, false);3637cv::Point anchor = cv::Point(-1, -1);3839// OpenCV code /////////////////////////////////////////////////////////////40{41cv::sepFilter2D(in_mat1, out_mat_ocv, dtype, kernelX, kernelY );42}4344// G-API code //////////////////////////////////////////////////////////////45cv::GMat in;46auto out = cv::gapi::sepFilter(in, dtype, kernelX, kernelY, anchor, cv::Scalar() );47cv::GComputation c(in, out);4849// Warm-up graph engine:50c.apply(in_mat1, out_mat_gapi, std::move(compile_args));5152TEST_CYCLE()53{54c.apply(in_mat1, out_mat_gapi, std::move(compile_args));55}5657// Comparison //////////////////////////////////////////////////////////////58{59EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));60EXPECT_EQ(out_mat_gapi.size(), sz);61}6263SANITY_CHECK_NOTHING();64}6566//------------------------------------------------------------------------------6768PERF_TEST_P_(Filter2DPerfTest, TestPerformance)69{70compare_f cmpF;71MatType type = 0;72int kernSize = 0, borderType = 0, dtype = 0;73cv::Size sz;74cv::GCompileArgs compile_args;75std::tie(cmpF, type, kernSize, sz, borderType, dtype, compile_args) = GetParam();7677initMatsRandN(type, sz, dtype, false);7879cv::Point anchor = {-1, -1};80double delta = 0;8182cv::Mat kernel = cv::Mat(kernSize, kernSize, CV_32FC1 );83cv::Scalar kernMean = cv::Scalar::all(1.0);84cv::Scalar kernStddev = cv::Scalar::all(2.0/3);85randn(kernel, kernMean, kernStddev);8687// OpenCV code /////////////////////////////////////////////////////////////88{89cv::filter2D(in_mat1, out_mat_ocv, dtype, kernel, anchor, delta, borderType);90}9192// G-API code //////////////////////////////////////////////////////////////93cv::GMat in;94auto out = cv::gapi::filter2D(in, dtype, kernel, anchor, delta, borderType);95cv::GComputation c(in, out);9697// Warm-up graph engine:98c.apply(in_mat1, out_mat_gapi, std::move(compile_args));99100TEST_CYCLE()101{102c.apply(in_mat1, out_mat_gapi, std::move(compile_args));103}104105// Comparison //////////////////////////////////////////////////////////////106{107EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));108EXPECT_EQ(out_mat_gapi.size(), sz);109}110111112SANITY_CHECK_NOTHING();113114}115116//------------------------------------------------------------------------------117118PERF_TEST_P_(BoxFilterPerfTest, TestPerformance)119{120compare_f cmpF;121MatType type = 0;122int filterSize = 0, borderType = 0, dtype = 0;123cv::Size sz;124cv::GCompileArgs compile_args;125std::tie(cmpF, type, filterSize, sz, borderType, dtype, compile_args) = GetParam();126127initMatsRandN(type, sz, dtype, false);128129cv::Point anchor = {-1, -1};130bool normalize = true;131132// OpenCV code /////////////////////////////////////////////////////////////133{134cv::boxFilter(in_mat1, out_mat_ocv, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);135}136137// G-API code //////////////////////////////////////////////////////////////138cv::GMat in;139auto out = cv::gapi::boxFilter(in, dtype, cv::Size(filterSize, filterSize), anchor, normalize, borderType);140cv::GComputation c(in, out);141142// Warm-up graph engine:143c.apply(in_mat1, out_mat_gapi, std::move(compile_args));144145TEST_CYCLE()146{147c.apply(in_mat1, out_mat_gapi, std::move(compile_args));148}149150// Comparison //////////////////////////////////////////////////////////////151{152EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));153EXPECT_EQ(out_mat_gapi.size(), sz);154}155156SANITY_CHECK_NOTHING();157158}159160//------------------------------------------------------------------------------161162PERF_TEST_P_(BlurPerfTest, TestPerformance)163{164compare_f cmpF;165MatType type = 0;166int filterSize = 0, borderType = 0;167cv::Size sz;168cv::GCompileArgs compile_args;169std::tie(cmpF, type, filterSize, sz, borderType, compile_args) = GetParam();170171initMatsRandN(type, sz, type, false);172173cv::Point anchor = {-1, -1};174175// OpenCV code /////////////////////////////////////////////////////////////176{177cv::blur(in_mat1, out_mat_ocv, cv::Size(filterSize, filterSize), anchor, borderType);178}179180// G-API code //////////////////////////////////////////////////////////////181cv::GMat in;182auto out = cv::gapi::blur(in, cv::Size(filterSize, filterSize), anchor, borderType);183cv::GComputation c(in, out);184185// Warm-up graph engine:186c.apply(in_mat1, out_mat_gapi, std::move(compile_args));187188TEST_CYCLE()189{190c.apply(in_mat1, out_mat_gapi, std::move(compile_args));191}192193// Comparison //////////////////////////////////////////////////////////////194{195EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));196EXPECT_EQ(out_mat_gapi.size(), sz);197}198199SANITY_CHECK_NOTHING();200201}202203//------------------------------------------------------------------------------204205PERF_TEST_P_(GaussianBlurPerfTest, TestPerformance)206{207compare_f cmpF;208MatType type = 0;209int kernSize = 0;210cv::Size sz;211cv::GCompileArgs compile_args;212std::tie(cmpF, type, kernSize, sz, compile_args) = GetParam();213214cv::Size kSize = cv::Size(kernSize, kernSize);215auto& rng = cv::theRNG();216double sigmaX = rng();217initMatsRandN(type, sz, type, false);218219// OpenCV code ///////////////////////////////////////////////////////////220cv::GaussianBlur(in_mat1, out_mat_ocv, kSize, sigmaX);221222// G-API code //////////////////////////////////////////////////////////////223cv::GMat in;224auto out = cv::gapi::gaussianBlur(in, kSize, sigmaX);225cv::GComputation c(in, out);226227// Warm-up graph engine:228c.apply(in_mat1, out_mat_gapi, std::move(compile_args));229230TEST_CYCLE()231{232c.apply(in_mat1, out_mat_gapi, std::move(compile_args));233}234235// Comparison //////////////////////////////////////////////////////////////236{237EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));238EXPECT_EQ(out_mat_gapi.size(), sz);239}240241242SANITY_CHECK_NOTHING();243}244245//------------------------------------------------------------------------------246247PERF_TEST_P_(MedianBlurPerfTest, TestPerformance)248{249compare_f cmpF;250MatType type = 0;251int kernSize = 0;252cv::Size sz;253cv::GCompileArgs compile_args;254std::tie(cmpF, type, kernSize, sz, compile_args) = GetParam();255256initMatsRandN(type, sz, type, false);257258// OpenCV code /////////////////////////////////////////////////////////////259{260cv::medianBlur(in_mat1, out_mat_ocv, kernSize);261}262263// G-API code //////////////////////////////////////////////////////////////264cv::GMat in;265auto out = cv::gapi::medianBlur(in, kernSize);266cv::GComputation c(in, out);267268// Warm-up graph engine:269c.apply(in_mat1, out_mat_gapi, std::move(compile_args));270271TEST_CYCLE()272{273c.apply(in_mat1, out_mat_gapi, std::move(compile_args));274}275276// Comparison //////////////////////////////////////////////////////////////277{278EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));279EXPECT_EQ(out_mat_gapi.size(), sz);280}281282SANITY_CHECK_NOTHING();283284}285286//------------------------------------------------------------------------------287288PERF_TEST_P_(ErodePerfTest, TestPerformance)289{290compare_f cmpF;291MatType type = 0;292int kernSize = 0, kernType = 0;293cv::Size sz;294cv::GCompileArgs compile_args;295std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam();296297initMatsRandN(type, sz, type, false);298299cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));300301// OpenCV code /////////////////////////////////////////////////////////////302{303cv::erode(in_mat1, out_mat_ocv, kernel);304}305306// G-API code //////////////////////////////////////////////////////////////307cv::GMat in;308auto out = cv::gapi::erode(in, kernel);309cv::GComputation c(in, out);310311// Warm-up graph engine:312c.apply(in_mat1, out_mat_gapi, std::move(compile_args));313314TEST_CYCLE()315{316c.apply(in_mat1, out_mat_gapi, std::move(compile_args));317}318319// Comparison //////////////////////////////////////////////////////////////320{321EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));322EXPECT_EQ(out_mat_gapi.size(), sz);323}324325SANITY_CHECK_NOTHING();326327}328329//------------------------------------------------------------------------------330331PERF_TEST_P_(Erode3x3PerfTest, TestPerformance)332{333compare_f cmpF;334MatType type = 0;335int numIters = 0;336cv::Size sz;337cv::GCompileArgs compile_args;338std::tie(cmpF, type, sz, numIters, compile_args) = GetParam();339340initMatsRandN(type, sz, type, false);341342cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3));343344// OpenCV code /////////////////////////////////////////////////////////////345{346cv::erode(in_mat1, out_mat_ocv, kernel, cv::Point(-1, -1), numIters);347}348349// G-API code //////////////////////////////////////////////////////////////350cv::GMat in;351auto out = cv::gapi::erode3x3(in, numIters);352cv::GComputation c(in, out);353354// Warm-up graph engine:355c.apply(in_mat1, out_mat_gapi, std::move(compile_args));356357TEST_CYCLE()358{359c.apply(in_mat1, out_mat_gapi, std::move(compile_args));360}361362// Comparison //////////////////////////////////////////////////////////////363{364EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));365EXPECT_EQ(out_mat_gapi.size(), sz);366}367368SANITY_CHECK_NOTHING();369370}371372//------------------------------------------------------------------------------373374PERF_TEST_P_(DilatePerfTest, TestPerformance)375{376compare_f cmpF;377MatType type = 0;378int kernSize = 0, kernType = 0;379cv::Size sz;380cv::GCompileArgs compile_args;381std::tie(cmpF, type, kernSize, sz, kernType, compile_args) = GetParam();382383initMatsRandN(type, sz, type, false);384385cv::Mat kernel = cv::getStructuringElement(kernType, cv::Size(kernSize, kernSize));386387// OpenCV code /////////////////////////////////////////////////////////////388{389cv::dilate(in_mat1, out_mat_ocv, kernel);390}391392// G-API code //////////////////////////////////////////////////////////////393cv::GMat in;394auto out = cv::gapi::dilate(in, kernel);395cv::GComputation c(in, out);396397// Warm-up graph engine:398c.apply(in_mat1, out_mat_gapi, std::move(compile_args));399400TEST_CYCLE()401{402c.apply(in_mat1, out_mat_gapi, std::move(compile_args));403}404405// Comparison //////////////////////////////////////////////////////////////406{407EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));408EXPECT_EQ(out_mat_gapi.size(), sz);409}410411SANITY_CHECK_NOTHING();412413}414415//------------------------------------------------------------------------------416417PERF_TEST_P_(Dilate3x3PerfTest, TestPerformance)418{419compare_f cmpF;420MatType type = 0;421int numIters = 0;422cv::Size sz;423cv::GCompileArgs compile_args;424std::tie(cmpF, type, sz, numIters, compile_args) = GetParam();425426initMatsRandN(type, sz, type, false);427428cv::Mat kernel = cv::getStructuringElement(cv::MorphShapes::MORPH_RECT, cv::Size(3, 3));429430// OpenCV code /////////////////////////////////////////////////////////////431{432cv::dilate(in_mat1, out_mat_ocv, kernel, cv::Point(-1,-1), numIters);433}434435// G-API code //////////////////////////////////////////////////////////////436cv::GMat in;437auto out = cv::gapi::dilate3x3(in, numIters);438cv::GComputation c(in, out);439440// Warm-up graph engine:441c.apply(in_mat1, out_mat_gapi, std::move(compile_args));442443TEST_CYCLE()444{445c.apply(in_mat1, out_mat_gapi, std::move(compile_args));446}447448// Comparison //////////////////////////////////////////////////////////////449{450EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));451EXPECT_EQ(out_mat_gapi.size(), sz);452}453454SANITY_CHECK_NOTHING();455456}457458//------------------------------------------------------------------------------459460PERF_TEST_P_(SobelPerfTest, TestPerformance)461{462compare_f cmpF;463MatType type = 0;464int kernSize = 0, dtype = 0, dx = 0, dy = 0;465cv::Size sz;466cv::GCompileArgs compile_args;467std::tie(cmpF, type, kernSize, sz, dtype, dx, dy, compile_args) = GetParam();468469initMatsRandN(type, sz, dtype, false);470471// OpenCV code /////////////////////////////////////////////////////////////472{473cv::Sobel(in_mat1, out_mat_ocv, dtype, dx, dy, kernSize);474}475476// G-API code //////////////////////////////////////////////////////////////477cv::GMat in;478auto out = cv::gapi::Sobel(in, dtype, dx, dy, kernSize );479cv::GComputation c(in, out);480481// Warm-up graph engine:482c.apply(in_mat1, out_mat_gapi, std::move(compile_args));483484TEST_CYCLE()485{486c.apply(in_mat1, out_mat_gapi, std::move(compile_args));487}488489// Comparison //////////////////////////////////////////////////////////////490{491EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));492EXPECT_EQ(out_mat_gapi.size(), sz);493}494495SANITY_CHECK_NOTHING();496497}498499//------------------------------------------------------------------------------500501PERF_TEST_P_(CannyPerfTest, TestPerformance)502{503compare_f cmpF;504MatType type;505int apSize = 0;506double thrLow = 0.0, thrUp = 0.0;507cv::Size sz;508bool l2gr = false;509cv::GCompileArgs compile_args;510std::tie(cmpF, type, sz, thrLow, thrUp, apSize, l2gr, compile_args) = GetParam();511512initMatsRandN(type, sz, CV_8UC1, false);513514// OpenCV code /////////////////////////////////////////////////////////////515{516cv::Canny(in_mat1, out_mat_ocv, thrLow, thrUp, apSize, l2gr);517}518519// G-API code //////////////////////////////////////////////////////////////520cv::GMat in;521auto out = cv::gapi::Canny(in, thrLow, thrUp, apSize, l2gr);522cv::GComputation c(in, out);523524// Warm-up graph engine:525c.apply(in_mat1, out_mat_gapi, std::move(compile_args));526527TEST_CYCLE()528{529c.apply(in_mat1, out_mat_gapi, std::move(compile_args));530}531532// Comparison //////////////////////////////////////////////////////////////533{534EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));535EXPECT_EQ(out_mat_gapi.size(), sz);536}537538SANITY_CHECK_NOTHING();539540}541542//------------------------------------------------------------------------------543544PERF_TEST_P_(EqHistPerfTest, TestPerformance)545{546compare_f cmpF = get<0>(GetParam());547Size sz = get<1>(GetParam());548cv::GCompileArgs compile_args = get<2>(GetParam());549550initMatsRandN(CV_8UC1, sz, CV_8UC1, false);551552// OpenCV code /////////////////////////////////////////////////////////////553{554cv::equalizeHist(in_mat1, out_mat_ocv);555}556557// G-API code //////////////////////////////////////////////////////////////558cv::GMat in;559auto out = cv::gapi::equalizeHist(in);560cv::GComputation c(in, out);561562// Warm-up graph engine:563c.apply(in_mat1, out_mat_gapi, std::move(compile_args));564565TEST_CYCLE()566{567c.apply(in_mat1, out_mat_gapi, std::move(compile_args));568}569570// Comparison //////////////////////////////////////////////////////////////571{572EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));573EXPECT_EQ(out_mat_gapi.size(), sz);574}575576SANITY_CHECK_NOTHING();577578}579580//------------------------------------------------------------------------------581582PERF_TEST_P_(RGB2GrayPerfTest, TestPerformance)583{584compare_f cmpF = get<0>(GetParam());585Size sz = get<1>(GetParam());586cv::GCompileArgs compile_args = get<2>(GetParam());587588initMatsRandN(CV_8UC3, sz, CV_8UC1, false);589590// OpenCV code /////////////////////////////////////////////////////////////591{592cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2GRAY);593}594595// G-API code //////////////////////////////////////////////////////////////596cv::GMat in;597auto out = cv::gapi::RGB2Gray(in);598cv::GComputation c(in, out);599600// Warm-up graph engine:601c.apply(in_mat1, out_mat_gapi, std::move(compile_args));602603TEST_CYCLE()604{605c.apply(in_mat1, out_mat_gapi, std::move(compile_args));606}607608// Comparison //////////////////////////////////////////////////////////////609{610EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));611EXPECT_EQ(out_mat_gapi.size(), sz);612}613614SANITY_CHECK_NOTHING();615616}617618//------------------------------------------------------------------------------619620PERF_TEST_P_(BGR2GrayPerfTest, TestPerformance)621{622compare_f cmpF = get<0>(GetParam());623Size sz = get<1>(GetParam());624cv::GCompileArgs compile_args = get<2>(GetParam());625626initMatsRandN(CV_8UC3, sz, CV_8UC1, false);627628// OpenCV code /////////////////////////////////////////////////////////////629{630cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2GRAY);631}632633// G-API code //////////////////////////////////////////////////////////////634cv::GMat in;635auto out = cv::gapi::BGR2Gray(in);636cv::GComputation c(in, out);637638// Warm-up graph engine:639c.apply(in_mat1, out_mat_gapi, std::move(compile_args));640641TEST_CYCLE()642{643c.apply(in_mat1, out_mat_gapi, std::move(compile_args));644}645646// Comparison //////////////////////////////////////////////////////////////647{648EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));649EXPECT_EQ(out_mat_gapi.size(), sz);650}651652SANITY_CHECK_NOTHING();653654}655656//------------------------------------------------------------------------------657658PERF_TEST_P_(RGB2YUVPerfTest, TestPerformance)659{660compare_f cmpF = get<0>(GetParam());661Size sz = get<1>(GetParam());662cv::GCompileArgs compile_args = get<2>(GetParam());663664initMatsRandN(CV_8UC3, sz, CV_8UC3, false);665666// OpenCV code /////////////////////////////////////////////////////////////667{668cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2YUV);669}670671// G-API code //////////////////////////////////////////////////////////////672cv::GMat in;673auto out = cv::gapi::RGB2YUV(in);674cv::GComputation c(in, out);675676// Warm-up graph engine:677c.apply(in_mat1, out_mat_gapi, std::move(compile_args));678679TEST_CYCLE()680{681c.apply(in_mat1, out_mat_gapi, std::move(compile_args));682}683684// Comparison //////////////////////////////////////////////////////////////685{686EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));687EXPECT_EQ(out_mat_gapi.size(), sz);688}689690SANITY_CHECK_NOTHING();691692}693694//------------------------------------------------------------------------------695696PERF_TEST_P_(YUV2RGBPerfTest, TestPerformance)697{698compare_f cmpF = get<0>(GetParam());699Size sz = get<1>(GetParam());700cv::GCompileArgs compile_args = get<2>(GetParam());701702initMatsRandN(CV_8UC3, sz, CV_8UC3, false);703704// OpenCV code /////////////////////////////////////////////////////////////705{706cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2RGB);707}708709// G-API code //////////////////////////////////////////////////////////////710cv::GMat in;711auto out = cv::gapi::YUV2RGB(in);712cv::GComputation c(in, out);713714// Warm-up graph engine:715c.apply(in_mat1, out_mat_gapi, std::move(compile_args));716717TEST_CYCLE()718{719c.apply(in_mat1, out_mat_gapi, std::move(compile_args));720}721722// Comparison //////////////////////////////////////////////////////////////723{724EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));725EXPECT_EQ(out_mat_gapi.size(), sz);726}727728SANITY_CHECK_NOTHING();729730}731732//------------------------------------------------------------------------------733734PERF_TEST_P_(RGB2LabPerfTest, TestPerformance)735{736compare_f cmpF = get<0>(GetParam());737Size sz = get<1>(GetParam());738cv::GCompileArgs compile_args = get<2>(GetParam());739740initMatsRandN(CV_8UC3, sz, CV_8UC3, false);741742// OpenCV code /////////////////////////////////////////////////////////////743{744cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_RGB2Lab);745}746747// G-API code //////////////////////////////////////////////////////////////748cv::GMat in;749auto out = cv::gapi::RGB2Lab(in);750cv::GComputation c(in, out);751752// Warm-up graph engine:753c.apply(in_mat1, out_mat_gapi, std::move(compile_args));754755TEST_CYCLE()756{757c.apply(in_mat1, out_mat_gapi, std::move(compile_args));758}759760// Comparison //////////////////////////////////////////////////////////////761{762EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));763EXPECT_EQ(out_mat_gapi.size(), sz);764}765766SANITY_CHECK_NOTHING();767768}769770//------------------------------------------------------------------------------771772PERF_TEST_P_(BGR2LUVPerfTest, TestPerformance)773{774compare_f cmpF = get<0>(GetParam());775Size sz = get<1>(GetParam());776cv::GCompileArgs compile_args = get<2>(GetParam());777778initMatsRandN(CV_8UC3, sz, CV_8UC3, false);779780// OpenCV code /////////////////////////////////////////////////////////////781{782cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2Luv);783}784785// G-API code //////////////////////////////////////////////////////////////786cv::GMat in;787auto out = cv::gapi::BGR2LUV(in);788cv::GComputation c(in, out);789790// Warm-up graph engine:791c.apply(in_mat1, out_mat_gapi, std::move(compile_args));792793TEST_CYCLE()794{795c.apply(in_mat1, out_mat_gapi, std::move(compile_args));796}797798// Comparison //////////////////////////////////////////////////////////////799{800EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));801EXPECT_EQ(out_mat_gapi.size(), sz);802}803804SANITY_CHECK_NOTHING();805806}807808//------------------------------------------------------------------------------809810PERF_TEST_P_(LUV2BGRPerfTest, TestPerformance)811{812compare_f cmpF = get<0>(GetParam());813Size sz = get<1>(GetParam());814cv::GCompileArgs compile_args = get<2>(GetParam());815816initMatsRandN(CV_8UC3, sz, CV_8UC3, false);817818// OpenCV code /////////////////////////////////////////////////////////////819{820cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_Luv2BGR);821}822823// G-API code //////////////////////////////////////////////////////////////824cv::GMat in;825auto out = cv::gapi::LUV2BGR(in);826cv::GComputation c(in, out);827828// Warm-up graph engine:829c.apply(in_mat1, out_mat_gapi, std::move(compile_args));830831TEST_CYCLE()832{833c.apply(in_mat1, out_mat_gapi, std::move(compile_args));834}835836// Comparison //////////////////////////////////////////////////////////////837{838EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));839EXPECT_EQ(out_mat_gapi.size(), sz);840}841842SANITY_CHECK_NOTHING();843844}845846//------------------------------------------------------------------------------847848PERF_TEST_P_(BGR2YUVPerfTest, TestPerformance)849{850compare_f cmpF = get<0>(GetParam());851Size sz = get<1>(GetParam());852cv::GCompileArgs compile_args = get<2>(GetParam());853854initMatsRandN(CV_8UC3, sz, CV_8UC3, false);855856cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_BGR2YUV);857858cv::GMat in;859auto out = cv::gapi::BGR2YUV(in);860cv::GComputation c(in, out);861862// Warm-up graph engine:863c.apply(in_mat1, out_mat_gapi, std::move(compile_args));864865TEST_CYCLE()866{867c.apply(in_mat1, out_mat_gapi, std::move(compile_args));868}869870EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));871EXPECT_EQ(out_mat_gapi.size(), sz);872873SANITY_CHECK_NOTHING();874}875876//------------------------------------------------------------------------------877878PERF_TEST_P_(YUV2BGRPerfTest, TestPerformance)879{880compare_f cmpF = get<0>(GetParam());881Size sz = get<1>(GetParam());882cv::GCompileArgs compile_args = get<2>(GetParam());883884initMatsRandN(CV_8UC3, sz, CV_8UC3, false);885886cv::cvtColor(in_mat1, out_mat_ocv, cv::COLOR_YUV2BGR);887888cv::GMat in;889auto out = cv::gapi::YUV2BGR(in);890cv::GComputation c(in, out);891892// Warm-up graph engine:893c.apply(in_mat1, out_mat_gapi, std::move(compile_args));894895TEST_CYCLE()896{897c.apply(in_mat1, out_mat_gapi, std::move(compile_args));898}899900EXPECT_TRUE(cmpF(out_mat_gapi, out_mat_ocv));901EXPECT_EQ(out_mat_gapi.size(), sz);902903SANITY_CHECK_NOTHING();904}905906//------------------------------------------------------------------------------907908}909#endif //OPENCV_GAPI_IMGPROC_PERF_TESTS_INL_HPP910911912