Merge pull request #16772 from aDanPin:dp/performance_render_tests
Added g-api render performance tests * Add render performance tests for BGROCV * Add render NV12 performance tests * Review response * Review response * Review response * Review response * Review response * Review response * Just a small fix * Final review response I hope) * Review response * Review response * Review response * Review response * Review response * Review responsepull/17586/head
parent
56373428dc
commit
57f5700e18
5 changed files with 974 additions and 2 deletions
@ -0,0 +1,9 @@ |
||||
// 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 "../perf_precomp.hpp" |
||||
#include "gapi_render_perf_tests_inl.hpp" |
@ -0,0 +1,43 @@ |
||||
// 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
|
||||
|
||||
|
||||
#ifndef OPENCV_GAPI_RENDER_PERF_TESTS_HPP |
||||
#define OPENCV_GAPI_RENDER_PERF_TESTS_HPP |
||||
|
||||
|
||||
#include "../../test/common/gapi_tests_common.hpp" |
||||
#include <opencv2/gapi/render/render.hpp> |
||||
|
||||
namespace opencv_test |
||||
{ |
||||
|
||||
using namespace perf; |
||||
|
||||
class RenderTestFTexts : public TestPerfParams<tuple<std::wstring, cv::Size, cv::Point, |
||||
int, cv::Scalar, cv::GCompileArgs>> {}; |
||||
class RenderTestTexts : public TestPerfParams<tuple<std::string, cv::Size, cv::Point, |
||||
int, cv::Scalar, int, int, |
||||
bool, cv::GCompileArgs>> {}; |
||||
class RenderTestRects : public TestPerfParams<tuple<cv::Size, cv::Rect, cv::Scalar, |
||||
int, int, int, cv::GCompileArgs>> {}; |
||||
class RenderTestCircles : public TestPerfParams<tuple<cv::Size, cv::Point, int, |
||||
cv::Scalar, int, int, int, |
||||
cv::GCompileArgs>> {}; |
||||
class RenderTestLines : public TestPerfParams<tuple<cv::Size, cv::Point, cv::Point, |
||||
cv::Scalar, int, int, int, |
||||
cv::GCompileArgs>> {}; |
||||
class RenderTestMosaics : public TestPerfParams<tuple<cv::Size, cv::Rect, int, int, |
||||
cv::GCompileArgs>> {}; |
||||
class RenderTestImages : public TestPerfParams<tuple<cv::Size, cv::Rect, cv::Scalar, double, |
||||
cv::GCompileArgs>> {}; |
||||
class RenderTestPolylines : public TestPerfParams<tuple<cv::Size, std::vector<cv::Point>, |
||||
cv::Scalar, int, int, int, |
||||
cv::GCompileArgs>> {}; |
||||
class RenderTestPolyItems : public TestPerfParams<tuple<cv::Size, int, int, int, cv::GCompileArgs>> {}; |
||||
|
||||
} |
||||
#endif //OPENCV_GAPI_RENDER_PERF_TESTS_HPP
|
@ -0,0 +1,827 @@ |
||||
// 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
|
@ -0,0 +1,95 @@ |
||||
// 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 "../perf_precomp.hpp" |
||||
#include "../common/gapi_render_perf_tests.hpp" |
||||
|
||||
#define RENDER_OCV cv::gapi::render::ocv::kernels() |
||||
|
||||
namespace opencv_test |
||||
{ |
||||
|
||||
#ifdef HAVE_FREETYPE |
||||
INSTANTIATE_TEST_CASE_P(RenderTestFTexts, RenderTestFTexts, |
||||
Combine(Values(L"\xe4\xbd\xa0\xe5\xa5\xbd"), |
||||
Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Point(50, 50)), |
||||
Values(60), |
||||
Values(cv::Scalar(200, 100, 25)), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
#endif // HAVE_FREETYPE
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestTexts, RenderTestTexts, |
||||
Combine(Values(std::string("Some text")), |
||||
Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Point(200, 200)), |
||||
Values(FONT_HERSHEY_SIMPLEX), |
||||
Values(cv::Scalar(0, 255, 0)), |
||||
Values(2), |
||||
Values(LINE_8), |
||||
Values(false), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestRects, RenderTestRects, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Rect(100, 100, 200, 200)), |
||||
Values(cv::Scalar(100, 50, 150)), |
||||
Values(2), |
||||
Values(LINE_8), |
||||
Values(0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestCircles, RenderTestCircles, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Point(100, 100)), |
||||
Values(10), |
||||
Values(cv::Scalar(100, 50, 150)), |
||||
Values(2), |
||||
Values(LINE_8), |
||||
Values(0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestLines, RenderTestLines, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Point(100, 100)), |
||||
Values(cv::Point(200, 200)), |
||||
Values(cv::Scalar(100, 50, 150)), |
||||
Values(2), |
||||
Values(LINE_8), |
||||
Values(0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestMosaics, RenderTestMosaics, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Rect(100, 100, 200, 200)), |
||||
Values(25), |
||||
Values(0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestImages, RenderTestImages, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(cv::Rect(50, 50, 100, 100)), |
||||
Values(cv::Scalar(100, 150, 60)), |
||||
Values(1.0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestPolylines, RenderTestPolylines, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(std::vector<cv::Point>{{100, 100}, {200, 200}, {150, 300}, {400, 150}}), |
||||
Values(cv::Scalar(100, 150, 60)), |
||||
Values(2), |
||||
Values(LINE_8), |
||||
Values(0), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
|
||||
INSTANTIATE_TEST_CASE_P(RenderTestPolyItems, RenderTestPolyItems, |
||||
Combine(Values(szVGA, sz720p, sz1080p), |
||||
Values(50), |
||||
Values(50), |
||||
Values(50), |
||||
Values(cv::compile_args(RENDER_OCV)))); |
||||
} |
Loading…
Reference in new issue