1

到目前为止,我一直在 VS 2012 中使用 OpenCV。一切正常。现在我正在尝试在 QtCreator 中工作,但我遇到了问题。当我在调试中运行项目时,出现错误:

"C:\Qt\Qt5.0.2\Tools\QtCreator\bin\DetectorPietoni\mainwindow.cpp:4: error: C1083: Cannot open include file: 'opencv2/core/core.hpp': No such file or directory"

在发布模式下,我收到错误:

"mainwindow.obj:-1: error: LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "private: void __cdecl MainWindow::on_pushButton_clicked(void)" (?on_pushButton_clicked@MainWindow@@AEAAXXZ)".

我正在运行的代码是下一个:

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

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_pushButton_clicked()
{
    cv::Mat img = cv::imread("C:\\PedestrianDetectionDataset\\test\\pos\\1.png");
}

我的设置是:

TARGET = DetectorPietoni
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui

INCLUDEPATH += C:\OpenCV-2.4.5\\opencv\build\include

CONFIG(release,debug|release)
{
    LIBS += C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_core245.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_features2d245.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_highgui245.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_imgproc245.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_ml245.lib
}

CONFIG(debug,debug|release)
{
    LIBS += C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_core245d.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_features2d245d.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_highgui245d.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_imgproc245d.lib \
            C:\\OpenCV-2.4.5\\opencv\\build\\x64\\vc11\\lib\\opencv_ml245d.lib
}

有什么想法吗?

4

1 回答 1

0

尝试应对opencv.hpp_C:\OpenCV-2.4.5\opencv\build\include\opencv2C:\OpenCV-2.4.5\opencv\build\include

然后它可能能够找到包含。

于 2013-08-14T13:31:10.120 回答