mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
port matching_to_many_images.cpp as cvmat#match_descriptors, and an example to use it
This commit is contained in:
parent
1a813b6690
commit
4eb0f3d2dd
8 changed files with 88 additions and 3 deletions
16
examples/matching_to_many_images.rb
Normal file
16
examples/matching_to_many_images.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
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}
|
||||
|
||||
|
||||
matchs = query.match_descriptors("SURF", "SURF", "FlannBased", images)
|
||||
|
||||
match, count = matchs.max_by {|image, count| count}
|
||||
|
||||
puts "max match: #{image_files[images.index(match)]}"
|
BIN
examples/matching_to_many_images/query.png
Executable file
BIN
examples/matching_to_many_images/query.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 119 KiB |
BIN
examples/matching_to_many_images/train/1.png
Executable file
BIN
examples/matching_to_many_images/train/1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
BIN
examples/matching_to_many_images/train/2.png
Executable file
BIN
examples/matching_to_many_images/train/2.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 112 KiB |
BIN
examples/matching_to_many_images/train/3.png
Executable file
BIN
examples/matching_to_many_images/train/3.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 118 KiB |
3
examples/matching_to_many_images/train/trainImages.txt
Executable file
3
examples/matching_to_many_images/train/trainImages.txt
Executable file
|
@ -0,0 +1,3 @@
|
|||
1.png
|
||||
2.png
|
||||
3.png
|
Loading…
Add table
Add a link
Reference in a new issue