Path: blob/master/modules/gapi/test/internal/gapi_int_executor_tests.cpp
16345 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#include "test_precomp.hpp"89namespace opencv_test10{1112// FIXME: avoid code duplication13// The below graph and config is taken from ComplexIslands test suite14TEST(GExecutor, SmokeTest)15{16cv::GMat in[2];17cv::GMat tmp[4];18cv::GScalar scl;19cv::GMat out[2];2021tmp[0] = cv::gapi::bitwise_not(cv::gapi::bitwise_not(in[0]));22tmp[1] = cv::gapi::boxFilter(in[1], -1, cv::Size(3,3));23tmp[2] = tmp[0] + tmp[1]; // FIXME: handle tmp[2] = tmp[0]+tmp[2] typo24scl = cv::gapi::sum(tmp[1]);25tmp[3] = cv::gapi::medianBlur(tmp[1], 3);26out[0] = tmp[2] + scl;27out[1] = cv::gapi::boxFilter(tmp[3], -1, cv::Size(3,3));2829// isl0 #internal130// ........................... .........31// (in1) -> NotNot ->(tmp0) --> Add ---------> (tmp2) --> AddC -------> (out1)32// :.....................^...: :..^....:33// : :34// : :35// #internal0 : :36// .....................:......... :37// (in2) -> Blur -> (tmp1) ----'--> Sum ----> (scl0) ----'38// :..........:..................: isl139// : ..............................40// `------------> Median -> (tmp3) --> Blur -------> (out2)41// :............................:4243cv::gapi::island("isl0", cv::GIn(in[0], tmp[1]), cv::GOut(tmp[2]));44cv::gapi::island("isl1", cv::GIn(tmp[1]), cv::GOut(out[1]));4546cv::Mat in_mat1 = cv::Mat::eye(32, 32, CV_8UC1);47cv::Mat in_mat2 = cv::Mat::eye(32, 32, CV_8UC1);48cv::Mat out_gapi[2];4950// Run G-API:51cv::GComputation(cv::GIn(in[0], in[1]), cv::GOut(out[0], out[1]))52.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_gapi[0], out_gapi[1]));5354// Run OpenCV55cv::Mat out_ocv[2];56{57cv::Mat ocv_tmp0;58cv::Mat ocv_tmp1;59cv::Mat ocv_tmp2;60cv::Mat ocv_tmp3;61cv::Scalar ocv_scl;6263ocv_tmp0 = in_mat1; // skip !(!)64cv::boxFilter(in_mat2, ocv_tmp1, -1, cv::Size(3,3));65ocv_tmp2 = ocv_tmp0 + ocv_tmp1;66ocv_scl = cv::sum(ocv_tmp1);67cv::medianBlur(ocv_tmp1, ocv_tmp3, 3);68out_ocv[0] = ocv_tmp2 + ocv_scl;69cv::boxFilter(ocv_tmp3, out_ocv[1], -1, cv::Size(3,3));70}7172EXPECT_EQ(0, cv::countNonZero(out_gapi[0] != out_ocv[0]));73EXPECT_EQ(0, cv::countNonZero(out_gapi[1] != out_ocv[1]));7475// FIXME: check that GIslandModel has more than 1 island (e.g. fusion76// with breakdown worked)77}7879// FIXME: Add explicit tests on GMat/GScalar/GArray<T> being connectors80// between executed islands8182} // namespace opencv_test838485