mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #18287 from mpashchenkov:mp/ocv-gapi-blue-branch
[G-API]: Add four kernels to parse NN outputs & provide information in Streaming scenarios * Kernels from GL "blue" branch, acc and perf tests * Code cleanup * Output fix * Comment fix * Added new file for parsers, stylistic corrections * Added end line * Namespace fix * Code cleanup * nnparsers.hpp moved to gapi/infer/, nnparsers -> parsers * Removed cv:: from parsers.hpp
This commit is contained in:
committed by
GitHub
parent
830d8d6b75
commit
a63cee2139
@@ -10,6 +10,7 @@
|
||||
|
||||
|
||||
#include "../../test/common/gapi_tests_common.hpp"
|
||||
#include "../../test/common/gapi_parsers_tests_common.hpp"
|
||||
#include <opencv2/gapi/core.hpp>
|
||||
|
||||
namespace opencv_test
|
||||
@@ -73,5 +74,10 @@ namespace opencv_test
|
||||
class ConvertToPerfTest : public TestPerfParams<tuple<MatType, int, cv::Size, cv::GCompileArgs>> {};
|
||||
class ResizePerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, cv::Size, cv::GCompileArgs>> {};
|
||||
class ResizeFxFyPerfTest : public TestPerfParams<tuple<compare_f, MatType, int, cv::Size, double, double, cv::GCompileArgs>> {};
|
||||
class ParseSSDBLPerfTest : public TestPerfParams<tuple<cv::Size, float, int, cv::GCompileArgs>>, public ParserSSDTest {};
|
||||
class ParseSSDPerfTest : public TestPerfParams<tuple<cv::Size, float, bool, bool, cv::GCompileArgs>>, public ParserSSDTest {};
|
||||
class ParseYoloPerfTest : public TestPerfParams<tuple<cv::Size, float, float, int, cv::GCompileArgs>>, public ParserYoloTest {};
|
||||
class SizePerfTest : public TestPerfParams<tuple<MatType, cv::Size, cv::GCompileArgs>> {};
|
||||
class SizeRPerfTest : public TestPerfParams<tuple<cv::Size, cv::GCompileArgs>> {};
|
||||
}
|
||||
#endif // OPENCV_GAPI_CORE_PERF_TESTS_HPP
|
||||
|
||||
@@ -1930,5 +1930,187 @@ PERF_TEST_P_(ResizeFxFyPerfTest, TestPerformance)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(ParseSSDBLPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz;
|
||||
float confidence_threshold = 0.0f;
|
||||
int filter_label = 0;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(sz, confidence_threshold, filter_label, compile_args) = GetParam();
|
||||
cv::Mat in_mat = generateSSDoutput(sz);
|
||||
std::vector<cv::Rect> boxes_gapi, boxes_ref;
|
||||
std::vector<int> labels_gapi, labels_ref;
|
||||
|
||||
// Reference code //////////////////////////////////////////////////////////
|
||||
parseSSDBLref(in_mat, sz, confidence_threshold, filter_label, boxes_ref, labels_ref);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
cv::GOpaque<cv::Size> op_sz;
|
||||
auto out = cv::gapi::parseSSD(in, op_sz, confidence_threshold, filter_label);
|
||||
cv::GComputation c(cv::GIn(in, op_sz), cv::GOut(std::get<0>(out), std::get<1>(out)));
|
||||
|
||||
// Warm-up graph engine:
|
||||
auto cc = c.compile(descr_of(in_mat), descr_of(sz), std::move(compile_args));
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi, labels_gapi));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi, labels_gapi));
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(boxes_gapi == boxes_ref);
|
||||
EXPECT_TRUE(labels_gapi == labels_ref);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(ParseSSDPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz;
|
||||
float confidence_threshold = 0;
|
||||
bool alignment_to_square = false, filter_out_of_bounds = false;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(sz, confidence_threshold, alignment_to_square, filter_out_of_bounds, compile_args) = GetParam();
|
||||
cv::Mat in_mat = generateSSDoutput(sz);
|
||||
std::vector<cv::Rect> boxes_gapi, boxes_ref;
|
||||
|
||||
// Reference code //////////////////////////////////////////////////////////
|
||||
parseSSDref(in_mat, sz, confidence_threshold, alignment_to_square, filter_out_of_bounds, boxes_ref);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
cv::GOpaque<cv::Size> op_sz;
|
||||
auto out = cv::gapi::parseSSD(in, op_sz, confidence_threshold, alignment_to_square, filter_out_of_bounds);
|
||||
cv::GComputation c(cv::GIn(in, op_sz), cv::GOut(out));
|
||||
|
||||
// Warm-up graph engine:
|
||||
auto cc = c.compile(descr_of(in_mat), descr_of(sz), std::move(compile_args));
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi));
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(boxes_gapi == boxes_ref);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(ParseYoloPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz;
|
||||
float confidence_threshold = 0.0f, nms_threshold = 0.0f;
|
||||
int num_classes = 0;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(sz, confidence_threshold, nms_threshold, num_classes, compile_args) = GetParam();
|
||||
cv::Mat in_mat = generateYoloOutput(num_classes);
|
||||
auto anchors = cv::gapi::nn::parsers::GParseYolo::defaultAnchors();
|
||||
std::vector<cv::Rect> boxes_gapi, boxes_ref;
|
||||
std::vector<int> labels_gapi, labels_ref;
|
||||
|
||||
// Reference code //////////////////////////////////////////////////////////
|
||||
parseYoloRef(in_mat, sz, confidence_threshold, nms_threshold, num_classes, anchors, boxes_ref, labels_ref);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
cv::GOpaque<cv::Size> op_sz;
|
||||
auto out = cv::gapi::parseYolo(in, op_sz, confidence_threshold, nms_threshold, anchors);
|
||||
cv::GComputation c(cv::GIn(in, op_sz), cv::GOut(std::get<0>(out), std::get<1>(out)));
|
||||
|
||||
// Warm-up graph engine:
|
||||
auto cc = c.compile(descr_of(in_mat), descr_of(sz), std::move(compile_args));
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi, labels_gapi));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cc(cv::gin(in_mat, sz), cv::gout(boxes_gapi, labels_gapi));
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_TRUE(boxes_gapi == boxes_ref);
|
||||
EXPECT_TRUE(labels_gapi == labels_ref);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(SizePerfTest, TestPerformance)
|
||||
{
|
||||
MatType type;
|
||||
cv::Size sz;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(type, sz, compile_args) = GetParam();
|
||||
in_mat1 = cv::Mat(sz, type);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GMat in;
|
||||
auto out = cv::gapi::size(in);
|
||||
cv::GComputation c(cv::GIn(in), cv::GOut(out));
|
||||
cv::Size out_sz;
|
||||
|
||||
// Warm-up graph engine:
|
||||
auto cc = c.compile(descr_of(in_mat1), std::move(compile_args));
|
||||
cc(cv::gin(in_mat1), cv::gout(out_sz));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cc(cv::gin(in_mat1), cv::gout(out_sz));
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(out_sz, sz);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
PERF_TEST_P_(SizeRPerfTest, TestPerformance)
|
||||
{
|
||||
cv::Size sz;
|
||||
cv::GCompileArgs compile_args;
|
||||
std::tie(sz, compile_args) = GetParam();
|
||||
cv::Rect rect(cv::Point(0,0), sz);
|
||||
|
||||
// G-API code //////////////////////////////////////////////////////////////
|
||||
cv::GOpaque<cv::Rect> op_rect;
|
||||
auto out = cv::gapi::size(op_rect);
|
||||
cv::GComputation c(cv::GIn(op_rect), cv::GOut(out));
|
||||
cv::Size out_sz;
|
||||
|
||||
// Warm-up graph engine:
|
||||
auto cc = c.compile(descr_of(rect), std::move(compile_args));
|
||||
cc(cv::gin(rect), cv::gout(out_sz));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cc(cv::gin(rect), cv::gout(out_sz));
|
||||
}
|
||||
|
||||
// Comparison ////////////////////////////////////////////////////////////
|
||||
{
|
||||
EXPECT_EQ(out_sz, sz);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
}
|
||||
#endif // OPENCV_GAPI_CORE_PERF_TESTS_INL_HPP
|
||||
|
||||
@@ -288,4 +288,33 @@ INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestCPU, ResizeFxFyPerfTest,
|
||||
Values(0.5, 0.1),
|
||||
Values(0.5, 0.1),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ParseSSDBLPerfTestCPU, ParseSSDBLPerfTest,
|
||||
Combine(Values(sz720p, sz1080p),
|
||||
Values(0.3f, 0.7f),
|
||||
Values(0, 1),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ParseSSDPerfTestCPU, ParseSSDPerfTest,
|
||||
Combine(Values(sz720p, sz1080p),
|
||||
Values(0.3f, 0.7f),
|
||||
testing::Bool(),
|
||||
testing::Bool(),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ParseYoloPerfTestCPU, ParseYoloPerfTest,
|
||||
Combine(Values(sz720p, sz1080p),
|
||||
Values(0.3f, 0.7f),
|
||||
Values(0.5),
|
||||
Values(7, 80),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SizePerfTestCPU, SizePerfTest,
|
||||
Combine(Values(CV_8UC1, CV_8UC3, CV_32FC1),
|
||||
Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(SizeRPerfTestCPU, SizeRPerfTest,
|
||||
Combine(Values(szSmall128, szVGA, sz720p, sz1080p),
|
||||
Values(cv::compile_args(CORE_CPU))));
|
||||
} // opencv_test
|
||||
|
||||
Reference in New Issue
Block a user