Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9196631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:53:33+00:00 2026-06-17T21:53:33+00:00

I am working on a project based on facerecognition using Qt and Opencv in

  • 0

I am working on a project based on facerecognition using Qt and Opencv in Windows 7. I have come across a really dead end now…I need to train a face recognizer using some images…but whenever I comment out the train statement, the program runs fine but not witholding my purpose…

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();
}

When I run the project and click a button that initiate the above function the process crashes saying…

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

i modified the code as follows taking advices…and got in to another problem…

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));


        }

i removed the pointers used within the for loop and stil the very same problem persists…

I also found that qt creator in its issues tab reported an issue:

:-1: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:53:35+00:00Added an answer on June 17, 2026 at 9:53 pm

    When your code crashes, use a debugger to find out where it crashes. If you don’t understand the reason, add the backtrace to the question.

    I assume your crash is in the filename handling when looping over the files.
    You’re opening multiple cans of worms by using char* instead of the std::string or QString and not doing it properly.

    For once, this is highly unsafe and also insecure (buffer overflow):

        char name[10];
        ...
        strcpy(name,filename.c_str());
    

    If the file name is longer than 9, the behavior is undefined (crash, most likely).

    You’re also leaking memory, as this allocation is never freed: char* path = new char [fname.size()+1];

    So I strongly suggest to use QString instead of fiddling with char*. If you need to pass a char* to OpenCV, you can do it like this:

    const QByteArray ba = filename.toLatin1(); //or toUtf8(), toLocal8Bit(), depending on the encoding you need
    ... functionTakingChar( ba.constData(), -1 ); // or .data(), if imread() takes a non-const char
    

    imread takes a std::string, so:

    ... imread( filename.toStdString(), -1 );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working now on a project based on DirectX and I am
I am working on a project based on OpenCv. I have tried to use
I'm working on a php project based on Joomla! and i'm using Aptana. I'm
I'm working on a larger Web based Project, that probably will have to handle
I am working on a small starling based project and i need something as
I am currently working on a multi branch desktop based project using VB.NET 2008.
I have a view based project working with a UINavigationController. The RootViewController performs operations
I am working on a web based project in my free time. I have
I'm working on project that based on WPF and MVVM. I have some UserControl
I'm currently working on a Maven based project in which I have unit tests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.