OpenCV配置C++篇(Debug与Release下有所区别)

原始出处: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<
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;
}
 

你可能感兴趣的:(C++)