3

I'm trying to find a way to work with a rotation invariant template matching. I can actually detect my objets, calculate the angle and rotate them so they are in the same orientation as the template (I took a capture of the template alone, in orientation 0). After that for each blob of my image, I execute the template matching function and it works quite well so far. The problem is that sometimes it doesn't find an object corresponding to my template, and sometimes it finds objects that totally do not correspond to the template. I thought modifing the threshold whould permit to filter the ones that shouldn't match but it filter the good ones too. I tried different matching methods and I find the best results with the CCOEF_NORM.

Here you have the objects I have to identify

the good matching object and the one that should not match

.

I don't really know how to perform a good matching program. I also tried searching for key points but it's not really dedicated for that type of objects.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Fosheus Badabu
  • 351
  • 1
  • 3
  • 10
  • You should do keypoint detection, description matching to find all the templates in the original image. After that warp the image and run matchTemplate – Rick M. Apr 06 '17 at 15:04
  • 2
    Did you try contours recognition using Hu Moments ? – Andrey Smorodov Apr 06 '17 at 15:21
  • @RickM. I'm new to computer vision, I already tried keypoint detecion but in python on my Raspberry Pi, I've got Segmentation fault when using the functions. Also I don't really know how to implemente all of the fonctionnalities that you listed. – Fosheus Badabu Apr 06 '17 at 17:05
  • @AndreySmorodov No, I just tried some easly implementable stuff such as template matching, keypoints, ... Should I use this to compare the shapes of my template and objects? – Fosheus Badabu Apr 06 '17 at 17:12
  • 1
    Check matchShapes method, it uses Hu moments to match contours : http://docs.opencv.org/2.4.8/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#matchshapes . Here you can find examples: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_contours/py_contours_more_functions/py_contours_more_functions.html – Andrey Smorodov Apr 06 '17 at 20:07
  • @AndreySmorodov Nice, thank you, I will give it a try. – Fosheus Badabu Apr 07 '17 at 06:12
  • @FosheusBadabu if you don't have that much experience, I think the suggestion about Hu Moments is the most apt for your problem, as you are able to extract contours. – Rick M. Apr 07 '17 at 08:19
  • So shape matching seams to work, thank you for your responses. I still have problems when it search for contours and place parts of the contours in differents elements of the contours array. I guess there is something to fuse the elements together and extract the whole shape as one item. – Fosheus Badabu Apr 07 '17 at 11:19
  • I don't get what you mean by _extract the whole shape as one item_. Isn't a direction vector enough? – Rick M. Apr 07 '17 at 14:02
  • I use the findContours function to get the shape in the image, but it returns an array of arrays with in each array a portion of the shape (maybe because it can't find continuity in the shape). I want to create a new array with the values of the arrays, to perform matchShape on the complet shape. What should I do with the direction vector? How to use it? – Fosheus Badabu Apr 07 '17 at 14:26
  • @FosheusBadabu Did you find a solution? – rpi_guru Nov 28 '19 at 01:49

0 Answers0