1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

OpenCV face detection network test

This commit is contained in:
Dmitry Kurtaev
2018-01-20 21:55:25 +03:00
parent c89ae6e537
commit a3d74704e5
5 changed files with 242 additions and 227 deletions
+24 -1
View File
@@ -396,7 +396,7 @@ TEST(Reproducibility_GoogLeNet_fp16, Accuracy)
// https://github.com/richzhang/colorization
TEST(Reproducibility_Colorization, Accuracy)
{
const float l1 = 1e-5;
const float l1 = 3e-5;
const float lInf = 3e-3;
Mat inp = blobFromNPY(_tf("colorization_inp.npy"));
@@ -460,4 +460,27 @@ TEST(Test_Caffe, multiple_inputs)
normAssert(out, first_image + second_image);
}
TEST(Test_Caffe, opencv_face_detector)
{
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false);
std::string model = findDataFile("dnn/opencv_face_detector.caffemodel", false);
Net net = readNetFromCaffe(proto, model);
Mat img = imread(findDataFile("gpu/lbpcascade/er.png", false));
Mat blob = blobFromImage(img, 1.0, Size(), Scalar(104.0, 177.0, 123.0), false, false);
net.setInput(blob);
// Output has shape 1x1xNx7 where N - number of detections.
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
Mat out = net.forward();
Mat ref = (Mat_<float>(6, 5) << 0.99520785, 0.80997437, 0.16379407, 0.87996572, 0.26685631,
0.9934696, 0.2831718, 0.50738752, 0.345781, 0.5985168,
0.99096733, 0.13629119, 0.24892329, 0.19756334, 0.3310290,
0.98977017, 0.23901358, 0.09084064, 0.29902688, 0.1769477,
0.97203469, 0.67965847, 0.06876482, 0.73999709, 0.1513494,
0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
normAssert(out.reshape(1, out.total() / 7).rowRange(0, 6).colRange(2, 7), ref);
}
}