Vocabulary Tree Algorithm

asked 2017-03-01 10:29:10 -0600

updated 2017-03-01 11:09:43 -0600

Hi everyone,

I am trying to implement Vocabulary Tree Algorithm by Nister and Stewenius. Part of their work says

For each image in the database, extract MSER regions and calculate a set of feature point descriptors (e.g. 128 SIFT).

and

For feature extraction, we use our own implementation of Maximally Stable Extremal Regions (MSERs) [10]. They have been found to perform well in thorough performance evaluation [13, 4]. We warp an elliptical patch around each MSER region into a circular patch. The remaining portion of our feature extraction is then implemented according to the SIFT feature extraction pipeline by Lowe

What I am not sure about is, how to do this in OpenCV 3.x and Python 3.x, and also am not sure if I understood it correctly.

Question #1 Also - English is not my first language but I understood it this way: They get MSER Regions (small parts of image) and in THAT small regions they detect keypoints with SIFT?

Question #2 Am I supposed to put MSER keypoints to SIFT? And if so, how do I do it in Python OpenCV? I saw something similar but it was in C++

So far I have this code: EDIT - I Think I managed to put MSER keypoints to SIFT so SIFT gave me descriptors- can someone confirm that this code is correct? It does not show any errors but I am unsure anyway

import cv2
import numpy as np

img = cv2.imread('test_image.jpg', cv2.IMREAD_COLOR);

# channels for color image
height, width, channels = img.shape

# blank image, will contain image and detected keypoints, just to show it works
#blank_image = np.zeros((height,width,3), np.uint8)



mser = cv2.MSER_create()
# detecting keypoints
mser_areas = mser.detect(img)

#creating sift to compute descriptors
sift = cv2.xfeatures2d.SIFT_create()
# descriptors created from MSER keypoints (Is this correct?)
descs = sift.compute(img, mser_areas)

print(descs)
edit retag flag offensive close merge delete

Comments

1

I understand the following:

  • detect MSER features
  • compute SIFT descriptors for these keypoints

There are Python tutorials here.

You should directly read the image in grayscale mode as SIFT (and MSER probably too) needs a grayscale image. To check if it is correct or not, the size of the descriptors should be number_of_features x 128 or the inverse maybe.

Eduardo gravatar imageEduardo ( 2017-03-01 12:53:06 -0600 )edit