Ask Your Question
1

ShapeContext OpenCV 3.0

asked 2014-10-27 16:52:58 -0600

crisie gravatar image

I was planning to use the new Shape module in order to compute the whole Shape Context pipeline. However, I only find implemented the computeDistance function, that computes the distance between two shapes, but I don't see neither a function implemented that computes and outputs the shape context descriptors, nor a function that computes the cost matrix and the other steps of the pipeline. Could anyone please tell me if such functions are going to be implemented and added to the release version of OpenCV 3.0?

Thanks in advance!

edit retag flag offensive close merge delete

Comments

Basically if you want that functionality, you will need to create a PR with a suggested adaptation to the module in the contrib repo. The shape module is a contributed open source module that needs some maturing before it will move to the actual opencv repo. Are you up for implementing it yourself?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-11-26 07:43:41 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-10-30 05:08:38 -0600

juanmanpr gravatar image

You are right. The descriptors used are not exhibited in the shape module, and that may be a valuable improvement to the shape module. However, other steps are available for user modification: Ptr<HistogramCostExtractor> and Ptr<ShapeTransformer> &_transformer can be used to use a modified cost matrix or a different shape transformation.

Hope this helps

edit flag offensive delete link more
0

answered 2014-11-25 16:40:51 -0600

I had the same problem as you. These things are implemented within opencv 3 but are not available accessible in the API unfortunately. If you go into the shape module source code at:

~opencv\sources\modules\shape\src\

there is the code for the classes SCD (build shape context descriptor for a set of points) and SCDMatcher (calculate histogram matching costs between descriptors) in the files scd_dis.cpp and scd_def.h. I've copied these into new files (modified slightly) and used them in my project.

The format of the point sets is quite weird and I can't figure out why it is advantageous. If you start with a -> std::vector<cv::point> pts; structure, then you need to unwrap into an InputArray structure -> cv::InputArray pts2 = pts; then turn that into a mat -> cv::Mat final_pts = pts2.getMat(); then you can extract the descriptor like -> SCD A(num_polar, num_rad); cv::Mat SCD; A.extractSCD(final_pts, SCD); and SCD is your extracted descriptor which you can pass to SCDMatcher.

Hope this helps!

PS if anyone knows why the rationale for this point set structure let me know

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-27 16:52:58 -0600

Seen: 996 times

Last updated: Nov 25 '14