I am working on a project based on face recognition and modefied the code here such that the image file paths are read using Qt directory libraries and is working fine. Problem occurs when I try to train the fisher faces model ,i.e the model->train() call let the app to crash..
void Dialog::on_btnAdd_2_clicked()
{
tmrTimer->stop();
dir=QDir(directory);
QFileInfoList files;
QFileInfo file;
QString filen;
char name[10];
int i,j;
std::string str;
std::string filename;
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
files=dir.entryInfoList();
int nofiles;
nofiles=files.size();
for(i=0;i<nofiles;i++)
{
file=files.at(i);
filen=file.baseName();
filename=filen.toStdString();
strcpy(name,filename.c_str());
for(j=0;name[j]!='-';j++);
name[j]='\0'; //label value ends with '-' in image names
filen=file.absoluteFilePath();
str=filen.toStdString();
/*
cv::Mat offimage=cv::imread(str.c_str(),-1);
cv::namedWindow("face",WINDOW_AUTOSIZE); //show retrieved image in a window
cv::imshow("face",offimage);
cvvWaitKey(1000);
*/
newImages.push_back(cv::imread(str.c_str(),CV_LOAD_IMAGE_GRAYSCALE));
newLabels.push_back(atoi(name));
}
ui->boxConsole->appendPlainText("Training Started....!!");
cv::Ptr<cv::FaceRecognizer> model = cv::createFisherFaceRecognizer();
model->train(newImages,newLabels); //this causes the error
//strcat(home,"\\data.xml");
//model->save(home);
ui->boxConsole->appendPlainText("Training Completed!!");
tmrTimer->start();
}
I am using windows 7 environment and ide is Qt creator. The crash report by the OS says that :
Problem signature:
Problem Event Name: APPCRASH
Application Name: QtTracker3.exe
Application Version: 0.0.0.0
Application Timestamp: 51035d17
Fault Module Name: libopencv_core242.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 50da6896
Exception Code: c0000005
Exception Offset: 000a38f0
OS Version: 6.1.7600.2.3.0.256.1
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789