SIFT opencv2.3.1/2.4.3 both Giving very strange descriptors..like 7., 29., 39., 11., 2.3.1 Giving very strange descriptors

StackOverflow https://stackoverflow.com/questions/14907711

  •  10-03-2022
  •  | 
  •  

Pregunta

This is very simple code for SIFT,I am getting is very strange descriptors.Are they correct?

descriptor: [ 0., 7., 29., 39., 11., 0., 0., 0., 32., 30., 39., 52., 16., 0., 1., 12., 38., 14., 10., 20., 28., 93., 45., 37., 93., 3., 6., 11., 23., 107., 24., 80., 0., 2., 47., 53., 0., 1., 9., 8., 104., 85., 35., 41., 1., 10., 32., 19., 130., 73., 0., 0., 8., 76., 31., 42., 61., 40., 10., 5., 83., 130., 28., 31., 3., 0., 0., 0., 0., 2., 12., 17., 60., 4., 0., 0., 0., 31., 76., 83., 130., 38., 10., 6., 15., 10., 16., 89., 19., 21., 16., 23., 130., 94., 7., 3., 1. ]

#include "stdafx.h"
#include <iostream>
#include <cv.h>
#include <highgui.h>
#include <C:\opencv243\include\opencv2\nonfree\features2d.hpp>
using namespace cv;
using namespace std; 
int main(int argc, const char* argv[])
{
string path="matrices.xml";
   FileStorage fs(path, FileStorage::WRITE);
   cv::siftFeatureDetector detector;
   cv::SiftDescriptorExtractor extractor; 
   cv::Mat descriptors_1;
   std::vector<cv::KeyPoint> keypoints;
   const cv::Mat input=cv::imread("image path",0);
   detector.detect(input, keypoints);
   extractor.compute( input, keypoints, descriptors_1 );
   fs <<"descriptor"<<descriptors_1;
   fs.release();
   return 0;
}
¿Fue útil?

Solución

For some reason unknown to me, the SIFT descriptor implemented in OpenCV converts the final values to uchar (0 - 255) and has always done so since I remember. It is a waste of space, since the resulting values are stored in a float descriptor, and it also hinders matching.

What I do is compile my own version of SIFT where I just leave out the conversion to bytes (in the link), and I get nice floating point values.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top