1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

cvmat#match_descriptors returns Hash using image index as key instead of CvMat object for easier to be dumped/saved

This commit is contained in:
Xiao Li 2012-08-12 23:57:29 -07:00
parent 4eb0f3d2dd
commit 4db0c33191
2 changed files with 4 additions and 4 deletions

View file

@ -11,6 +11,6 @@ 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}
match_index, count = matchs.max_by {|image_index, count| count}
puts "max match: #{image_files[images.index(match)]}"
puts "max match: #{image_files[match_index]}"

View file

@ -5336,7 +5336,7 @@ rb_match_shapes(int argc, VALUE *argv, VALUE self)
* match_descriptors(<i>detector_type, descriptor_type, matcher_type, images</i>) -> Hash
*
* Matching descriptors detected on one image to descriptors detected in image set.
* Returns a Hash contains match count of each image.
* Returns a Hash contains match count of each image index.
*
* <i>detector_type</i> is a string, options: "SURF"
* <i>descriptor_type</i> is a string, options: "SURF"
@ -5377,7 +5377,7 @@ rb_match_descriptors(int argc, VALUE *argv, VALUE self)
VALUE _matches = rb_hash_new();
for (size_t i=0; i<matches.size(); i++) {
VALUE match = RARRAY_PTR(images)[matches[i].imgIdx];
VALUE match = INT2FIX(matches[i].imgIdx);
VALUE count = rb_hash_aref(_matches, match);
if (NIL_P(count)) {
count = INT2FIX(1);