我正在使用此OpenCV示例https://bitbucket.org/jameskingconsulting/blackjack-scala/src/master/。然后,我使用for face detection进行面部识别。第一步是使用OpenCV检测面部并将检测到的矩形保存为jpg。我也对第二张图片做同样的事情。之后,我将此面孔加载到dlib模型中,并尝试识别是否存在同一个人。一切正常,甚至正确,但是在i7 8550U和16gb ram内存上大约需要1分30秒才能识别出面部。所以在我看来,我做错了。我有一些代码可以比较面孔:
anet_type dlibNet;
deserialize("dlib_face_recognition_resnet_model_v1.dat") >> dlibNet;
...
cv::Mat img1 = cv::imread("img1.jpg");
cv::Mat img2 = cv::imread("img2.jpg");
cv::resize(img1, img1, cv::Size(150, 150));
cv::resize(img2, img2, cv::Size(150, 150));
cv_image<bgr_pixel> image1(img1);
matrix<rgb_pixel> matr1;
assign_image(matr1, image1);
cv_image<bgr_pixel> image2(img2);
matrix<rgb_pixel> matr2;
assign_image(matr2, image2);
std::vector<matrix<rgb_pixel>> faces;
faces.push_back(matr1);
faces.push_back(matr2);
std::vector<matrix<float, 0, 1>> face_descriptors = dlibNet(faces);
if (length(face_descriptors[0] - face_descriptors[1]) < 0.6)
cout << "Same person" << endl;
else
cout << "Fail. Different people" << endl;