首页 > 解决方案 > 使用预测时未处理的异常(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.

谁能帮我解决这个问题?非常感谢

标签: c++face-recognitionunhandled-exception

解决方案


推荐阅读