Ask Your Question
7

shape context implementation in opencv

asked 2012-08-21 04:28:27 -0600

mrgloom gravatar image

updated 2012-08-27 04:50:44 -0600

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.

edit retag flag offensive close merge delete

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 ( 2012-12-18 06:49:38 -0600 )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 ( 2012-12-19 02:10:01 -0600 )edit

Thank you so much!

nvtoicntt gravatar imagenvtoicntt ( 2012-12-19 10:16:52 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
9

answered 2012-09-27 12:11:31 -0600

Rob gravatar image

updated 2012-09-29 07:25:36 -0600

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

edit flag offensive delete link more
0

answered 2012-08-28 09:12:23 -0600

imran gravatar image

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

edit flag offensive delete link more

Comments

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

mrgloom gravatar imagemrgloom ( 2012-08-28 09:23:57 -0600 )edit

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

imran gravatar imageimran ( 2012-08-29 16:48:53 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-08-21 04:28:27 -0600

Seen: 9,977 times

Last updated: Sep 29 '12