c++ - 通过 dlib 进行人脸识别太慢
问题描述
我正在使用这个 OpenCV 示例进行人脸检测。然后我使用这个 dlib 示例进行人脸识别。第一步是使用 OpenCV 检测人脸并将检测到的矩形保存在 jpg 中。我也对第二张图片做同样的事情。之后,我将这些面孔加载到 dlib 模型中,并尝试识别是否存在同一个人。一切正常,甚至是正确的,但在我的 i7 8550U 和 16gb 内存上识别人脸大约需要 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;
解决方案
推荐阅读
- unity3d - 空的游戏对象重置为 0,0,0 但现在我不能用它的孩子移动它,因为箭头在 0,0,0 处很远,无论如何要改变它?
- swift - 在其他数组中使用 ForEach 的索引
- sql - 在 SQL 中计算作业的结束时间,知道作业开始时间、暂停时间和作业持续时间(以分钟为单位)
- javascript - 如何仅更改引脚的颜色
- javascript - 一种更简洁的对象解构方式,即嵌套?
- flutter - 当列表视图下方的小部件高度减小时,在框架期间计划构建
- node.js - 从 heroku 仪表板查看文件/文件夹
- javascript - Angular:单击保存时,保持所有选项卡不变
- rest - 我在 localhost 中运行的 API 的自定义端口号
- azure - Azure Sentinel 工作簿由于缓存而显示旧数据