简体   繁体   中英

How to Compare an Image with Database in C++ opencv

This might have been asked several times before. But I feel mine is a bit different and since I lack complete understanding of concepts, I am posting it again.

I am working on opencv code written in C++ on Ubuntu that can match vein patterns. I have captured 4 vein images. In my program, I would like to capture a new image from the IR camera and compare it with the images in the images directory. I am planning to use fuzzy C clustering algorithm for my matching. I have created a user menu in which one option is comparing my algorithm with FLANN, SIFT, etc. This comparison is based on the time taken. How do you calculate the time taken for computation?

I am completely new to Fuzzy clustering and any tutorials/Sample codes that might help is greatly appreciated.

Also, can you please suggest how to go about comparing a file captured from camera to a file in directory in linux?

Edit 1: Have uploaded two sample vein patterns with their Canny Edge Detectors.

Vein Pattern 1

Vein Pattern 2

www.i.imgur.com/mvt3kIy.jpg (Canny Edge 1)

www.i.imgur.com/8GwaLTu.jpg (Canny Edge 2)

Please suggest some methods to compare the same.

To calculate the time elapsed between a set of instructions,

#include <time>

int main()
{

    // whatever code

    clock_t tstart = clock();

    /// more code and implementations

    cout << "Processing time = " << (double)(clock() - tstart)/(CLOCKS_PER_SEC) << " second(s)" << endl;

}

There are many ways in which you can compare 2 files; if you post some images, I might be able to guide you further. You might try and read some of OpenCV documentation and related papers. This link will give you a head start to feature description..

I use this function for timings:

#include <sys/time.h>
#include <iostream>

inline long getMilliSecs()
{
  timeval t;
  gettimeofday(&t, NULL);
  return t.tv_sec*1000 + t.tv_usec/1000;
}

int main()
{
  long start_time = getMilliSecs();
///
//do stuff;
///
  long end_time = getMilliSecs();
std::cout << ((double)(end_time - start_time))/1000 << " seconds" << std::endl; 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM