Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/gapi/test/internal/gapi_int_executor_tests.cpp
16345 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
//
5
// Copyright (C) 2018 Intel Corporation
6
7
8
#include "test_precomp.hpp"
9
10
namespace opencv_test
11
{
12
13
// FIXME: avoid code duplication
14
// The below graph and config is taken from ComplexIslands test suite
15
TEST(GExecutor, SmokeTest)
16
{
17
cv::GMat in[2];
18
cv::GMat tmp[4];
19
cv::GScalar scl;
20
cv::GMat out[2];
21
22
tmp[0] = cv::gapi::bitwise_not(cv::gapi::bitwise_not(in[0]));
23
tmp[1] = cv::gapi::boxFilter(in[1], -1, cv::Size(3,3));
24
tmp[2] = tmp[0] + tmp[1]; // FIXME: handle tmp[2] = tmp[0]+tmp[2] typo
25
scl = cv::gapi::sum(tmp[1]);
26
tmp[3] = cv::gapi::medianBlur(tmp[1], 3);
27
out[0] = tmp[2] + scl;
28
out[1] = cv::gapi::boxFilter(tmp[3], -1, cv::Size(3,3));
29
30
// isl0 #internal1
31
// ........................... .........
32
// (in1) -> NotNot ->(tmp0) --> Add ---------> (tmp2) --> AddC -------> (out1)
33
// :.....................^...: :..^....:
34
// : :
35
// : :
36
// #internal0 : :
37
// .....................:......... :
38
// (in2) -> Blur -> (tmp1) ----'--> Sum ----> (scl0) ----'
39
// :..........:..................: isl1
40
// : ..............................
41
// `------------> Median -> (tmp3) --> Blur -------> (out2)
42
// :............................:
43
44
cv::gapi::island("isl0", cv::GIn(in[0], tmp[1]), cv::GOut(tmp[2]));
45
cv::gapi::island("isl1", cv::GIn(tmp[1]), cv::GOut(out[1]));
46
47
cv::Mat in_mat1 = cv::Mat::eye(32, 32, CV_8UC1);
48
cv::Mat in_mat2 = cv::Mat::eye(32, 32, CV_8UC1);
49
cv::Mat out_gapi[2];
50
51
// Run G-API:
52
cv::GComputation(cv::GIn(in[0], in[1]), cv::GOut(out[0], out[1]))
53
.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_gapi[0], out_gapi[1]));
54
55
// Run OpenCV
56
cv::Mat out_ocv[2];
57
{
58
cv::Mat ocv_tmp0;
59
cv::Mat ocv_tmp1;
60
cv::Mat ocv_tmp2;
61
cv::Mat ocv_tmp3;
62
cv::Scalar ocv_scl;
63
64
ocv_tmp0 = in_mat1; // skip !(!)
65
cv::boxFilter(in_mat2, ocv_tmp1, -1, cv::Size(3,3));
66
ocv_tmp2 = ocv_tmp0 + ocv_tmp1;
67
ocv_scl = cv::sum(ocv_tmp1);
68
cv::medianBlur(ocv_tmp1, ocv_tmp3, 3);
69
out_ocv[0] = ocv_tmp2 + ocv_scl;
70
cv::boxFilter(ocv_tmp3, out_ocv[1], -1, cv::Size(3,3));
71
}
72
73
EXPECT_EQ(0, cv::countNonZero(out_gapi[0] != out_ocv[0]));
74
EXPECT_EQ(0, cv::countNonZero(out_gapi[1] != out_ocv[1]));
75
76
// FIXME: check that GIslandModel has more than 1 island (e.g. fusion
77
// with breakdown worked)
78
}
79
80
// FIXME: Add explicit tests on GMat/GScalar/GArray<T> being connectors
81
// between executed islands
82
83
} // namespace opencv_test
84
85