我正在使用QT-Creater 5.2创建一个GUI来显示Image和二进制分类器 使用Dalal& amp;检测对象是否存在。触发HOG提取算法。
我正面临上述运行时错误&需要帮助来解决这个问题。
此致 西
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();
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();
}