Ask Your Question

Revision history [back]

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