gapi_gstreamersource_tests.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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) 2021 Intel Corporation
  6. #include "../test/common/gapi_tests_common.hpp"
  7. #include <opencv2/gapi/streaming/gstreamer/gstreamerpipeline.hpp>
  8. #include <opencv2/gapi/streaming/gstreamer/gstreamersource.hpp>
  9. #include <opencv2/gapi/core.hpp>
  10. #include <opencv2/gapi/cpu/core.hpp>
  11. #include <opencv2/gapi/streaming/meta.hpp>
  12. #include <opencv2/gapi/streaming/format.hpp>
  13. #include <opencv2/gapi/gkernel.hpp>
  14. #include <opencv2/gapi/cpu/gcpukernel.hpp>
  15. #include <opencv2/gapi/gcomputation.hpp>
  16. #include <opencv2/ts.hpp>
  17. #include <regex>
  18. #ifdef HAVE_GSTREAMER
  19. namespace opencv_test
  20. {
  21. struct GStreamerSourceTest : public TestWithParam<std::tuple<std::string, cv::Size, std::size_t>>
  22. { };
  23. TEST_P(GStreamerSourceTest, AccuracyTest)
  24. {
  25. std::string pipeline;
  26. cv::Size expectedFrameSize;
  27. std::size_t streamLength { };
  28. std::tie(pipeline, expectedFrameSize, streamLength) = GetParam();
  29. // Graph declaration:
  30. cv::GMat in;
  31. auto out = cv::gapi::copy(in);
  32. cv::GComputation c(cv::GIn(in), cv::GOut(out));
  33. // Graph compilation for streaming mode:
  34. auto ccomp = c.compileStreaming();
  35. EXPECT_TRUE(ccomp);
  36. EXPECT_FALSE(ccomp.running());
  37. // GStreamer streaming source configuration:
  38. ccomp.setSource<cv::gapi::wip::GStreamerSource>(pipeline);
  39. // Start of streaming:
  40. ccomp.start();
  41. EXPECT_TRUE(ccomp.running());
  42. // Streaming - pulling of frames until the end:
  43. cv::Mat in_mat_gapi;
  44. EXPECT_TRUE(ccomp.pull(cv::gout(in_mat_gapi)));
  45. EXPECT_TRUE(!in_mat_gapi.empty());
  46. EXPECT_EQ(expectedFrameSize, in_mat_gapi.size());
  47. EXPECT_EQ(CV_8UC3, in_mat_gapi.type());
  48. std::size_t framesCount = 1UL;
  49. while (ccomp.pull(cv::gout(in_mat_gapi))) {
  50. EXPECT_TRUE(!in_mat_gapi.empty());
  51. EXPECT_EQ(expectedFrameSize, in_mat_gapi.size());
  52. EXPECT_EQ(CV_8UC3, in_mat_gapi.type());
  53. framesCount++;
  54. }
  55. EXPECT_FALSE(ccomp.running());
  56. ccomp.stop();
  57. EXPECT_FALSE(ccomp.running());
  58. EXPECT_EQ(streamLength, framesCount);
  59. }
  60. TEST_P(GStreamerSourceTest, TimestampsTest)
  61. {
  62. std::string pipeline;
  63. std::size_t streamLength { };
  64. std::tie(pipeline, std::ignore, streamLength) = GetParam();
  65. // Graph declaration:
  66. cv::GMat in;
  67. cv::GMat copied = cv::gapi::copy(in);
  68. cv::GOpaque<int64_t> outId = cv::gapi::streaming::seq_id(copied);
  69. cv::GOpaque<int64_t> outTs = cv::gapi::streaming::timestamp(copied);
  70. cv::GComputation c(cv::GIn(in), cv::GOut(outId, outTs));
  71. // Graph compilation for streaming mode:
  72. auto ccomp = c.compileStreaming();
  73. EXPECT_TRUE(ccomp);
  74. EXPECT_FALSE(ccomp.running());
  75. // GStreamer streaming source configuration:
  76. ccomp.setSource<cv::gapi::wip::GStreamerSource>(pipeline);
  77. // Start of streaming:
  78. ccomp.start();
  79. EXPECT_TRUE(ccomp.running());
  80. // Streaming - pulling of frames until the end:
  81. int64_t seqId;
  82. int64_t timestamp;
  83. std::vector<int64_t> allSeqIds;
  84. std::vector<int64_t> allTimestamps;
  85. while (ccomp.pull(cv::gout(seqId, timestamp))) {
  86. allSeqIds.push_back(seqId);
  87. allTimestamps.push_back(timestamp);
  88. }
  89. EXPECT_FALSE(ccomp.running());
  90. ccomp.stop();
  91. EXPECT_FALSE(ccomp.running());
  92. EXPECT_EQ(0L, allSeqIds.front());
  93. EXPECT_EQ(int64_t(streamLength) - 1, allSeqIds.back());
  94. EXPECT_EQ(streamLength, allSeqIds.size());
  95. EXPECT_TRUE(std::is_sorted(allSeqIds.begin(), allSeqIds.end()));
  96. EXPECT_EQ(allSeqIds.size(), std::set<int64_t>(allSeqIds.begin(), allSeqIds.end()).size());
  97. EXPECT_EQ(streamLength, allTimestamps.size());
  98. EXPECT_TRUE(std::is_sorted(allTimestamps.begin(), allTimestamps.end()));
  99. }
  100. G_TYPED_KERNEL(GGstFrameCopyToNV12, <std::tuple<cv::GMat,cv::GMat>(GFrame)>,
  101. "org.opencv.test.gstframe_copy_to_nv12")
  102. {
  103. static std::tuple<GMatDesc, GMatDesc> outMeta(GFrameDesc desc) {
  104. GMatDesc y { CV_8U, 1, desc.size, false };
  105. GMatDesc uv { CV_8U, 2, desc.size / 2, false };
  106. return std::make_tuple(y, uv);
  107. }
  108. };
  109. G_TYPED_KERNEL(GGstFrameCopyToGRAY8, <cv::GMat(GFrame)>,
  110. "org.opencv.test.gstframe_copy_to_gray8")
  111. {
  112. static GMatDesc outMeta(GFrameDesc desc) {
  113. GMatDesc y{ CV_8U, 1, desc.size, false };
  114. return y;
  115. }
  116. };
  117. GAPI_OCV_KERNEL(GOCVGstFrameCopyToNV12, GGstFrameCopyToNV12)
  118. {
  119. static void run(const cv::MediaFrame& in, cv::Mat& y, cv::Mat& uv)
  120. {
  121. auto view = in.access(cv::MediaFrame::Access::R);
  122. cv::Mat ly(y.size(), y.type(), view.ptr[0], view.stride[0]);
  123. cv::Mat luv(uv.size(), uv.type(), view.ptr[1], view.stride[1]);
  124. ly.copyTo(y);
  125. luv.copyTo(uv);
  126. }
  127. };
  128. GAPI_OCV_KERNEL(GOCVGstFrameCopyToGRAY8, GGstFrameCopyToGRAY8)
  129. {
  130. static void run(const cv::MediaFrame & in, cv::Mat & y)
  131. {
  132. auto view = in.access(cv::MediaFrame::Access::R);
  133. cv::Mat ly(y.size(), y.type(), view.ptr[0], view.stride[0]);
  134. ly.copyTo(y);
  135. }
  136. };
  137. TEST_P(GStreamerSourceTest, GFrameTest)
  138. {
  139. std::string pipeline;
  140. cv::Size expectedFrameSize;
  141. std::size_t streamLength { };
  142. bool isNV12 = false;
  143. std::tie(pipeline, expectedFrameSize, streamLength) = GetParam();
  144. //Check if pipline string contains NV12 sub-string
  145. if (pipeline.find("NV12") != std::string::npos) {
  146. isNV12 = true;
  147. }
  148. // Graph declaration:
  149. cv::GFrame in;
  150. cv::GMat copiedY, copiedUV;
  151. if (isNV12) {
  152. std::tie(copiedY, copiedUV) = GGstFrameCopyToNV12::on(in);
  153. }
  154. else {
  155. copiedY = GGstFrameCopyToGRAY8::on(in);
  156. }
  157. cv::GComputation c(cv::GIn(in), isNV12 ? cv::GOut(copiedY, copiedUV) : cv::GOut(copiedY));
  158. // Graph compilation for streaming mode:
  159. cv::GStreamingCompiled ccomp;
  160. if (isNV12) {
  161. ccomp = c.compileStreaming(cv::compile_args(cv::gapi::kernels<GOCVGstFrameCopyToNV12>()));
  162. } else {
  163. ccomp = c.compileStreaming(cv::compile_args(cv::gapi::kernels<GOCVGstFrameCopyToGRAY8>()));
  164. }
  165. EXPECT_TRUE(ccomp);
  166. EXPECT_FALSE(ccomp.running());
  167. // GStreamer streaming source configuration:
  168. ccomp.setSource<cv::gapi::wip::GStreamerSource>
  169. (pipeline, cv::gapi::wip::GStreamerSource::OutputType::FRAME);
  170. // Start of streaming:
  171. ccomp.start();
  172. EXPECT_TRUE(ccomp.running());
  173. // Streaming - pulling of frames until the end:
  174. cv::Mat y_mat, uv_mat;
  175. EXPECT_TRUE(isNV12 ? ccomp.pull(cv::gout(y_mat, uv_mat)) : ccomp.pull(cv::gout(y_mat)));
  176. EXPECT_TRUE(!y_mat.empty());
  177. if (isNV12) {
  178. EXPECT_TRUE(!uv_mat.empty());
  179. }
  180. cv::Size expectedYSize = expectedFrameSize;
  181. cv::Size expectedUVSize = expectedFrameSize / 2;
  182. EXPECT_EQ(expectedYSize, y_mat.size());
  183. if (isNV12) {
  184. EXPECT_EQ(expectedUVSize, uv_mat.size());
  185. }
  186. EXPECT_EQ(CV_8UC1, y_mat.type());
  187. if (isNV12) {
  188. EXPECT_EQ(CV_8UC2, uv_mat.type());
  189. }
  190. std::size_t framesCount = 1UL;
  191. while (isNV12 ? ccomp.pull(cv::gout(y_mat, uv_mat)) : ccomp.pull(cv::gout(y_mat))) {
  192. EXPECT_TRUE(!y_mat.empty());
  193. if (isNV12) {
  194. EXPECT_TRUE(!uv_mat.empty());
  195. }
  196. EXPECT_EQ(expectedYSize, y_mat.size());
  197. if (isNV12) {
  198. EXPECT_EQ(expectedUVSize, uv_mat.size());
  199. }
  200. EXPECT_EQ(CV_8UC1, y_mat.type());
  201. if (isNV12) {
  202. EXPECT_EQ(CV_8UC2, uv_mat.type());
  203. }
  204. framesCount++;
  205. }
  206. EXPECT_FALSE(ccomp.running());
  207. ccomp.stop();
  208. EXPECT_FALSE(ccomp.running());
  209. EXPECT_EQ(streamLength, framesCount);
  210. }
  211. // FIXME: Need to launch with sudo. May be infrastructure problems.
  212. // TODO: It is needed to add tests for streaming from native KMB camera: kmbcamsrc
  213. // GStreamer element.
  214. INSTANTIATE_TEST_CASE_P(CameraEmulatingPipeline, GStreamerSourceTest,
  215. Combine(Values("videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  216. "videorate ! videoscale ! "
  217. "video/x-raw,format=NV12,width=1920,height=1080,framerate=3/1 ! "
  218. "appsink",
  219. "videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  220. "videorate ! videoscale ! "
  221. "video/x-raw,format=GRAY8,width=1920,height=1080,framerate=3/1 ! "
  222. "appsink"),
  223. Values(cv::Size(1920, 1080)),
  224. Values(10UL)));
  225. INSTANTIATE_TEST_CASE_P(FileEmulatingPipeline, GStreamerSourceTest,
  226. Combine(Values("videotestsrc pattern=colors num-buffers=10 ! "
  227. "videorate ! videoscale ! "
  228. "video/x-raw,format=NV12,width=640,height=420,framerate=3/1 ! "
  229. "appsink",
  230. "videotestsrc pattern=colors num-buffers=10 ! "
  231. "videorate ! videoscale ! "
  232. "video/x-raw,format=GRAY8,width=640,height=420,framerate=3/1 ! "
  233. "appsink"),
  234. Values(cv::Size(640, 420)),
  235. Values(10UL)));
  236. INSTANTIATE_TEST_CASE_P(MultipleLiveSources, GStreamerSourceTest,
  237. Combine(Values("videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  238. "videoscale ! video/x-raw,format=NV12,width=1280,height=720 ! appsink "
  239. "videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  240. "fakesink",
  241. "videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  242. "videoscale ! video/x-raw,format=GRAY8,width=1280,height=720 ! appsink "
  243. "videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  244. "fakesink"),
  245. Values(cv::Size(1280, 720)),
  246. Values(10UL)));
  247. INSTANTIATE_TEST_CASE_P(MultipleNotLiveSources, GStreamerSourceTest,
  248. Combine(Values("videotestsrc pattern=colors num-buffers=10 ! "
  249. "videoscale ! video/x-raw,format=NV12,width=1280,height=720 ! appsink "
  250. "videotestsrc pattern=colors num-buffers=10 ! "
  251. "fakesink",
  252. "videotestsrc pattern=colors num-buffers=10 ! "
  253. "videoscale ! video/x-raw,format=GRAY8,width=1280,height=720 ! appsink "
  254. "videotestsrc pattern=colors num-buffers=10 ! "
  255. "fakesink"),
  256. Values(cv::Size(1280, 720)),
  257. Values(10UL)));
  258. TEST(GStreamerMultiSourceSmokeTest, Test)
  259. {
  260. // Graph declaration:
  261. cv::GMat in1, in2;
  262. auto out = cv::gapi::add(in1, in2);
  263. cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
  264. // Graph compilation for streaming mode:
  265. auto ccomp = c.compileStreaming();
  266. EXPECT_TRUE(ccomp);
  267. EXPECT_FALSE(ccomp.running());
  268. cv::gapi::wip::GStreamerPipeline
  269. pipeline("videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  270. "videorate ! videoscale ! "
  271. "video/x-raw,width=1920,height=1080,framerate=3/1 ! "
  272. "appsink name=sink1 "
  273. "videotestsrc is-live=true pattern=colors num-buffers=10 ! "
  274. "videorate ! videoscale ! "
  275. "video/x-raw,width=1920,height=1080,framerate=3/1 ! "
  276. "appsink name=sink2");
  277. // GStreamer streaming sources configuration:
  278. auto src1 = pipeline.getStreamingSource("sink1");
  279. auto src2 = pipeline.getStreamingSource("sink2");
  280. ccomp.setSource(cv::gin(src1, src2));
  281. // Start of streaming:
  282. ccomp.start();
  283. EXPECT_TRUE(ccomp.running());
  284. // Streaming - pulling of frames until the end:
  285. cv::Mat in_mat_gapi;
  286. EXPECT_TRUE(ccomp.pull(cv::gout(in_mat_gapi)));
  287. EXPECT_TRUE(!in_mat_gapi.empty());
  288. EXPECT_EQ(CV_8UC3, in_mat_gapi.type());
  289. while (ccomp.pull(cv::gout(in_mat_gapi))) {
  290. EXPECT_TRUE(!in_mat_gapi.empty());
  291. EXPECT_EQ(CV_8UC3, in_mat_gapi.type());
  292. }
  293. EXPECT_FALSE(ccomp.running());
  294. ccomp.stop();
  295. EXPECT_FALSE(ccomp.running());
  296. }
  297. struct GStreamerMultiSourceTestNV12 :
  298. public TestWithParam<std::tuple<cv::GComputation, cv::gapi::wip::GStreamerSource::OutputType>>
  299. { };
  300. TEST_P(GStreamerMultiSourceTestNV12, ImageDataTest)
  301. {
  302. std::string pathToLeftIm = findDataFile("cv/stereomatching/datasets/tsukuba/im6.png");
  303. std::string pathToRightIm = findDataFile("cv/stereomatching/datasets/tsukuba/im2.png");
  304. std::string pipelineToReadImage("filesrc location=LOC ! pngdec ! videoconvert ! "
  305. "videoscale ! video/x-raw,format=NV12 ! appsink");
  306. cv::gapi::wip::GStreamerSource leftImageProvider(
  307. std::regex_replace(pipelineToReadImage, std::regex("LOC"), pathToLeftIm));
  308. cv::gapi::wip::GStreamerSource rightImageProvider(
  309. std::regex_replace(pipelineToReadImage, std::regex("LOC"), pathToRightIm));
  310. cv::gapi::wip::Data leftImData, rightImData;
  311. leftImageProvider.pull(leftImData);
  312. rightImageProvider.pull(rightImData);
  313. cv::Mat leftRefMat = cv::util::get<cv::Mat>(leftImData);
  314. cv::Mat rightRefMat = cv::util::get<cv::Mat>(rightImData);
  315. // Retrieve test parameters:
  316. std::tuple<cv::GComputation, cv::gapi::wip::GStreamerSource::OutputType> params = GetParam();
  317. cv::GComputation extractImage = std::move(std::get<0>(params));
  318. cv::gapi::wip::GStreamerSource::OutputType outputType = std::get<1>(params);
  319. // Graph compilation for streaming mode:
  320. auto compiled =
  321. extractImage.compileStreaming();
  322. EXPECT_TRUE(compiled);
  323. EXPECT_FALSE(compiled.running());
  324. cv::gapi::wip::GStreamerPipeline
  325. pipeline(std::string("multifilesrc location=" + pathToLeftIm + " index=0 loop=true ! "
  326. "pngdec ! videoconvert ! videoscale ! video/x-raw,format=NV12 ! "
  327. "appsink name=sink1 ") +
  328. std::string("multifilesrc location=" + pathToRightIm + " index=0 loop=true ! "
  329. "pngdec ! videoconvert ! videoscale ! video/x-raw,format=NV12 ! "
  330. "appsink name=sink2"));
  331. // GStreamer streaming sources configuration:
  332. auto src1 = pipeline.getStreamingSource("sink1", outputType);
  333. auto src2 = pipeline.getStreamingSource("sink2", outputType);
  334. compiled.setSource(cv::gin(src1, src2));
  335. // Start of streaming:
  336. compiled.start();
  337. EXPECT_TRUE(compiled.running());
  338. // Streaming - pulling of frames:
  339. cv::Mat in_mat1, in_mat2;
  340. std::size_t counter { }, limit { 10 };
  341. while(compiled.pull(cv::gout(in_mat1, in_mat2)) && (counter < limit)) {
  342. EXPECT_EQ(0, cv::norm(in_mat1, leftRefMat, cv::NORM_INF));
  343. EXPECT_EQ(0, cv::norm(in_mat2, rightRefMat, cv::NORM_INF));
  344. ++counter;
  345. }
  346. compiled.stop();
  347. EXPECT_FALSE(compiled.running());
  348. }
  349. INSTANTIATE_TEST_CASE_P(GStreamerMultiSourceViaGMatsTest, GStreamerMultiSourceTestNV12,
  350. Combine(Values(cv::GComputation([]()
  351. {
  352. cv::GMat in1, in2;
  353. return cv::GComputation(cv::GIn(in1, in2),
  354. cv::GOut(cv::gapi::copy(in1),
  355. cv::gapi::copy(in2)));
  356. })),
  357. Values(cv::gapi::wip::GStreamerSource::OutputType::MAT)));
  358. INSTANTIATE_TEST_CASE_P(GStreamerMultiSourceViaGFramesTest, GStreamerMultiSourceTestNV12,
  359. Combine(Values(cv::GComputation([]()
  360. {
  361. cv::GFrame in1, in2;
  362. return cv::GComputation(cv::GIn(in1, in2),
  363. cv::GOut(cv::gapi::streaming::BGR(in1),
  364. cv::gapi::streaming::BGR(in2)));
  365. })),
  366. Values(cv::gapi::wip::GStreamerSource::OutputType::FRAME)));
  367. struct GStreamerMultiSourceTestGRAY8 :
  368. public TestWithParam<std::tuple<cv::GComputation, cv::gapi::wip::GStreamerSource::OutputType>>
  369. { };
  370. TEST_P(GStreamerMultiSourceTestGRAY8, ImageDataTest)
  371. {
  372. std::string pathToLeftIm = findDataFile("cv/stereomatching/datasets/tsukuba/im6.png");
  373. std::string pathToRightIm = findDataFile("cv/stereomatching/datasets/tsukuba/im2.png");
  374. std::string pipelineToReadImage("filesrc location=LOC ! pngdec ! videoconvert ! "
  375. "videoscale ! video/x-raw,format=GRAY8 ! appsink");
  376. cv::gapi::wip::GStreamerSource leftImageProvider(
  377. std::regex_replace(pipelineToReadImage, std::regex("LOC"), pathToLeftIm));
  378. cv::gapi::wip::GStreamerSource rightImageProvider(
  379. std::regex_replace(pipelineToReadImage, std::regex("LOC"), pathToRightIm));
  380. cv::gapi::wip::Data leftImData, rightImData;
  381. leftImageProvider.pull(leftImData);
  382. rightImageProvider.pull(rightImData);
  383. cv::Mat leftRefMat = cv::util::get<cv::Mat>(leftImData);
  384. cv::Mat rightRefMat = cv::util::get<cv::Mat>(rightImData);
  385. // Retrieve test parameters:
  386. std::tuple<cv::GComputation, cv::gapi::wip::GStreamerSource::OutputType> params = GetParam();
  387. cv::GComputation extractImage = std::move(std::get<0>(params));
  388. cv::gapi::wip::GStreamerSource::OutputType outputType = std::get<1>(params);
  389. // Graph compilation for streaming mode:
  390. auto compiled =
  391. extractImage.compileStreaming();
  392. EXPECT_TRUE(compiled);
  393. EXPECT_FALSE(compiled.running());
  394. cv::gapi::wip::GStreamerPipeline
  395. pipeline(std::string("multifilesrc location=" + pathToLeftIm + " index=0 loop=true ! "
  396. "pngdec ! videoconvert ! videoscale ! video/x-raw,format=GRAY8 ! "
  397. "appsink name=sink1 ") +
  398. std::string("multifilesrc location=" + pathToRightIm + " index=0 loop=true ! "
  399. "pngdec ! videoconvert ! videoscale ! video/x-raw,format=GRAY8 ! "
  400. "appsink name=sink2"));
  401. // GStreamer streaming sources configuration:
  402. auto src1 = pipeline.getStreamingSource("sink1", outputType);
  403. auto src2 = pipeline.getStreamingSource("sink2", outputType);
  404. compiled.setSource(cv::gin(src1, src2));
  405. // Start of streaming:
  406. compiled.start();
  407. EXPECT_TRUE(compiled.running());
  408. // Streaming - pulling of frames:
  409. cv::Mat in_mat1, in_mat2;
  410. std::size_t counter { }, limit { 10 };
  411. while(compiled.pull(cv::gout(in_mat1, in_mat2)) && (counter < limit)) {
  412. EXPECT_EQ(0, cv::norm(in_mat1, leftRefMat, cv::NORM_INF));
  413. EXPECT_EQ(0, cv::norm(in_mat2, rightRefMat, cv::NORM_INF));
  414. ++counter;
  415. }
  416. compiled.stop();
  417. EXPECT_FALSE(compiled.running());
  418. }
  419. INSTANTIATE_TEST_CASE_P(GStreamerMultiSourceViaGMatsTest, GStreamerMultiSourceTestGRAY8,
  420. Combine(Values(cv::GComputation([]()
  421. {
  422. cv::GMat in1, in2;
  423. return cv::GComputation(cv::GIn(in1, in2),
  424. cv::GOut(cv::gapi::copy(in1),
  425. cv::gapi::copy(in2)));
  426. })),
  427. Values(cv::gapi::wip::GStreamerSource::OutputType::MAT)));
  428. INSTANTIATE_TEST_CASE_P(GStreamerMultiSourceViaGFramesTest, GStreamerMultiSourceTestGRAY8,
  429. Combine(Values(cv::GComputation([]()
  430. {
  431. cv::GFrame in1, in2;
  432. return cv::GComputation(cv::GIn(in1, in2),
  433. cv::GOut(cv::gapi::streaming::BGR(in1),
  434. cv::gapi::streaming::BGR(in2)));
  435. })),
  436. Values(cv::gapi::wip::GStreamerSource::OutputType::FRAME)));
  437. } // namespace opencv_test
  438. #endif // HAVE_GSTREAMER