1

A WebCam captures an image, this image is compared with available the images in a SQL database and a nearest match is displayed in the GUI. The size of each image in database is around 60kb and are stored in varbinary format.

Right now, I am getting all images in a Datatable, iterating through each datarow, getting image from datarow columnd and comparing it with my image.

Is there a more efficient way to compare images with images from database? Does adding an index to the table increase the performance?

lerner1225
  • 862
  • 7
  • 25
  • What are you using to compare the faces? Usually, with facial matching biometric sdks, you generate a template from the original image and, under the hood, it uses this template to do the comparison. So if you want to talk about 'efficiency' I'd say that that's a big consideration. There's a *lot* in an image that you wouldn't need for facial matching. –  Jul 26 '17 at 11:50
  • 1
    @AlexK. "nearest match" is not the same as "equal". OP could be taking into account panning of the image, color correction, etc. Which is implied by referring to it as a "nearest match". – Flater Jul 26 '17 at 11:51
  • @JᴀʏMᴇᴇ: I am using a third party library, the method takes two images (as byte arrays) as input and gives the score. But, for that i need to iterate through each image in DB. – lerner1225 Jul 26 '17 at 12:00
  • Yep, I missed that from the question. – Alex K. Jul 26 '17 at 12:00
  • Oh ok, unusual that it doesn't provide a way of generating templates in prior to the identification. Are you able to share with us what the third-party library is? Your biggest bottleneck here is going to be retrieving from the table. Index will definitely help, depending on what column your searching by. Also, I'd generate a ton of tests to determine whether it's more efficient to store the path in the image and retrieve the image from this path (on disk)? Nice question though. –  Jul 26 '17 at 12:04
  • 1
    If there's any efficiencies to be gained here, it probably depends a lot on that third party library and any features it has beyond "compare two byte arrays" - i.e. if it has some means of extracting a "signature" (set of characteristics that are interesting about a single image) and whether such signatures would be more directly comparable. At most, as is, you may be able to install it and use it within SQL Server (from a CLR procedure) to cut down on some data transfer. – Damien_The_Unbeliever Jul 26 '17 at 12:04
  • Well this also depends on the machine you are running it on a terabyte of RAM is not as uncommon as it use to be, or running a server cluster to do what you need to boost the performance. So keeping everything in memory might be a viable option. How big of a database do you expect to work with? Is SQL really the only option I am sure there are more free solutions for [elasticsearch](https://stackoverflow.com/questions/32785803/similar-image-search-by-phash-distance-in-elasticsearch). – Filip Cordas Jul 26 '17 at 12:19

0 Answers0