到目前为止,我在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
}
任何想法?
答案 0 :(得分:0)
尝试从opencv.hpp
到C:\OpenCV-2.4.5\opencv\build\include\opencv2
C:\OpenCV-2.4.5\opencv\build\include
然后它可以找到包含。