I'm working on an algorithm that should recognize an object from an image in a video file. For now, I want to use ORB(I know that SURF and SIFT are better at this kind of job, but I want to make this affirmation based on my results). Now I have one problem: when I run my program, in one of the images the keypoints are detected in a different area than in the other image and it hardly finds any matches. Now, in OpenCV 2.4 there was GridAdaptedFeatureDetector, a class that allows you to partition the source image into a grid and detect points in each cell. But I'm using OpenCV 3.1(Visual Studio 2015) and it seems to have disappeared? Please help me find a solution.
3 Answers
They removed a lot of different adapters feature detector/extractor in OpenCV 3.1.
One of the way to get them back, is to copy them to you project from OpenCV 2.4. It worked for me with OpponentSiftDescriptor. You will need to fix interfaces, because they moved from DescriptorExtractor and FeatureDetector interfaces to Features2D. You can copy its code from here : https://github.com/kipr/opencv/blob/master/modules/features2d/src/detectors.cpp

- 1,483
- 9
- 18
It's in python, so it might be useful (I found this question when looking for a python solution so hopefully someone else does too...) but this is what I used to iterate over sub-blocks of the image:
def blocks(img, rows, cols):
h, w = img.shape[:2]
xs = np.uint32(np.rint(np.linspace(0, w, num=cols+1)))
ys = np.uint32(np.rint(np.linspace(0, h, num=rows+1)))
ystarts, yends = ys[:-1], ys[1:]
xstarts, xends = xs[:-1], xs[1:]
for y1, y2 in zip(ystarts, yends):
for x1, x2 in zip(xstarts, xends):
yield img[y1:y2, x1:x2]

- 837
- 10
- 13
There is a recent paper that tackles the problem of homogeneous keypoint distribution on the image. C++, Python, and Matlab interfaces are provided in this repository.

- 197
- 2
- 15
-
Its GPL in case that matters to anyone seeing this answer. – chutsu Apr 24 '18 at 02:36
-
2@chutsu Indeed, at the moment of releasing the code I didn't realize that GPL license had many restrictions. Thus, I have recently changed it to MIT one. Overall, feel free to use it without any restrictions, since the overall purpose of releasing the paper and the code is to make the algorithm to be used easily by developers and researchers without worrying about any restrictions. – Alex Bailo May 10 '18 at 13:58