OpenCV 从 VS2013 迁移到 QT 5.5
Posted
技术标签:
【中文标题】OpenCV 从 VS2013 迁移到 QT 5.5【英文标题】:OpenCV migration from VS2013 to QT 5.5 【发布时间】:2015-10-07 08:03:23 【问题描述】:我已经从here 下载了适用于 windows 的 OpenCV 2.4.11,并像这样为 Visual Studio 2013(x86) 设置了它:
RB=右键
项目上的 RB -> 配置属性 -> 调试 -> 环境项目中的 RB -> 配置属性 -> C/C++ -> 常规 -> 其他包含目录PATH=%PATH%;D:\opencv_2411\opencv\build\x86\vc12\bin
项目上的 RB -> 配置属性 -> 链接器 -> 常规 -> 附加 图书馆目录D:\opencv_2411\opencv\build\include
项目上的 RB -> 配置属性 -> 链接器 -> 输入 -> 其他图书馆目录D:\opencv_2411\opencv\build\x86\vc12\lib
包括:opencv_calib3d2411d.lib opencv_contrib2411d.lib opencv_core2411d.lib opencv_features2d2411d.lib opencv_flann2411d.lib opencv_gpu2411d.lib opencv_highgui2411d.lib opencv_imgproc2411d.lib opencv_legacy2411d.lib opencv_ml2411d.lib opencv_nonfree2411d.lib opencv_objdetect2411d.lib opencv_ocl2411d.lib opencv_photo2411d.lib opencv_stitching2411d.lib opencv_superres2411d.lib opencv_ts2411d.lib opencv_video2411d.lib opencv_videostab2411d.lib
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std;
一切正常,但现在我正尝试在 QT 5.5 中做同样的事情:
我用基类“QDialog”和这些工具包制作了新的“QT Witgets Application”:
使用这个 .pro 文件:
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-07T10:54:31
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = asd
TEMPLATE = app
SOURCES += main.cpp\
dialog.cpp
HEADERS += dialog.h
FORMS += dialog.ui
INCLUDEPATH += D:\opencv_2411\opencv\build\include
LIBS += D:\opencv_2411\opencv\build\x64\vc12\lib \
-lopencv_calib3d2411.lib \
-lopencv_core2411.lib \
-lopencv_features2d2411.lib \
-lopencv_flann2411.lib \
-lopencv_highgui2411.lib \
-lopencv_imgproc2411.lib \
-lopencv_ml2411.lib \
-lopencv_objdetect2411.lib \
-lopencv_photo2411.lib \
-lopencv_stitching2411.lib \
-lopencv_superres2411.lib \
-lopencv_ts2411.lib \
-lopencv_video2411.lib \
-lopencv_videostab2411.lib
我运行 qmake 以应用 .pro 文件中的更改。在我的源文件中,我有:
#include "dialog.h"
#include <QApplication>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
int main(int argc, char *argv[])
QApplication a(argc, argv);
Dialog w;
w.show();
return a.exec();
Build 运行时出现以下错误:
:-1: 错误: LNK1104: 无法打开文件 'D:\opencv_2411\opencv\build\x64\vc12\lib.obj'
我该如何解决这个问题?
【问题讨论】:
LIBS += -L感谢 Miki,对 .pro 文件的最后补充如下:
INCLUDEPATH += D:\opencv_2411\opencv\build\include
LIBS += -LD:\opencv_2411\opencv\build\x64\vc12\lib \
-lopencv_calib3d2411 \
-lopencv_core2411 \
-lopencv_features2d2411 \
-lopencv_flann2411 \
-lopencv_highgui2411 \
-lopencv_imgproc2411 \
-lopencv_ml2411 \
-lopencv_objdetect2411 \
-lopencv_photo2411 \
-lopencv_stitching2411 \
-lopencv_superres2411 \
-lopencv_ts2411 \
-lopencv_video2411 \
-lopencv_videostab2411
但如果您在使用 imread 和其他功能时仍有问题,请参阅this 主题。
【讨论】:
以上是关于OpenCV 从 VS2013 迁移到 QT 5.5的主要内容,如果未能解决你的问题,请参考以下文章
从 Qt 4.x (Ubuntu Linux) 迁移到 Qt 5.1 (Windows 7)
将 C++ ATL 可执行应用程序从 VS2003 迁移到 VS2013