Qt run time error in using compute function of HOG descriptor



  • I am using Qt-Creator 5.2.0 to create a GUI to display the Image and a binary classifier to detect the object is present or absent using Dalal & triggs HOG extraction algorithm.

    I am facing the mentioned Run time error & need help to solve this issue.
    mainwindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include<QDebug>
    #include <opencv2/calib3d/calib3d.hpp>
    //#include <opencv2/calib3d/calib3d.hpp>
    #include<opencv2/core/core.hpp>
    #include<opencv2/features2d/features2d.hpp>
    #include<opencv2/highgui/highgui.hpp>
    #include<opencv2/imgproc/imgproc.hpp>
    #include<opencv2/ml/ml.hpp>
    #include<opencv2/objdetect/objdetect.hpp>
    using namespace cv;
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    

    private:
    Ui::MainWindow *ui;
    };
    float SVM_classifier(Mat image);

    #endif // MAINWINDOW_H@
    

    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
       IplImage *oMatDeltaImage  = cvLoadImage("E:\\Wihart\\Car_Images\\(785).jpg",CV_LOAD_IMAGE_UNCHANGED);
    
        Mat mat_img(oMatDeltaImage );
        float oMatResult =  SVM_classifier(mat_img);
    //    qDebug()<<oMatResult;
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    float SVM_classifier(Mat image)
    {
    
            resize(image, image, Size(64,128) );
    
            HOGDescriptor extract_features;
            vector<float> descriptorsValues;
            vector<Point> locations;
            extract_features.compute( image, descriptorsValues, Size(0,0), Size(0,0), locations);
    
            Mat feature_vector(descriptorsValues);// = Mat::zeros((descriptorsValues.size(),1));
            CvSVM SVM;
            SVM.load("SVM_classifier_data.xml");
            float result= SVM.predict(feature_vector);
            return result;
    }@
    

    main.cpp
    @#include "mainwindow.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec&#40;&#41;;
    }@
    

    This is the error i faced at
    Line:
    @ extract_features.compute( image, descriptorsValues, Size(0,0), Size(0,0), locations);@

    Exception triggered:
    "The inferior stopped because it triggered an exception.
    Stopped in thread 0 by Exception 0xf8b3b11, code: 0xc0000005: write access violation at 0x1, flags= 0x0 (first chance)."


  • Lifetime Qt Champion

    Hi,

    Since you don't tell exactly what error you have, I would say that your application can't find the OpenCV dlls. So you need to update the Run panel PATH environment variable and add the path to OpenCV dlls there



  • Hi SGaist, sorry about that. I've included the error now.


  • Lifetime Qt Champion

    Then you should run your application through the debugger to see exactly where you are accessing something invalid


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.