关于opencv“无法训练”的Facerec示例

时间:2014-11-17 10:58:01

标签: c++ visual-studio opencv

每当代码执行model-> train(图像,标签)时; 该程序抛出一个内存位置异常 但是我通过imshow和cout检查了所有标签和图像 我无法找到问题所在。 有人可以帮我~~

int main(){

string root = "C:\\Users\\Administrator\\Desktop\\";
// holds images and labels
vector<Mat> images;
vector<int> labels;
// images for first person
images.push_back(imread(root + "person0\\0.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
images.push_back(imread(root + "person0\\1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
images.push_back(imread(root + "person0\\2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(0);
// images for second person
images.push_back(imread(root + "person1\\0.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
images.push_back(imread(root + "person1\\1.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);
images.push_back(imread(root + "person1\\2.jpg", CV_LOAD_IMAGE_GRAYSCALE)); labels.push_back(1);

Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
model->train(images, labels);




system("pause");
return 0;

}

0 个答案:

没有答案