码迷,mamicode.com
首页 > 其他好文 > 详细

opencv嫁接vlfeat densesift

时间:2016-02-17 22:16:21      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

#include <opencv2/opencv.hpp>
#include <iostream>

extern "C" {
  #include <vl/generic.h>
  #include <time.h>
  #include <stdlib.h>
#include "vl/dsift.h"
#include "vl/pgm.h"
#include "vl/mathop.h"
#include "vl/imopv.h"
}

using namespace cv;
using namespace std;

int main (int argc, const char * argv[]) {
srand(time(NULL));

Mat img;
img = imread("/home/yuhao/codes/vlfeat-0.9.20/data/roofs1.jpg", CV_LOAD_IMAGE_COLOR);   // Read the file

namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", img );                   // Show our image inside it.
waitKey(0);

VlDsiftFilter * vlf = vl_dsift_new_basic(320, 240, 1, 3);

// transform image in cv::Mat to float vector
std::vector<float> imgvec;

for (int i = 0; i < img.rows; ++i){
  for (int j = 0; j < img.cols; ++j){
    imgvec.push_back(img.at<unsigned char>(i,j) / 255.0f);                                                                                                                                                                                                        
  }
}
// call processing function of vl
vl_dsift_process(vlf, &imgvec[0]);

// echo number of keypoints found
std::cout << vl_dsift_get_keypoint_num(vlf) << std::endl;

  return 0;
}

 编译方法

g++ sift.cpp  `pkg-config --cflags --libs opencv` -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect -lopencv_imgcodecs -I /home/yuhao/codes/vlfeat-0.9.20 -L /home/yuhao/codes/vlfeat-0.9.20/bin/glnxa64 -lvl

opencv嫁接vlfeat densesift

标签:

原文地址:http://www.cnblogs.com/Pallashadow/p/5196504.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!