Important: Please read the Qt Code of Conduct -

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.
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <opencv2/calib3d/calib3d.hpp>
    //#include <opencv2/calib3d/calib3d.hpp>
    using namespace cv;
    namespace Ui {
    class MainWindow;
    class MainWindow : public QMainWindow
        explicit MainWindow(QWidget *parent = 0);

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

    #endif // MAINWINDOW_H@

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

    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
       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;
        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;
            float result= SVM.predict(feature_vector);
            return result;

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

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

    This is the error i faced at
    @ 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


    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