OpenCV配置文件的配置

3 篇文章 0 订阅

OpenCV头文件:

#include <iostream>  
#include <opencv2/core/core.hpp>  
#include <opencv2/highgui/highgui.hpp>  
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;

QT中OpenCV配置文件的配置
第一种方法
添加下列代码在pro文件中:

INCLUDEPATH += /usr/local/include/opencv
LIBS += -lopencv_core \
-lopencv_imgproc \
-lopencv_highgui \
-lopencv_ml \
-lopencv_video \
-lopencv_features2d \
-lopencv_calib3d \
-lopencv_objdetect \
-lopencv_contrib \
-lopencv_legacy \
-lopencv_flann

第二种方法
在pro文件夹中加入以下配置说明:

INCLUDEPATH+=E:\opencvForQt\include
INCLUDEPATH+=E:\opencvForQt\include\opencv
INCLUDEPATH+=E:\opencvForQt\include\opencv2
LIBS += -L E:\opencvForQt\lib\libopencv_*.a
完整配置:

QT += core

QT -= gui

TARGET = testOpencv
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

INCLUDEPATH+=E:\opencvForQt\include
INCLUDEPATH+=E:\opencvForQt\include\opencv
INCLUDEPATH+=E:\opencvForQt\include\opencv2
LIBS += -L E:\opencvForQt\lib\libopencv_*.a


vs中opencv2.4.9的配置

  1. 在弹出来的“编辑系统变量”对话框中,在“变量值”这一栏添加(注意是添加,就是在这一栏的最后使用分号隔开后添加)
    “path=F:\opencv\build\x86\vc10\bin;F:\opencv\build\x64\vc10\lib;”(如果是32位系统,就可以不用后面这个)。
    vc9,vc10,vc11,vc12分别表示VS2008,VS2010,VS2012,VS2013的VisualStudio使用的编译器版本,根据自己的VS版本来填写正确的编译器版本号

  2. 点击项目->Debug|Win32->Microsoft.Cpp.Win32.userDirectories(反键属性)即可打开属性页,点击属性,如下图:在这里插入图片描述

  3. 通用属性 ->VC++目录 ->包含目录中->编辑,如下图:然后添加上一下三个目录:
    F:\opencv\build\include
    F:\opencv\build\include\opencv
    F:\opencv\build\include\opencv2在这里插入图片描述

  4. 通用属性 ->VC++目录 ->库目录。添加上:

F:\opencv\build\x86\vc10\lib
F:\opencv\build\x64\vc10\lib
对于32位操作系统来说,这里肯定选择x86,而对于64为操作系统来说,看你自己编译的时候用哪个编译器,假如用Win32则是x86,假如是选择的是x64,则用x64,如下图:在这里插入图片描述

  1. 链接库的配置

属性管理器”工作区中,点击项目 ->Debug|Win32->Microsoft.Cpp.Win32.userDirectories(右键属性)即可打开属 性页面。通用属性 ->链接器->输入->附加的依赖项
其中249代表的是2.4.9版本,假如是其他版本,比如2.4.8,则把249改成248。2.4.10版本改成2410。(19个带“d”的debug版本;19个不带“d”的release版本)
添加以下库:

opencv_ml249d.lib
opencv_calib3d249d.lib
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_objdetect249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_nonfree249d.lib
opencv_ocl249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_superres249d.lib
opencv_videostab249d.lib
opencv_objdetect249.lib
opencv_ts249.lib
opencv_video249.lib
opencv_nonfree249.lib
opencv_ocl249.lib
opencv_photo249.lib
opencv_stitching249.lib
opencv_superres249.lib
opencv_videostab249.lib
opencv_calib3d249.lib
opencv_contrib249.lib
opencv_core249.lib
opencv_features2d249.lib
opencv_flann249.lib
opencv_gpu249.lib
opencv_highgui249.lib
opencv_imgproc249.lib
opencv_legacy249.lib
opencv_ml249.lib

注:
解决方案:
1>LINK : fatal error LNK1104: 无法打开文件“cv.lib”
由于cv.lib是opencv1.0的,下载opencv1.0
链接: http://pan.baidu.com/s/1qY1ZWsc 密码: zzyb
http://www.cnblogs.com/xiaochige/p/5990858.html
相关配置:
https://www.cnblogs.com/xiaochige/p/5991187.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值