Vscode2013上配置Opencv2.4.9详解教程

下载Visual Studio Community 2013

Visual Studio Community 2013下载链接:Visual Studio Community 2013

opencv2.4.9

下载

OpenCV – 2.4.9 – 2014-04-11下载链接:opencv2.4.9

配置环境变量

在这里插入图片描述

在这里插入图片描述

配置Visual Studio Community 2013

新建visual C项目

新建 visual C++项目,如下图所示,项目选项注意:如下图。
在这里插入图片描述

在这里插入图片描述

工程目录的配置

view->other windows->preperty manager
Debug|Win32->Win32 User(右键)->preperties
1、包含目录:(VC++目录)

D:\Program Files\opencv\build\include

D:\Program Files\opencv\build\include\opencv

D:\Program Files\opencv\build\include\opencv2

2、库目录:(VC++目录)D:\Program Files\opencv\build\x86\vc12\lib
在这里插入图片描述
连接器->输入->附加依赖项:

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

在这里插入图片描述

可能会出现的Bug

vs2013配置opencv2.4.9后,运行程序。
出现找不到opencv_core249d.dll,opencv_highgui249d.dll,opencv_features2d249d.dll等问题。
解决办法
将opencv_core249d.dll;opencv_highgui249d.dll等缺失dll文件从“OpenCV的安装路径\opencv\build\x86\vc12\bin”拷贝到C:\WINDOWS\SYSTEM32和C:\Windows\SysWOW64下。这里由部分博客给出的是根据当前电脑位数是32还是64的,我是全部拷贝。
进入cmd,输入regsvr32 C:\Windows\System32\opencv_core249d.dll。

如果还报错的话。
在这里插入图片描述
可能是dll文件出现了问题。
解决方案:下载directx修复工具,操作教程。记得要重启一下,再运行试试

测试

#include "opencv2/core/core.hpp"
#include "highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp"

#include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/detail/camera.hpp"
#include "opencv2/stitching/detail/exposure_compensate.hpp"
#include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/detail/seam_finders.hpp"
#include "opencv2/stitching/detail/util.hpp"
#include "opencv2/stitching/detail/warpers.hpp"
#include "opencv2/stitching/warpers.hpp"

#include <iostream>
#include <fstream> 
#include <string>
using namespace cv;
using namespace std;
using namespace detail;

int main(int argc, char** argv)
{
	Mat img = imread("G://vcproject2.4.9//test_opencv//a.jpg");    //读入图像

	Ptr<FeaturesFinder> finder;    //定义FeaturesFinder类

	finder = new SurfFeaturesFinder();    //应用SURF方法
	//finder = new OrbFeaturesFinder();    //应用ORB方法

	ImageFeatures features;    //表示特征

	(*finder)(img, features);    //特征检测

	Mat output_img;
	//调用drawKeypoints函数绘制特征
	drawKeypoints(img, features.keypoints, output_img, Scalar::all(-1));

	namedWindow("features", CV_WINDOW_NORMAL);
	imshow("features", output_img);

	waitKey(0);

	return 0;
}

在这里插入图片描述

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值