OpenCV配置C++篇(Debug与Release下有所区别)
2015-02-06 20:18
375 查看
原始出处:http://blog.sina.com.cn/s/blog_6f7265cf0101nsob.html
配置环境:vs2013(64位)+OpenCV 2.4.8+win8.1(64位)
OpenCV安装路径:C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv为例
1.环境变量:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\x64\vc12\bin;
2.包含目录:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\include;
3.包含库目录:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\x64\vc12\lib;
4.链接器->输入(Debug下,若为Release去掉所有的’d’;当然也可以把两种都加入,以免两种模式切换配置麻烦):
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_objdetect248d.lib
opencv_ts248d.lib
opencv_video248d.lib
opencv_nonfree248d.lib
5.示例程序:
用OpenCV实现SIFT特征的提取
#include “stdio.h”
#include “iostream”
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include “vector”
#include “fstream”
#include “AFXWin.h”
#include “comdef.h”
using namespace cv;
using namespace std;
void readme();
string ws2s(const wstring& ws)
{
_bstr_t t = ws.c_str();
char* pchar = (char*)t;
string result = pchar;
return result;
}
int main(int argc, char** argv)
{
CFileFind finder;
BOOL bWorking = finder.FindFile(L"C:\\Users\\zhangzhizhi\\Pictures\\国旗\\普通\\*.png");
DWORD selectionBeforeTime = ::GetTickCount();
if (bWorking)
{
bWorking = finder.FindNextFile();
CString sFileName = finder.GetFilePath();
Mat img = imread(ws2s(sFileName.GetString()));
SiftFeatureDetector detector;
vector<</SPAN>KeyPoint> keypoints;
detector.detect(img, keypoints);
SiftDescriptorExtractor extractor;
Mat descr;
extractor.compute(img, keypoints, descr);
ofstream ofile;
int n = sFileName.Replace(L".png", L".txt");
ofile.open(ws2s(sFileName.GetString()));
ofile << format(descr, "csv");
ofile.close();
}
finder.Close();
DWORD predictionBeforeTime = ::GetTickCount();
DWORD selectionSpeed = predictionBeforeTime - selectionBeforeTime;
cout << "用时:" << selectionSpeed*1.0 / 1000 << "s" << endl;
return 0;
}
配置环境:vs2013(64位)+OpenCV 2.4.8+win8.1(64位)
OpenCV安装路径:C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv为例
1.环境变量:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\x64\vc12\bin;
2.包含目录:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\include;
3.包含库目录:
C:\Users\zhangzhizhi\Documents\Everyone\张志智\总结积累\OpenCV\opencv\build\x64\vc12\lib;
4.链接器->输入(Debug下,若为Release去掉所有的’d’;当然也可以把两种都加入,以免两种模式切换配置麻烦):
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_objdetect248d.lib
opencv_ts248d.lib
opencv_video248d.lib
opencv_nonfree248d.lib
5.示例程序:
用OpenCV实现SIFT特征的提取
#include “stdio.h”
#include “iostream”
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include “vector”
#include “fstream”
#include “AFXWin.h”
#include “comdef.h”
using namespace cv;
using namespace std;
void readme();
string ws2s(const wstring& ws)
{
_bstr_t t = ws.c_str();
char* pchar = (char*)t;
string result = pchar;
return result;
}
int main(int argc, char** argv)
{
CFileFind finder;
BOOL bWorking = finder.FindFile(L"C:\\Users\\zhangzhizhi\\Pictures\\国旗\\普通\\*.png");
DWORD selectionBeforeTime = ::GetTickCount();
if (bWorking)
{
bWorking = finder.FindNextFile();
CString sFileName = finder.GetFilePath();
Mat img = imread(ws2s(sFileName.GetString()));
SiftFeatureDetector detector;
vector<</SPAN>KeyPoint> keypoints;
detector.detect(img, keypoints);
SiftDescriptorExtractor extractor;
Mat descr;
extractor.compute(img, keypoints, descr);
ofstream ofile;
int n = sFileName.Replace(L".png", L".txt");
ofile.open(ws2s(sFileName.GetString()));
ofile << format(descr, "csv");
ofile.close();
}
finder.Close();
DWORD predictionBeforeTime = ::GetTickCount();
DWORD selectionSpeed = predictionBeforeTime - selectionBeforeTime;
cout << "用时:" << selectionSpeed*1.0 / 1000 << "s" << endl;
return 0;
}
相关文章推荐
- Release和Debug模式的区别以及Opencv在Release和Debug不同模式下的配置
- Release和Debug模式的区别以及Opencv在Release和Debug不同模式下的配置
- [OpenCV] VS2010中OpenCV2.X配置Debug和Release同时正常使用
- 【OpenCV配置之二】VS2013:LNK2038 RuntimeLibrary不匹配问题(Release Debug混合错误)
- OpenCV一次配置Debug和Release,反复使用的方法
- debug,trace,release项目配置区别
- Opencv在Release和Debug不同模式下的配置
- OpenCV一次配置Debug和Release,反复使用的方法
- VS 解决方案的配置Debug和Release有什么区别?
- OpenCV一次配置Debug和Release,反复使用的方法
- VS 解决方案的配置Debug和Release有什么区别?
- Debug和Release版的区别
- VS.Net中程序集的Debug版本和Release版本的区别
- Debug 和 Release 编译方式的本质区别
- 关于Debug和Release之本质区别的讨论
- Debug和Release之本质区别
- 关于Debug和Release之本质区别的讨论(z)
- Debug和Release版本 的区别
- 关于Debug和Release之本质区别的讨论~~(主要针对VC6.0和VS2003.net编译工具而言)
- Debug 和 Release 编译方式的本质区别