• 大小: 15.24MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-21
  • 语言: C/C++
  • 标签: surf  c++  

资源简介

基于SURF特征检测程序 可以在VC6.0 下直接运行,对特征匹配的需求的同学有一定的帮助

资源截图

代码片段和文件信息

/*
 * A Demo to OpenCV Implementation of SURF
 * Further Information Refer to “SURF: Speed-Up Robust Feature“
 * Author: Liu Liu
 * liuliu.1987+opencv@gmail.com
 */

#include 
#include 
#include 
#include 
#include 

#include 
#include 

using namespace std;

#if _DEBUG
#pragma  comment(lib “cv200d.lib“)
#pragma  comment(lib “cxcore200d.lib“)
#pragma  comment(lib “cvaux200d.lib“)
#pragma  comment(lib “highgui200d.lib“)
#pragma  comment(lib “ml200d.lib“)
#else
#pragma  comment(lib “cv200.lib“)
#pragma  comment(lib “cxcore200.lib“)
#pragma  comment(lib “cvaux200.lib“)
#pragma  comment(lib “highgui200.lib“)
#pragma  comment(lib “ml200.lib“)
#endif


// define whether to use approximate nearest-neighbor search
#define USE_FLANN


IplImage *image = 0;

double
compareSURFDescriptors( const float* d1 const float* d2 double best int length )
{
    double total_cost = 0;
    assert( length % 4 == 0 );
    for( int i = 0; i < length; i += 4 )
    {
        double t0 = d1[i] - d2[i];
        double t1 = d1[i+1] - d2[i+1];
        double t2 = d1[i+2] - d2[i+2];
        double t3 = d1[i+3] - d2[i+3];
        total_cost += t0*t0 + t1*t1 + t2*t2 + t3*t3;
        if( total_cost > best )
            break;
    }
    return total_cost;
}


int
naiveNearestNeighbor( const float* vec int laplacian
                      const CvSeq* model_keypoints
                      const CvSeq* model_descriptors )
{
    int length = (int)(model_descriptors->elem_size/sizeof(float));
    int i neighbor = -1;
    double d dist1 = 1e6 dist2 = 1e6;
    CvSeqReader reader kreader;
    cvStartReadSeq( model_keypoints &kreader 0 );
    cvStartReadSeq( model_descriptors &reader 0 );

    for( i = 0; i < model_descriptors->total; i++ )
    {
        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
        const float* mvec = (const float*)reader.ptr;
     CV_NEXT_SEQ_ELEM( kreader.seq->elem_size kreader );
        CV_NEXT_SEQ_ELEM( reader.seq->elem_size reader );
        if( laplacian != kp->laplacian )
            continue;
        d = compareSURFDescriptors( vec mvec dist2 length );
        if( d < dist1 )
        {
            dist2 = dist1;
            dist1 = d;
            neighbor = i;
        }
        else if ( d < dist2 )
            dist2 = d;
    }
    if ( dist1 < 0.6*dist2 )
        return neighbor;
    return -1;
}

void
findPairs( const CvSeq* objectKeypoints const CvSeq* objectDescriptors
           const CvSeq* imageKeypoints const CvSeq* imageDescriptors vector& ptpairs )
{
    int i;
    CvSeqReader reader kreader;
    cvStartReadSeq( objectKeypoints &kreader );
    cvStartReadSeq( objectDescriptors &reader );
    ptpairs.clear();

    for( i = 0; i < objectDescriptors->total; i++ )
    {
        const CvSURFPoint* kp = (const CvSURFPoint*)kreader.ptr;
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-11-20 19:00  surf\
     目录           0  2013-11-20 19:00  surf\Debug\
     文件     1647104  2012-07-17 11:38  surf\Debug\cv200.dll
     文件     3389952  2012-07-17 11:33  surf\Debug\cv200d.dll
     文件     1010688  2012-07-17 11:40  surf\Debug\cvaux200.dll
     文件     2317312  2012-07-17 11:34  surf\Debug\cvaux200d.dll
     文件     2071040  2012-07-17 11:37  surf\Debug\cxcore200.dll
     文件     3638272  2012-07-17 11:32  surf\Debug\cxcore200d.dll
     文件      200192  2012-07-17 11:38  surf\Debug\cxts200.dll
     文件      435200  2012-07-17 11:33  surf\Debug\cxts200d.dll
     文件      774144  2012-07-17 11:39  surf\Debug\highgui200.dll
     文件     1631232  2012-07-17 11:33  surf\Debug\highgui200d.dll
     文件      432128  2012-07-17 11:38  surf\Debug\ml200.dll
     文件      945152  2012-07-17 11:33  surf\Debug\ml200d.dll
     文件     5205504  2012-07-17 11:39  surf\Debug\opencv_ffmpeg200.dll
     文件     6607872  2012-07-17 11:33  surf\Debug\opencv_ffmpeg200d.dll
     文件       99328  2012-07-19 15:39  surf\Debug\surf.exe
     文件      723672  2012-07-19 15:39  surf\Debug\surf.ilk
     文件     1264640  2012-07-19 15:39  surf\Debug\surf.pdb
     目录           0  2013-11-20 19:00  surf\surf\
     文件    15346688  2012-07-19 19:58  surf\surf.ncb
     文件         878  2012-07-19 15:25  surf\surf.sln
     文件       22528  2012-07-19 19:58  surf\surf.suo
     目录           0  2013-11-20 19:00  surf\surf\Debug\
     文件        6210  2012-07-19 15:39  surf\surf\Debug\BuildLog.htm
     文件      351979  2012-07-19 15:39  surf\surf\Debug\find_obj.obj
     文件          67  2012-07-19 15:39  surf\surf\Debug\mt.dep
     文件         663  2012-07-19 15:28  surf\surf\Debug\surf.exe.embed.manifest
     文件         728  2012-07-19 15:28  surf\surf\Debug\surf.exe.embed.manifest.res
     文件         621  2012-07-19 15:39  surf\surf\Debug\surf.exe.intermediate.manifest
     文件      601088  2012-07-19 15:39  surf\surf\Debug\vc90.idb
............此处省略4个文件信息

评论

共有 条评论