Fix for OpenCV python binding – cv.MatchShapes returning NoneType rather than double

Posted on January 4, 2011


The fix can be easily made if you build from source (building for debian).

The key line that needs to be altered is at line 1131 of trunk/opencv/modules/python/api [svn browse ink]:

QueryHistValue_3D double
  CvHistogram hist
  int idx0
  int idx1
  int idx2
QueryHistValue_nD double
  CvHistogram hist
  ints idx

# Matching
  CvArr image
  CvArr templ
  CvArr result
  int method
MatchShapes                <------------------ this line
  CvSeq object1
  CvSeq object2
  int method
  double parameter 0

# Contour Processing Functions
ApproxChains CvSeq*
  CvSeq src_seq
  CvMemStorage storage
  double parameter 0

Change the line to the following to make the python binding generator know that the method will return a double:

MatchShapes double

Then do the usual make && sudo make install. If running on debian-based systems, remember to copy across the python lib afterwards!

sudo mv /usr/local/lib/python2.6/site-packages/ /usr/local/lib/python2.6/dist-packages/

Tagged: , ,