Results 1 to 3 of 3

Thread: Qt run time error in using compute function of HOG descriptor

  1. #1
    Join Date
    Feb 2014
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default 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.
    QT_ERROR.jpg

    mainwindow.h

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include<QDebug>
    6. #include <opencv2/calib3d/calib3d.hpp>
    7. //#include <opencv2/calib3d/calib3d.hpp>
    8. #include<opencv2/core/core.hpp>
    9. #include<opencv2/features2d/features2d.hpp>
    10. #include<opencv2/highgui/highgui.hpp>
    11. #include<opencv2/imgproc/imgproc.hpp>
    12. #include<opencv2/ml/ml.hpp>
    13. #include<opencv2/objdetect/objdetect.hpp>
    14. using namespace cv;
    15.  
    16. namespace Ui {
    17. class MainWindow;
    18. }
    19.  
    20. class MainWindow : public QMainWindow
    21. {
    22. Q_OBJECT
    23.  
    24. public:
    25. explicit MainWindow(QWidget *parent = 0);
    26. ~MainWindow();
    27.  
    28. private:
    29. Ui::MainWindow *ui;
    30. };
    31. float SVM_classifier(Mat image);
    32.  
    33.  
    34. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9.  
    10. IplImage *oMatDeltaImage = cvLoadImage("E:\\Wihart\\Car_Images\\(785).jpg",CV_LOAD_IMAGE_UNCHANGED);
    11.  
    12. Mat mat_img(oMatDeltaImage );
    13. float oMatResult = SVM_classifier(mat_img);
    14. // qDebug()<<oMatResult;
    15.  
    16. }
    17.  
    18. MainWindow::~MainWindow()
    19. {
    20. delete ui;
    21. }
    22.  
    23. float SVM_classifier(Mat image)
    24. {
    25.  
    26. resize(image, image, Size(64,128) );
    27.  
    28. HOGDescriptor extract_features;
    29. vector<float> descriptorsValues;
    30. descriptorsValues.resize(0.0);
    31. vector<Point> locations;
    32. locations.resize(0.0);
    33. extract_features.compute( image, descriptorsValues, Size(0,0), Size(0,0), locations);
    34.  
    35. Mat feature_vector(descriptorsValues);// = Mat::zeros((descriptorsValues.size(),1));
    36. CvSVM SVM;
    37. SVM.load("SVM_classifier_data.xml");
    38. float result= SVM.predict(feature_vector);
    39. return result;
    40. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9.  
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt run time error in using compute function of HOG descriptor

    Qt Code:
    1. IplImage *oMatDeltaImage = cvLoadImage("E:\\Wihart\\Car_Images\\(785).jpg",CV_LOAD_IMAGE_UNCHANGED);
    To copy to clipboard, switch view to plain text mode 

    How do you know that "oMatDeltaImage" is a valid pointer? I presume that if cvLoadImage() fails, it will return a NULL pointer. You don't check the return value, you simply use it in the next line and in SVM_classifier() and assume it is OK.

    The debugger would probably have found your error in less time than it took to make your post.

  3. #3
    Join Date
    Jun 2014
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: Qt run time error in using compute function of HOG descriptor

    I tried to run this program using visual studio 10 with a qt addin-1.19 in it. The code runs fine.

Similar Threads

  1. Compute Shader
    By bavarianbasti in forum Qt Programming
    Replies: 0
    Last Post: 22nd November 2013, 11:38
  2. Time is not getting displayed using tostring function!
    By sanujas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 31st January 2013, 14:15
  3. Replies: 10
    Last Post: 4th June 2010, 10:43
  4. Socket Descriptor
    By ManuMies in forum Qt Programming
    Replies: 1
    Last Post: 17th March 2009, 10:42
  5. Compute the area under a curve
    By giusepped in forum Qwt
    Replies: 0
    Last Post: 26th December 2008, 07:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.