c++ - 使用预测时未处理的异常(FaceRecognizer)
问题描述
我现在正在使用 C++ 进行人脸识别项目,我的这个项目的环境将是 Visual Studio 2019 和 OpenCV4.2.5,我已经将我的 VS2019 链接到 opencv_world452d.lib 和 opencv_face452d.lib。我的代码似乎很好,但我想知道为什么它总是显示未处理的异常(每次我尝试使用人脸识别)
这是发生错误的部分:
for (int i = 0; i < faces.size(); i++)
{
Rect face_i = faces[i];
Mat face = graySacleFrame(face_i);
Mat face_resized;
resize(face, face_resized, Size(img_width, img_height), 1.0, 1.0, INTER_CUBIC);
int label = -1; double confidence = 0;
model->predict(face_resized, label, confidence);
cout << " confidence " << confidence << " Label: " << label << endl;
Pname = to_string(label);
rectangle(original, face_i, CV_RGB(0, 255, 0), 1);
string text = Pname;
int pos_x = std::max(face_i.tl().x - 10, 0);
int pos_y = std::max(face_i.tl().y - 10, 0);
//name the person who is in the image
putText(original, text, Point(pos_x, pos_y), FONT_HERSHEY_COMPLEX_SMALL, 1.0, CV_RGB(0, 255, 0), 1.0);
//cv::imwrite("E:/FDB/"+frameset+".jpg", cropImg);
}
我尝试使用单元测试来找出问题,我发现问题出在“预测”部分,我在这个问题上尝试了几种方法,但我仍然无法解决任何问题(我的文件之前经过培训,它里面有三个模型)
model->predict(face_resized, label, confidence);
这将是代码的错误:
Unhandled exception at 0x00007FF8FF154B89 in Test.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000D9B99DD0D0.
谁能帮我解决这个问题?非常感谢
解决方案
推荐阅读
- javascript - 测试从回调中调用的 window.open 是否已执行
- karate - 空手道:dynamic-csv.feature 可以用于 Get Request,如何从 CSV 传递动态路径参数?
- javascript - 如何增加全局变量 onmousehover,但让它返回到正常值 onmouseout?
- c# - CefSharp Javascript异步响应太快
- delphi - 当我的光标悬停在 Delphi 中时,如何更改 TLabel 的颜色?
- node.js - 使用谷歌中等图像触发器时的应用程序/八位字节流问题(模糊图像)
- python - 为什么我不通过scrapy抓取数据?
- c++ - CTAD 无法在部分专业化中使用 SFINAE 推断模板参数
- asp.net - 使用 web.config 设置特定文件夹的权限
- javascript - 如何使用 JavaScript 变量的值更新虚拟 html 元素的样式属性?