1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
9 #include <opencv2/gapi.hpp>
10 #include <opencv2/gapi/gmat.hpp>
11 #include <opencv2/gapi/gkernel.hpp>
13 namespace InferenceEngine {
15 using Size = cv::gapi::own::Size;
17 using GMat2 = std::tuple<cv::GMat, cv::GMat>;
18 using GMat3 = std::tuple<cv::GMat, cv::GMat, cv::GMat>;
19 using GMat4 = std::tuple<cv::GMat, cv::GMat, cv::GMat, cv::GMat>;
21 G_TYPED_KERNEL(ChanToPlane, <cv::GMat(cv::GMat, int)>, "com.intel.ie.chan_to_plane") {
22 static cv::GMatDesc outMeta(const cv::GMatDesc &in, int) {
23 return in.withType(in.depth, 1);
27 G_TYPED_KERNEL(ScalePlane, <cv::GMat(cv::GMat, int, Size, Size, int)>, "com.intel.ie.scale_plane") {
28 static cv::GMatDesc outMeta(const cv::GMatDesc &in, int type, const Size &szIn, const Size &szOut, int) {
29 GAPI_Assert(type == in.depth);
30 return in.withSize(szOut);
34 G_TYPED_KERNEL_M(ScalePlanes, <GMat3(cv::GMat, int, Size, Size, int)>, "com.intel.ie.scale_planes") {
35 static std::tuple<cv::GMatDesc, cv::GMatDesc, cv::GMatDesc> outMeta(const cv::GMatDesc &in, int /*type*/, const Size &szIn, const Size &szOut, int) {
36 cv::GMatDesc out_desc;
37 out_desc.depth = in.depth;
39 out_desc.size = szOut;
40 return std::make_tuple(out_desc, out_desc, out_desc);
44 G_TYPED_KERNEL(Merge2, <cv::GMat(cv::GMat, cv::GMat)>, "com.intel.ie.merge2") {
45 static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &) {
46 // FIXME: check a/b are equal!
47 return in.withType(in.depth, 2);
51 G_TYPED_KERNEL(Merge3, <cv::GMat(cv::GMat, cv::GMat, cv::GMat)>, "com.intel.ie.merge3") {
52 static cv::GMatDesc outMeta(const cv::GMatDesc &in, const cv::GMatDesc &, const cv::GMatDesc &) {
53 // FIXME: check a/b are equal!
54 return in.withType(in.depth, 3);
58 G_TYPED_KERNEL(Merge4, <cv::GMat(cv::GMat, cv::GMat, cv::GMat, cv::GMat)>, "com.intel.ie.merge4") {
59 static cv::GMatDesc outMeta(const cv::GMatDesc& in,
60 const cv::GMatDesc&, const cv::GMatDesc&, const cv::GMatDesc&) {
61 // FIXME: check a/b are equal!
62 return in.withType(in.depth, 4);
66 G_TYPED_KERNEL_M(Split2, <GMat2(cv::GMat)>, "com.intel.ie.split2") {
67 static std::tuple<cv::GMatDesc, cv::GMatDesc> outMeta(const cv::GMatDesc& in) {
68 const auto out_depth = in.depth;
69 const auto out_desc = in.withType(out_depth, 1);
70 return std::make_tuple(out_desc, out_desc);
74 G_TYPED_KERNEL_M(Split3, <GMat3(cv::GMat)>, "com.intel.ie.split3") {
75 static std::tuple<cv::GMatDesc, cv::GMatDesc, cv::GMatDesc> outMeta(const cv::GMatDesc& in) {
76 const auto out_depth = in.depth;
77 const auto out_desc = in.withType(out_depth, 1);
78 return std::make_tuple(out_desc, out_desc, out_desc);
82 G_TYPED_KERNEL_M(Split4, <GMat4(cv::GMat)>, "com.intel.ie.split4") {
83 static std::tuple<cv::GMatDesc, cv::GMatDesc, cv::GMatDesc, cv::GMatDesc> outMeta(const cv::GMatDesc& in) {
84 const auto out_depth = in.depth;
85 const auto out_desc = in.withType(out_depth, 1);
86 return std::make_tuple(out_desc, out_desc, out_desc, out_desc);
90 cv::gapi::GKernelPackage preprocKernels();
93 } // namespace InferenceEngine