对象识别的前置步骤是什么(在执行SIFT / SURF之前)

时间:2014-12-23 08:59:50

标签: c++ opencv image-processing

我是一名IT工程师。 我的目的是研究与AR相关的Landmark指南系统。 该项目的一部分当然是对象识别。 目前我的任务是从(网络摄像头)识别对象 这就是为什么我尝试在openCV上使用图像直方图从数据集中选择相对图像到帧。然后我可以在几张图像中执行SURF。 但结果很可怕。在比较直方图之后,几乎所有图像都给出了相同的结果。

我有 10200 ukbenchmark图像数据集

从给定的帧我应该识别10200个图像中的对象。但要用这个量执行SURF是不可能的。我需要以某种方式选择相对(可能匹配)图像。 如何选择图像以便我不必对每张图像执行SURF? 有没有办法利用图像直方图来解决这个问题? 我非常感谢你的帮助!

这是我的数据集 ukbenchmark dataset

这是直方图比较结果histogram comparision

这是我的基于opencv的代码

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

int main( int argc, char** argv )
{
  Mat src;

  /// Establish the number of bins
  int histSize = 256;

  /// Set the ranges ( for B,G,R) )
  float range[] = { 0, 256 } ;
  const float* histRange = { range };

  bool uniform = true; bool accumulate = false;

  Mat gray_hist;
    // Draw the histograms for B, G and R
  int hist_w = 512; int hist_h = 400;
  int bin_w = cvRound( (double) hist_w/histSize );

  char * filename=new char[100];

  //cycle starts here
  int begin=getTickCount();
  Mat inputImage=imread("frame3.jpg",1);//this is given input image
  cvtColor(inputImage,inputImage,COLOR_RGB2GRAY);
    Mat inputImageHist;
    equalizeHist(inputImage,inputImage);
     calcHist( &inputImage, 1, 0, Mat(), inputImageHist, 1, &histSize, &histRange, uniform, accumulate );
        normalize( inputImageHist, inputImageHist, 0, 1, NORM_MINMAX, -1, Mat() );

  for(int i=0;i<n;i++){
    /// Load image
    sprintf(filename,"D:\\labworks\\ukbenchmark\\full\\ukbench%05d.jpg",i);
    src = imread( filename, 1 );
    Mat srcGray;
    cvtColor(src,srcGray,COLOR_RGB2GRAY);

    //this commented lines are to show what i store in files
    ///// Apply Histogram Equalization
    //equalizeHist( srcGray, srcGray);
    //calcHist( &srcGray, 1, 0, Mat(), gray_hist, 1, &histSize, &histRange, uniform, accumulate );
    //normalize( gray_hist, gray_hist, 0, 1, NORM_MINMAX, -1, Mat() );

    /// Compute the histograms:
    sprintf(filename,"histogramEqualized\\ukbench%05d.yml",i);
    FileStorage fs(filename,FileStorage::READ);
    fs["myHistogram"]>>gray_hist;
    fs.release();

    int histDif=compareHist(gray_hist,inputImageHist,1);
    cout<<filename<<"\t:\t"<<histDif<<endl;

  }
  //cycle ends here

    system("pause");

  return 0;
}

0 个答案:

没有答案
相关问题