[知识备忘]OpenCV安装与VS2010编译

2017-01-03 07:43:08来源:作者:人点击

快毕业了,把之前做的内容复习一下,防止以后忘了。

1、下载OpenCV
http://opencv.org/选择一个合适的版本。
2、安装

选择一个合适的文件夹,在该文件下安装

3、VS2010属性配置

(1)新建工程

(2)项目->属性->配置属性->VC++目录

包含目录: F:/Users/长发/Desktop/opencv/build/include

F:/Users/长发/Desktop/opencv/build/include/opencv

F:/Users/长发/Desktop/opencv/build/include/opencv2

库目录: F:/Users/长发/Desktop/opencv/build/x86/vc10/lib

(3)项目->属性->配置属性->链接器->输入

opencv_calib3d248d.lib

opencv_contrib248d.lib

opencv_core248d.lib

opencv_features2d248d.lib

opencv_flann248d.lib

opencv_gpu248d.lib

opencv_highgui248d.lib

opencv_imgproc248d.lib

opencv_legacy248d.lib

opencv_ml248d.lib

opencv_nonfree248d.lib

opencv_objdetect248d.lib

opencv_photo248d.lib

opencv_stitching248d.lib

opencv_ts248d.lib

opencv_video248d.lib

opencv_videostab248d.lib

opencv_calib3d248.lib

opencv_contrib248.lib

opencv_core248.lib

opencv_features2d248.lib

opencv_flann248.lib

opencv_gpu248.lib

opencv_highgui248.lib

opencv_imgproc248.lib

opencv_legacy248.lib

opencv_ml248.lib

opencv_nonfree248.lib

opencv_objdetect248.lib

opencv_photo248.lib

opencv_stitching248.lib

opencv_ts248.lib

opencv_video248.lib

opencv_videostab248.lib

配置完成。

4、程序测试:

#include "stdafx.h"

#include "cv.h"

#include "highgui.h"

#include <iostream>

using namespace std;

using namespace cv;

void colorReduce( Mat & inputImage, Mat & outputImage, int div );

int main()

{

Mat srcImage = imread( "perspective-quadrilateral-src-img.jpg" );

imshow( "原始图像", srcImage );

Mat dstImage;

dstImage.create( srcImage.rows, srcImage.cols, srcImage.type() );

double time0 = static_cast<double>( getTickCount() );

colorReduce( srcImage, dstImage, 32 );

time0 = ( (double)getTickCount() - time0 ) / getTickFrequency() ;

cout<< "此方法运行时间为: "<< time0 <<"秒" <<endl;

imshow( "效果图", dstImage );

waitKey( 0 );

}

void colorReduce ( Mat & inputImage, Mat &outputImage, int div )

{

outputImage = inputImage.clone();

int rowNumber = outputImage.rows;

int colNumber = outputImage.cols * outputImage.channels();

for ( int i = 0; i < rowNumber; i++ )

{

uchar *data = outputImage.ptr<uchar>(i);

for ( int j = 0; j < colNumber; j++ )

{

data[j] = data[j] / div * div + div / 2;

}

}

}

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台