@@ -456,16 +456,21 @@ TEST(Test_Caffe, multiple_inputs)
456
456
normAssert (out, first_image + second_image);
457
457
}
458
458
459
- typedef testing::TestWithParam<std::string> opencv_face_detector;
459
+ CV_ENUM (DNNTarget, DNN_TARGET_CPU, DNN_TARGET_OPENCL)
460
+ typedef testing::TestWithParam<tuple<std::string, DNNTarget> > opencv_face_detector;
460
461
TEST_P (opencv_face_detector, Accuracy)
461
462
{
462
463
std::string proto = findDataFile (" dnn/opencv_face_detector.prototxt" , false );
463
- std::string model = findDataFile (GetParam (), false );
464
+ std::string model = findDataFile (get<0 >(GetParam ()), false );
465
+ dnn::Target targetId = (dnn::Target)(int )get<1 >(GetParam ());
464
466
465
467
Net net = readNetFromCaffe (proto, model);
466
468
Mat img = imread (findDataFile (" gpu/lbpcascade/er.png" , false ));
467
469
Mat blob = blobFromImage (img, 1.0 , Size (), Scalar (104.0 , 177.0 , 123.0 ), false , false );
468
470
471
+ net.setPreferableBackend (DNN_BACKEND_DEFAULT);
472
+ net.setPreferableTarget (targetId);
473
+
469
474
net.setInput (blob);
470
475
// Output has shape 1x1xNx7 where N - number of detections.
471
476
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
@@ -479,11 +484,13 @@ TEST_P(opencv_face_detector, Accuracy)
479
484
0.95097077 , 0.51901293 , 0.45863652 , 0.5777427 , 0.5347801 );
480
485
normAssert (out.reshape (1 , out.total () / 7 ).rowRange (0 , 6 ).colRange (2 , 7 ), ref);
481
486
}
482
- INSTANTIATE_TEST_CASE_P (Test_Caffe, opencv_face_detector, Values(
483
- " dnn/opencv_face_detector.caffemodel" ,
484
- " dnn/opencv_face_detector_fp16.caffemodel"
485
- ));
486
-
487
+ INSTANTIATE_TEST_CASE_P (Test_Caffe, opencv_face_detector,
488
+ Combine (
489
+ Values (" dnn/opencv_face_detector.caffemodel" ,
490
+ " dnn/opencv_face_detector_fp16.caffemodel" ),
491
+ Values(DNN_TARGET_CPU, DNN_TARGET_OPENCL)
492
+ )
493
+ );
487
494
488
495
TEST (Test_Caffe, FasterRCNN_and_RFCN)
489
496
{
0 commit comments