1

我正在从事基于人脸识别的项目,并且我使用了 Open cv Fisherfaces。我首先打算将人脸保存在一个目录中并从该目录中读取以训练 Fisher 人脸对象,但在训练时 Windows 显示错误。我正在使用 Qt 创建 GUI:

Problem signature:
  Problem Event Name: APPCRASH
  Application Name:   QtTracker3.exe
  Application Version:    0.0.0.0
  Application Timestamp:  5100b46b
  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

显示错误的代码条:

void Dialog::on_btnAdd_2_clicked()
{
    tmrTimer->stop();
    ui->boxConsole->appendPlainText("Training Started....!!");

    cv::Ptr<cv::FaceRecognizer> model = cv::createFisherFaceRecognizer();

    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();
        char* path;
        std::string fname = filen.toStdString();
        path = new char [fname.size()+1];
        strcpy( path, fname.c_str() );

        ui->boxConsole->appendPlainText(path);
        newImages.push_back(cv::imread(path,0)); //std::vector<cv::Mat> newImages; std::vector<int> newLabels; defined in the header
        newLabels.push_back(i);
    }

    model->train(newImages,newLabels);  //this wen commented relieves the error but needs it....
    strcat(home,"\\data.xml");


    model->save(home);


    ui->boxConsole->appendPlainText("Training Completed!!");
    tmrTimer->start();
}
4

0 回答 0