VLFeat——SIFT图像特征提取(VC++实现)

本文转载于点击打开链接


包含头文件:

extern "C"{
#include
#include
#include
#include
#include
};


实现过程


#include 
#include 
#include 
#include 
#include 
#include 
#pragma comment(lib, "opencv_core230d.lib")
#pragma comment(lib, "opencv_imgproc230d.lib")
#pragma comment(lib, "opencv_highgui230d.lib")
#pragma comment(lib, "opencv_objdetect230d.lib")

using namespace cv;
using namespace std;

extern "C"{
#include 
#include 
#include 
#include 
#include 
};

int _tmain(int argc, _TCHAR* argv[])
{
    VL_PRINT ("Hello world!\n") ;
    char *ImagePath="a.jpg";
    IplImage *Image=cvLoadImage(ImagePath,0);
    //  int min=0;
    //  min=Image->width>Image->height?Image->height:Image->width;
    int noctaves=4,nlevels=2,o_min=0;
    // noctaves=(int)(log(min)/log(2));
    vl_sift_pix *ImageData=new vl_sift_pix[Image->height*Image->width];
    unsigned char *Pixel;
    for (int i=0;iheight;i++)
    {
        for (int j=0;jwidth;j++)
        {
            Pixel=(unsigned char*)(Image->imageData+i*Image->width+j);
            ImageData[i*Image->width+j]=*(Pixel);
        }
    }
    VlSiftFilt *SiftFilt=NULL;
    SiftFilt=vl_sift_new(Image->width,Image->height,noctaves,nlevels,o_min);
    int KeyPoint=0;
    int idx=0;
    if (vl_sift_process_first_octave(SiftFilt,ImageData)!=VL_ERR_EOF)
    {
        while (TRUE)
        {
            //计算每组中的关键点
            vl_sift_detect(SiftFilt);
            //遍历并绘制每个点
            KeyPoint+=SiftFilt->nkeys;
            VlSiftKeypoint *pKeyPoint=SiftFilt->keys;
            for (int i=0;inkeys;i++)
            {
                VlSiftKeypoint TemptKeyPoint=*pKeyPoint;
                pKeyPoint++;
                cvDrawCircle(Image,cvPoint(TemptKeyPoint.x,TemptKeyPoint.y),TemptKeyPoint.sigma/2,CV_RGB(255,0,0));
                idx++;
                //计算并遍历每个点的方向
                double angles[4];
                int angleCount=vl_sift_calc_keypoint_orientations(SiftFilt,angles,&TemptKeyPoint);
                for (int j=0;j





你可能感兴趣的:(VLFeat——SIFT图像特征提取(VC++实现))