2012-08-13 02:18:31 -04:00
|
|
|
require 'opencv'
|
|
|
|
require 'benchmark'
|
|
|
|
include OpenCV
|
|
|
|
|
|
|
|
data = File.join(File.dirname(__FILE__), 'matching_to_many_images')
|
|
|
|
|
|
|
|
query = IplImage.load File.join(data, 'query.png'), CV_LOAD_IMAGE_GRAYSCALE
|
|
|
|
image_files = ['1.png', '2.png', '3.png'].map{|f| File.join(data, 'train', f)}
|
|
|
|
images = image_files.map{|f| IplImage.load f, CV_LOAD_IMAGE_GRAYSCALE}
|
|
|
|
|
|
|
|
|
2012-08-14 17:45:34 -04:00
|
|
|
matchs = query.match_descriptors(images)
|
2012-08-13 02:18:31 -04:00
|
|
|
|
2012-08-13 02:57:29 -04:00
|
|
|
match_index, count = matchs.max_by {|image_index, count| count}
|
2012-08-13 02:18:31 -04:00
|
|
|
|
2012-08-13 02:57:29 -04:00
|
|
|
puts "max match: #{image_files[match_index]}"
|