Ask Your Question
7

shape context implementation in opencv

asked Aug 21 '12

mrgloom gravatar image

updated Aug 27 '12

I want to use shape context for contour matching and for contour clusterization/classification, I have already implimented it in opencv, but I don't understand how to use it in case if contours have different number of points? maybe I can add some fictitious points between real point or simplify contour to delete some points?

In paper they just add some "dummy" points, but it's only suitable for shape comparision, but if I want to use vector of features for example in SVM,feature vector need to be the constant size.

Preview: (hide)

Comments

Hi mrgloom, Could you give me your source code? I am learning Shape Context and I want to implement it in C++ and OpenCV. Your question is also my question. I have an idea to resolve this problem so I really need your source code to implement my idea in order to test it quickly. I hope we can discuss more often in the future. Thanks!

nvtoicntt gravatar imagenvtoicntt (Dec 18 '12)edit

I haven't finished my code and it doesn't work at all, so I think it needs a lot of rewrite(also to new opencv interface), but I found faster algorithm than hungarian algorithm. here my old dirty code http://codepaste.ru/12864/

mrgloom gravatar imagemrgloom (Dec 19 '12)edit

Thank you so much!

nvtoicntt gravatar imagenvtoicntt (Dec 19 '12)edit

2 answers

Sort by » oldest newest most voted
9

answered Sep 27 '12

Rob gravatar image

updated Sep 29 '12

Hey there,

unfortunately, OpenCV has no shape context (SC) implementation accepted, yet. You can find here a C++ implementation that was implemented analogeously to Belongie et al. (2000, 2001, 2002) (I'm not sure if the second link is really their's): http://www.umiacs.umd.edu/~zhengyf/PointMatching.htm

The original (?) MATLAB-implementation can be found here: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html

C#-implementation: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=7465&lngWId=10

And see what happens in the following link. Someone made there a mistake to mix up shape matching and shape context, so read carefully the documentation if you read about shape matching in OpenCV that uses Hu moments and shape matching using shape context. There's nothing for SC in OpenCV like the descriptor (shape context/the histogram [log(r),theta]), assignment problem solver (like hungarian [by munkres in O(n^3)], ...) etc.] or deforming algorithms to model transformations (TPS - Thin Plate Spline, ...) etc. as far as I know). Here the link: http://stackoverflow.com/questions/3146546/objective-c-implementation-of-shape-context-algorithm-image-matching

Here the Hu-moments-based shape matching.. Maybe it already satisfies your needs as SC is tricky to implement by yourself. Here the link to matching (...): http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html

Preview: (hide)
0

answered Aug 28 '12

imran gravatar image

Try looking at active contours. OpenCV has it in their Legacy folder under the name cvSnake.

Preview: (hide)

Comments

Can you point some examples what can I do with this technique?

mrgloom gravatar imagemrgloom (Aug 28 '12)edit

The ebook on http://www.computervisionmodels.com/ has some examples.

imran gravatar imageimran (Aug 29 '12)edit

Question Tools

1 follower

Stats

Asked: Aug 21 '12

Seen: 12,509 times

Last updated: Sep 29 '12