OpenCV从VS2013迁移到QT 5.5

时间:2015-10-07 08:03:24

标签: c++ qt opencv visual-studio-2013

我已经从here下载了适用于Windows的OpenCV 2.4.11,并且已经像这样为Visual Studio 2013(x86)设置了它:

RB =右键

  • RB on project - >配置属性 - >调试 - >环境
  

PATH =%PATH%; d:\ opencv_2411 \的OpenCV \建立\ 86 \ VC12 \ BIN

  • RB on project - >配置属性 - > C / C ++ - >一般 - > 其他包含目录
  

d:\ opencv_2411 \的OpenCV \建立\包括

  • RB on project - >配置属性 - >链接器 - >一般 - >额外 图书馆馆长
  

d:\ opencv_2411 \的OpenCV \建立\ 86 \ VC12 \ lib中

  • RB on project - >配置属性 - >链接器 - >输入 - > 其他图书馆馆藏
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中做同样的事情:

enter image description here

我使用基类“QDialog”制作了新的“QT Witgets Application”和这些套件:

enter image description here

使用此.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();
}

构建运行时发生以下错误:

  

: - 1:错误:LNK1104:无法打开文件   'd:\ opencv_2411 \的OpenCV \建立\ 64 \ VC12 \ lib.obj'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

感谢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主题。