加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

OpenCV配置(C++篇)

(2014-04-04 22:05:58)
标签:

国旗

目录

变量

c

张志智

分类: 软件使用

配置环境:vs201364位)+OpenCV 2.4.8+win8.164位)

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;

}

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有