SURF源碼分析之surflib.h

surflib.h有三個函數組成,第一個函數是第二個和第三個的合體數組

一、提取關鍵點並提取特徵點描述因子surfDetDes()函數

二、提取關鍵點 surfDet()ui

三、提取特徵點描述因子surfDes(()rest

#ifndef SURFLIB_H
#define SURFLIB_H

#include <cv.h>
#include <highgui.h>

#include "integral.h"
#include "fasthessian.h"
#include "surf.h"
#include "ipoint.h"
#include "utils.h"

//! 提取描述因子
//  img 待提取描述因子圖像
//  ipts 存儲關鍵點信息的容器
//  upright 是否適用於旋轉不變模型
//  octaves 尺度空間組數
//  intervals 尺度空間每組包含的層數
//  init_sample 初始抽樣倍數
//  thres blob 閥值
//! Library function builds vector of described interest points
inline void surfDetDes(IplImage *img,  /* image to find Ipoints in */
                       std::vector<Ipoint> &ipts, /* reference to vector of Ipoints */
                       bool upright = false, /* run in rotation invariant mode? */
                       int octaves = OCTAVES, /* number of octaves to calculate */
                       int intervals = INTERVALS, /* number of intervals per octave */
                       int init_sample = INIT_SAMPLE, /* initial sampling step */
                       float thres = THRES /* blob response threshold */)
{
  // 構造積分圖
  // Create integral-image representation of the image
  IplImage *int_img = Integral(img);
  
  // 建立快速hessian對象
  // Create Fast Hessian Object
  FastHessian fh(int_img, ipts, octaves, intervals, init_sample, thres);
  
  // 提取興趣點並保存於容器ipts中 
  // Extract interest points and store in vector ipts
  fh.getIpoints();
  
  // 建立Surf des
  // Create Surf Descriptor Object
  Surf des(int_img, ipts);
  
  // 提取描述因子
  // Extract the descriptors for the ipts
  des.getDescriptors(upright);
  
  // 釋放積分圖內存
  // Deallocate the integral image
  cvReleaseImage(&int_img);
}


//! Library function builds vector of interest points
//! 提取圖像關鍵點
inline void surfDet(IplImage *img,  /* image to find Ipoints in */
                    std::vector<Ipoint> &ipts, /* reference to vector of Ipoints */
                    int octaves = OCTAVES, /* number of octaves to calculate */
                    int intervals = INTERVALS, /* number of intervals per octave */
                    int init_sample = INIT_SAMPLE, /* initial sampling step */
                    float thres = THRES /* blob response threshold */)
{
  // Create integral image representation of the image
  IplImage *int_img = Integral(img);

  // Create Fast Hessian Object
  FastHessian fh(int_img, ipts, octaves, intervals, init_sample, thres);

  // Extract interest points and store in vector ipts
  fh.getIpoints();

  // Deallocate the integral image
  cvReleaseImage(&int_img);
}




//! Library function describes interest points in vector
//! 提取圖像特徵描述因子
inline void surfDes(IplImage *img,  /* image to find Ipoints in */
                    std::vector<Ipoint> &ipts, /* reference to vector of Ipoints */
                    bool upright = false) /* run in rotation invariant mode? */
{ 
  // Create integral image representation of the image
  IplImage *int_img = Integral(img);

  // Create Surf Descriptor Object
  Surf des(int_img, ipts);

  // Extract the descriptors for the ipts
  des.getDescriptors(upright);
  
  // Deallocate the integral image
  cvReleaseImage(&int_img);
}


#endif
相關文章
相關標籤/搜索