123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827 |
- // This file is part of OpenCV project.
- // It is subject to the license terms in the LICENSE file found in the top-level directory
- // of this distribution and at http://opencv.org/license.html.
- //
- // Copyright (C) 2020 Intel Corporation
- #include "gapi_render_perf_tests.hpp"
- namespace opencv_test
- {
- namespace {
- void create_rand_mats(const cv::Size &size, MatType type, cv::Mat &ref_mat, cv::Mat &gapi_mat)
- {
- ref_mat.create(size, type);
- cv::randu(ref_mat, cv::Scalar::all(0), cv::Scalar::all(255));
- ref_mat.copyTo(gapi_mat);
- };
- } // namespace
- PERF_TEST_P_(RenderTestFTexts, RenderFTextsPerformanceBGROCVTest)
- {
- std::wstring text;
- cv::Size sz;
- cv::Point org;
- int fh = 0;
- cv::Scalar color;
- cv::GCompileArgs comp_args;
- std::tie(text ,sz ,org ,fh ,color, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::FText{text, org, fh, color});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestFTexts, RenderFTextsPerformanceNV12OCVTest)
- {
- std::wstring text;
- cv::Size sz;
- cv::Point org;
- int fh = 0;
- cv::Scalar color;
- cv::GCompileArgs comp_args;
- std::tie(text ,sz ,org ,fh ,color, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::FText{text, org, fh, color});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestTexts, RenderTextsPerformanceBGROCVTest)
- {
- cv::Point org;
- int ff = 0;
- int thick = 0;
- int lt = 0;
- double fs = 2.0;
- cv::Scalar color;
- bool blo = false;
- std::string text;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(text, sz, org, ff, color, thick, lt, blo, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Text{text, org, ff, fs, color, thick, lt, blo});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestTexts, RenderTextsPerformanceNV12OCVTest)
- {
- cv::Point org;
- int ff = 0;
- int thick = 0;
- int lt = 0;
- double fs = 2.0;
- cv::Scalar color;
- bool blo = false;
- std::string text;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(text, sz, org, ff, color, thick, lt, blo, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Text{text, org, ff, fs, color, thick, lt, blo});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestRects, RenderRectsPerformanceBGROCVTest)
- {
- cv::Rect rect;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, rect, color, thick, lt, shift, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Rect{rect, color, thick, lt, shift});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestRects, RenderRectsPerformanceNV12OCVTest)
- {
- cv::Rect rect;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, rect, color, thick, lt, shift, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Rect{rect, color, thick, lt, shift});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestCircles, RenderCirclesPerformanceBGROCVTest)
- {
- cv::Point center;
- int radius;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, center, radius, color, thick, lt, shift, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Circle{center, radius, color, thick, lt, shift});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestCircles, RenderCirclesPerformanceNV12OCVTest)
- {
- cv::Point center;
- int radius;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, center, radius, color, thick, lt, shift, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Circle{center, radius, color, thick, lt, shift});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestLines, RenderLinesPerformanceBGROCVTest)
- {
- cv::Point pt1;
- cv::Point pt2;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- compare_f cmpF;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, pt1, pt2, color, thick, lt, shift, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Line{pt1, pt2, color, thick, lt, shift});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestLines, RenderLinesPerformanceNV12OCVTest)
- {
- cv::Point pt1;
- cv::Point pt2;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- compare_f cmpF;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, pt1, pt2, color, thick, lt, shift, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Line{pt1, pt2, color, thick, lt, shift});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestMosaics, RenderMosaicsPerformanceBGROCVTest)
- {
- cv::Rect mos;
- int cellsz = 0;
- int decim = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, mos, cellsz, decim, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Mosaic{mos, cellsz, decim});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestMosaics, RenderMosaicsPerformanceNV12OCVTest)
- {
- cv::Rect mos;
- int cellsz = 0;
- int decim = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, mos, cellsz, decim, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Mosaic{mos, cellsz, decim});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestImages, RenderImagesPerformanceBGROCVTest)
- {
- cv::Rect rect;
- cv::Scalar color;
- double transparency = 0.0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, rect, color, transparency, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- cv::Mat img(rect.size(), CV_8UC3, color);
- cv::Mat alpha(rect.size(), CV_32FC1, transparency);
- auto tl = rect.tl();
- cv::Point org = {tl.x, tl.y + rect.size().height};
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Image{org, img, alpha});
- cv::gapi::wip::draw::render(gapi_mat, prims);
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestImages, RenderImagesPerformanceNV12OCVTest)
- {
- cv::Rect rect;
- cv::Scalar color;
- double transparency = 0.0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, rect, color, transparency, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- cv::Mat img(rect.size(), CV_8UC3, color);
- cv::Mat alpha(rect.size(), CV_32FC1, transparency);
- auto tl = rect.tl();
- cv::Point org = {tl.x, tl.y + rect.size().height};
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Image{org, img, alpha});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestPolylines, RenderPolylinesPerformanceBGROCVTest)
- {
- std::vector<cv::Point> points;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, points, color, thick, lt, shift, comp_args) = GetParam();
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Poly{points, color, thick, lt, shift});
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestPolylines, RenderPolylinesPerformanceNV12OCVTest)
- {
- std::vector<cv::Point> points;
- cv::Scalar color;
- int thick = 0;
- int lt = 0;
- int shift = 0;
- cv::Size sz;
- cv::GCompileArgs comp_args;
- std::tie(sz, points, color, thick, lt, shift, comp_args) = GetParam();
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- prims.emplace_back(cv::gapi::wip::draw::Poly{points, color, thick, lt, shift});
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestPolyItems, RenderPolyItemsPerformanceBGROCVTest)
- {
- cv::Size sz;
- int rects_num = 0;
- int text_num = 0;
- int image_num = 0;
- cv::GCompileArgs comp_args;
- std::tie(sz, rects_num, text_num, image_num, comp_args) = GetParam();
- int thick = 2;
- int lt = LINE_8;
- cv::Scalar color(100, 50, 150);
- MatType type = CV_8UC3;
- cv::Mat gapi_mat, ref_mat;
- create_rand_mats(sz, type, ref_mat, gapi_mat);
- cv::Mat gapi_out_mat(sz, type);
- gapi_mat.copyTo(gapi_out_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- // Rects
- int shift = 0;
- for (int i = 0; i < rects_num; ++i) {
- cv::Rect rect(200 + i, 200 + i, 200, 200);
- prims.emplace_back(cv::gapi::wip::draw::Rect(rect, color, thick, lt, shift));
- }
- // Mosaic
- int cellsz = 25;
- int decim = 0;
- for (int i = 0; i < rects_num; ++i) {
- cv::Rect mos(200 + i, 200 + i, 200, 200);
- prims.emplace_back(cv::gapi::wip::draw::Mosaic(mos, cellsz, decim));
- }
- // Text
- std::string text = "Some text";
- int ff = FONT_HERSHEY_SIMPLEX;
- double fs = 2.0;
- bool blo = false;
- for (int i = 0; i < text_num; ++i) {
- cv::Point org(200 + i, 200 + i);
- prims.emplace_back(cv::gapi::wip::draw::Text(text, org, ff, fs, color, thick, lt, blo));
- }
- // Image
- double transparency = 1.0;
- cv::Rect rect_img(0 ,0 , 50, 50);
- cv::Mat img(rect_img.size(), CV_8UC3, color);
- cv::Mat alpha(rect_img.size(), CV_32FC1, transparency);
- auto tl = rect_img.tl();
- for (int i = 0; i < image_num; ++i) {
- cv::Point org_img = {tl.x + i, tl.y + rect_img.size().height + i};
- prims.emplace_back(cv::gapi::wip::draw::Image({org_img, img, alpha}));
- }
- cv::GMat in;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- cv::GComputation comp(cv::GIn(in, arr),
- cv::GOut(cv::gapi::wip::draw::render3ch(in, arr)));
- // Warm-up graph engine:
- comp.apply(gin(gapi_mat, prims), gout(gapi_out_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(gin(gapi_mat, prims), gout(gapi_out_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- PERF_TEST_P_(RenderTestPolyItems, RenderPolyItemsPerformanceNV12OCVTest)
- {
- cv::Size sz;
- int rects_num = 0;
- int text_num = 0;
- int image_num = 0;
- cv::GCompileArgs comp_args;
- std::tie(sz, rects_num, text_num, image_num, comp_args) = GetParam();
- int thick = 2;
- int lt = LINE_8;
- cv::Scalar color(100, 50, 150);
- cv::Mat y_ref_mat, uv_ref_mat;
- cv::Mat y_in_gapi_mat, uv_in_gapi_mat,
- y_out_gapi_mat, uv_out_gapi_mat;
- create_rand_mats(sz, CV_8UC1, y_ref_mat, y_in_gapi_mat);
- create_rand_mats(sz / 2, CV_8UC2, uv_ref_mat, uv_in_gapi_mat);
- // G-API code //////////////////////////////////////////////////////////////
- cv::gapi::wip::draw::Prims prims;
- // Rects
- int shift = 0;
- for (int i = 0; i < rects_num; ++i) {
- cv::Rect rect(200 + i, 200 + i, 200, 200);
- prims.emplace_back(cv::gapi::wip::draw::Rect(rect, color, thick, lt, shift));
- }
- // Mosaic
- int cellsz = 25;
- int decim = 0;
- for (int i = 0; i < rects_num; ++i) {
- cv::Rect mos(200 + i, 200 + i, 200, 200);
- prims.emplace_back(cv::gapi::wip::draw::Mosaic(mos, cellsz, decim));
- }
- // Text
- std::string text = "Some text";
- int ff = FONT_HERSHEY_SIMPLEX;
- double fs = 2.0;
- bool blo = false;
- for (int i = 0; i < text_num; ++i) {
- cv::Point org(200 + i, 200 + i);
- prims.emplace_back(cv::gapi::wip::draw::Text(text, org, ff, fs, color, thick, lt, blo));
- }
- // Image
- double transparency = 1.0;
- cv::Rect rect_img(0 ,0 , 50, 50);
- cv::Mat img(rect_img.size(), CV_8UC3, color);
- cv::Mat alpha(rect_img.size(), CV_32FC1, transparency);
- auto tl = rect_img.tl();
- for (int i = 0; i < image_num; ++i) {
- cv::Point org_img = {tl.x + i, tl.y + rect_img.size().height + i};
- prims.emplace_back(cv::gapi::wip::draw::Image({org_img, img, alpha}));
- }
- cv::GMat y_in, uv_in, y_out, uv_out;
- cv::GArray<cv::gapi::wip::draw::Prim> arr;
- std::tie(y_out, uv_out) = cv::gapi::wip::draw::renderNV12(y_in, uv_in, arr);
- cv::GComputation comp(cv::GIn(y_in, uv_in, arr), cv::GOut(y_out, uv_out));
- // Warm-up graph engine:
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat), std::move(comp_args));
- TEST_CYCLE()
- {
- comp.apply(cv::gin(y_in_gapi_mat, uv_in_gapi_mat, prims),
- cv::gout(y_out_gapi_mat, uv_out_gapi_mat));
- }
- SANITY_CHECK_NOTHING();
- }
- } // namespace opencv_test
|