【发布时间】:2013-06-20 16:17:12
【问题描述】:
我正在使用 Qt 5.0.2 并尝试开始使用 OpenCv。
如果我运行以下程序,它只显示一个控制台并说按任意键,但它不显示任何图像。我什至没有收到 qDebug() 消息。
但是,删除了 Opencv 的内容后,我收到了消息。
PS:是的,我确保 Desert.jpg 位于 exe 所在的同一文件夹中。 first-openCV-test.pro:
QT += core
QT -= gui
TARGET = first-openCV-test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += F:\\QT\\libraries\\opencv\\opnecv_build_2.4.5\\install\\include
LIBS += -LF:\\QT\libraries\\opencv\\opnecv_build_2.4.5\\install\\lib \
-lopencv_core245.dll \
-lopencv_highgui245.dll \
-lopencv_imgproc245.dll \
-lopencv_features2d245.dll \
-lopencv_calib3d245.dll
main.cpp:
#include <QDebug>
#include <QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char *argv[])
{
// read an image
qDebug()<< "start initialising";
cv::Mat image= cv::imread("Desert.jpg");
// create image window named "My Image"
qDebug()<< "name Window";
cv::namedWindow("My Image");
// show the image on window
qDebug()<< "show image: ";
cv::imshow("My Image", image);
// wait key for 5000 ms
qDebug()<< "wait";
cv::waitKey(5000);
return 1;
}
/////////////////////////////////////// ///////////////////////////////////
感谢您的快速解答。
我尝试了一些东西,并重新构建并重新下载了它。我把它改成了这样:
QT += 核心
QT -= gui
目标 = 第一次测试
配置 += 控制台
配置 -= app_bundle
模板 = 应用程序
来源 += main.cpp
INCLUDEPATH += "F:/QT/libraries/opencv/build/include" \
"F:/QT/libraries/opencv/build/include/opencv" \
"F:/QT/libraries/opencv/build/include/opencv2"
LIBS += -L"F:/QT/libraries/opencv/build/x86/mingw/lib"
-libopencv_core245.dll
-libopencv_highgui245.dll
-libopencv_imgproc245.dll
-libopencv_features2d245.dll
-libopencv_calib3d245.dll
但现在我收到以下错误:
F:\A_PROJECTS\OPEN-CV\first-test\first-test\main.cpp:-1: Fehler:undefined reference to `cv::fastFree(void*)'
F:\A_PROJECTS\OPEN-CV\first-test\first-test\main.cpp:-1: Fehler: undefined reference to `cv::Mat::deallocate()'
【问题讨论】:
-
感谢您的快速解答。