我正在使用 Windows 7 中的 Qt 和 Opencv 进行基于人脸识别的项目。我现在遇到了一个真正的死胡同……我需要使用一些图像来训练人脸识别器……但是每当我注释掉火车声明,程序运行良好,但没有放弃我的目的......
void Dialog::on_btnAdd_2_clicked()
{
tmrTimer->stop();
dir=QDir(directory);
QFileInfoList files;
QFileInfo file;
QString filen;
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
files=dir.entryInfoList();
int nofiles;
nofiles=files.size();
for(int i=0;i<nofiles;i++)
{
file=files.at(i);
filen=file.absoluteFilePath();
std::string fname = filen.toStdString();
filen=file.baseName();
std::string filename=filen.toStdString();
char* path = new char [fname.size()+1];
char name[10];
strcpy(name,filename.c_str());
strcpy( path, fname.c_str() );
name[1]='\0';
ui->boxConsole->appendPlainText(path);
ui->boxConsole->appendPlainText(name);
cv::Mat temp=cv::imread(path,-1);
newImages.push_back(temp);
newLabels.push_back(atoi(name));
}
ui->boxConsole->appendPlainText("Training Started....!!");
cv::Ptr<cv::FaceRecognizer> model = cv::createEigenFaceRecognizer();
model->train(newImages,newLabels); ///training statement
//strcat(home,"\\data.xml");
//model->save(home);
ui->boxConsole->appendPlainText("Training Completed!!");
tmrTimer->start();
}
当我运行项目并单击启动上述功能的按钮时,进程崩溃说...
Problem signature:
Problem Event Name: APPCRASH
Application Name: QtTracker3.exe
Application Version: 0.0.0.0
Application Timestamp: 5101dde0
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
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
我按照以下建议修改了代码...并遇到了另一个问题...
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;
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();
std::string filename=filen.toStdString();
strcpy(name,filename.c_str());
for(j=0;name[j]!='-';j++);
name[j]='\0';
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(offimage);
newLabels.push_back(atoi(name));
}
我删除了 for 循环中使用的指针,但同样的问题仍然存在......
我还发现 qt creator 在其问题选项卡中报告了一个问题:
:-1: warning: auto-importing has been activated without --enable-auto-import specified on the command line.