@@ -1112,10 +1112,7 @@ TEST(InferList, TestStreamingInfer)
1112
1112
1113
1113
// Load IE network, initialize input data using that.
1114
1114
cv::Mat in_mat;
1115
- std::vector<cv::Mat> ie_ages;
1116
- std::vector<cv::Mat> ie_genders;
1117
- std::vector<cv::Mat> gapi_ages;
1118
- std::vector<cv::Mat> gapi_genders;
1115
+ std::vector<cv::Mat> ie_ages, ie_genders, gapi_ages, gapi_genders;
1119
1116
1120
1117
std::vector<cv::Rect> roi_list = {
1121
1118
cv::Rect (cv::Point{64 , 60 }, cv::Size{ 96 , 96 }),
@@ -1206,10 +1203,7 @@ TEST(Infer2, TestStreamingInfer)
1206
1203
1207
1204
// Load IE network, initialize input data using that.
1208
1205
cv::Mat in_mat;
1209
- std::vector<cv::Mat> ie_ages;
1210
- std::vector<cv::Mat> ie_genders;
1211
- std::vector<cv::Mat> gapi_ages;
1212
- std::vector<cv::Mat> gapi_genders;
1206
+ std::vector<cv::Mat> ie_ages, ie_genders, gapi_ages, gapi_genders;
1213
1207
1214
1208
std::vector<cv::Rect> roi_list = {
1215
1209
cv::Rect (cv::Point{64 , 60 }, cv::Size{ 96 , 96 }),
@@ -1286,6 +1280,116 @@ TEST(Infer2, TestStreamingInfer)
1286
1280
pipeline.stop ();
1287
1281
}
1288
1282
1283
+ TEST (InferEmptyList, TestStreamingInfer)
1284
+ {
1285
+ initTestDataPath ();
1286
+ initDLDTDataPath ();
1287
+
1288
+ std::string filepath = findDataFile (" cv/video/768x576.avi" );
1289
+
1290
+ cv::gapi::ie::detail::ParamDesc params;
1291
+ params.model_path = findDataFile (SUBDIR + " age-gender-recognition-retail-0013.xml" );
1292
+ params.weights_path = findDataFile (SUBDIR + " age-gender-recognition-retail-0013.bin" );
1293
+ params.device_id = " CPU" ;
1294
+
1295
+ // Load IE network, initialize input data using that.
1296
+ cv::Mat in_mat;
1297
+ std::vector<cv::Mat> ie_ages, ie_genders, gapi_ages, gapi_genders;
1298
+
1299
+ // NB: Empty list of roi
1300
+ std::vector<cv::Rect> roi_list;
1301
+
1302
+ using AGInfo = std::tuple<cv::GMat, cv::GMat>;
1303
+ G_API_NET (AgeGender, <AGInfo (cv::GMat)>, " test-age-gender" );
1304
+
1305
+ cv::GMat in;
1306
+ cv::GArray<cv::Rect> roi;
1307
+ cv::GArray<GMat> age, gender;
1308
+
1309
+ std::tie (age, gender) = cv::gapi::infer<AgeGender>(roi, in);
1310
+ cv::GComputation comp (cv::GIn (in, roi), cv::GOut (age, gender));
1311
+
1312
+ auto pp = cv::gapi::ie::Params<AgeGender> {
1313
+ params.model_path , params.weights_path , params.device_id
1314
+ }.cfgOutputLayers ({ " age_conv3" , " prob" });
1315
+
1316
+
1317
+ std::size_t num_frames = 0u ;
1318
+ std::size_t max_frames = 1u ;
1319
+
1320
+ cv::VideoCapture cap;
1321
+ cap.open (filepath);
1322
+ if (!cap.isOpened ())
1323
+ throw SkipTestException (" Video file can not be opened" );
1324
+
1325
+ cap >> in_mat;
1326
+ auto pipeline = comp.compileStreaming (cv::compile_args (cv::gapi::networks (pp)));
1327
+ pipeline.setSource (
1328
+ cv::gin (cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(filepath), roi_list));
1329
+
1330
+ pipeline.start ();
1331
+ while (num_frames < max_frames && pipeline.pull (cv::gout (gapi_ages, gapi_genders)))
1332
+ {
1333
+ EXPECT_TRUE (gapi_ages.empty ());
1334
+ EXPECT_TRUE (gapi_genders.empty ());
1335
+ }
1336
+ }
1337
+
1338
+ TEST (Infer2EmptyList, TestStreamingInfer)
1339
+ {
1340
+ initTestDataPath ();
1341
+ initDLDTDataPath ();
1342
+
1343
+ std::string filepath = findDataFile (" cv/video/768x576.avi" );
1344
+
1345
+ cv::gapi::ie::detail::ParamDesc params;
1346
+ params.model_path = findDataFile (SUBDIR + " age-gender-recognition-retail-0013.xml" );
1347
+ params.weights_path = findDataFile (SUBDIR + " age-gender-recognition-retail-0013.bin" );
1348
+ params.device_id = " CPU" ;
1349
+
1350
+ // Load IE network, initialize input data using that.
1351
+ cv::Mat in_mat;
1352
+ std::vector<cv::Mat> ie_ages, ie_genders, gapi_ages, gapi_genders;
1353
+
1354
+ // NB: Empty list of roi
1355
+ std::vector<cv::Rect> roi_list;
1356
+
1357
+ using AGInfo = std::tuple<cv::GMat, cv::GMat>;
1358
+ G_API_NET (AgeGender, <AGInfo (cv::GMat)>, " test-age-gender" );
1359
+
1360
+ cv::GArray<cv::Rect> rr;
1361
+ cv::GMat in;
1362
+ cv::GArray<cv::GMat> age, gender;
1363
+ std::tie (age, gender) = cv::gapi::infer2<AgeGender>(in, rr);
1364
+
1365
+ cv::GComputation comp (cv::GIn (in, rr), cv::GOut (age, gender));
1366
+
1367
+ auto pp = cv::gapi::ie::Params<AgeGender> {
1368
+ params.model_path , params.weights_path , params.device_id
1369
+ }.cfgOutputLayers ({ " age_conv3" , " prob" });
1370
+
1371
+
1372
+ std::size_t num_frames = 0u ;
1373
+ std::size_t max_frames = 1u ;
1374
+
1375
+ cv::VideoCapture cap;
1376
+ cap.open (filepath);
1377
+ if (!cap.isOpened ())
1378
+ throw SkipTestException (" Video file can not be opened" );
1379
+
1380
+ cap >> in_mat;
1381
+ auto pipeline = comp.compileStreaming (cv::compile_args (cv::gapi::networks (pp)));
1382
+ pipeline.setSource (
1383
+ cv::gin (cv::gapi::wip::make_src<cv::gapi::wip::GCaptureSource>(filepath), roi_list));
1384
+
1385
+ pipeline.start ();
1386
+ while (num_frames < max_frames && pipeline.pull (cv::gout (gapi_ages, gapi_genders)))
1387
+ {
1388
+ EXPECT_TRUE (gapi_ages.empty ());
1389
+ EXPECT_TRUE (gapi_genders.empty ());
1390
+ }
1391
+ }
1392
+
1289
1393
} // namespace opencv_test
1290
1394
1291
1395
#endif // HAVE_INF_ENGINE
0 commit comments