title: Comparing SIFT features stored in a mysql database
body: <p>I'm currently extending an image library used to categorize images and i want to find duplicate images, transformed images, and images that contain or are contained in other images.<br>
  I have tested the SIFT implementation from OpenCV and it works very well but would be rather slow for multiple images. Too speed it up I thought I could extract the features and save them in a database as a lot of other image related meta data is already being held there.  </p>
  
  <p><strong>What would be the fastest way to compare the features of a new images to the features in the database?</strong><br>
  Usually comparison is done calculating the euclidean distance using kd-trees, FLANN, or with the <a href="http://userweb.cs.utexas.edu/~grauman/research/projects/pmk/pmk_projectpage.htm" rel="noreferrer">Pyramid Match Kernel</a> that I found in another thread here on SO, but haven't looked much into yet.</p>
  
  <p>Since I don't know of a way to save and search a kd-tree in a database efficiently, I'm currently only seeing three options:<br>
  * Let MySQL calculate the euclidean distance to every feature in the database, although I'm sure that that will take an unreasonable time for more than a few images.<br>
  * Load the entire dataset into memory at the beginning and build the kd-tree(s). This would probably be fast, but very memory intensive. Plus all the data would need to be transferred from the database.<br>
  * Saving the generated trees into the database and loading all of them, would be the fastest method but also generate high amounts of traffic as with new images the kd-trees would have to be rebuilt and send to the server.</p>
  
  <p>I'm using the SIFT implementation of OpenCV, but I'm not dead set on it. If there is a feature extractor more suitable for this task (and roughly equally robust) I'm glad if someone could suggest one.</p>