2

I need to calculate the Earth Mover's Distance (EMD) in my program. I am trying to follow this answer, but for some reason the cv2 module which I have on my system does not have the function CalcEMD2. Could someone explain why it is missing?

I am using Anaconda for Python 3.4 and installed OpenCV with

conda install -c https://conda.anaconda.org/menpo opencv3 

The package installed without problems and imports nicely.

>>> import cv2
>>> print(cv2.__version__)
3.1.0

However, CalcEMD2 does not exist. The namespace of cv2 has only two members containing the string 'emd' (case-insensitive), neither of which is the function I'm looking for:

>>> [k for k in cv2.__dict__ if 'emd' in k.lower()]
['createEMDHistogramCostExtractor', 'createEMDL1HistogramCostExtractor']
Community
  • 1
  • 1
juhka
  • 23
  • 6
  • The new name is `EMD`, so it should be like: `cv2.EMD(...)` – Miki Mar 11 '16 at 18:10
  • In my case there is neither `cv2.EMD`. I edited the question to show that the module contains only two functions containing the string 'EMD' in their name, but neither of them is the one that I'm looking for. – juhka Mar 14 '16 at 07:38

1 Answers1

0

You will find it under cv2.cv.CalcEMD2() for most OpenCV 2.7.x libraries I've seen.

The compareHist() also has parameters hiding under cv2.cv.CV_COMP_* as well.

Hope this helps.

Michael McGarrah
  • 585
  • 4
  • 10
  • Yes, `CalcEMD2` is there in the OpenCV 2.4.x libs for Python 2.7, but it seems to be missing from OpenCV 3.1.x libs for Python 3.x. – juhka Apr 23 '17 at 18:56
  • Cool, I see you mentioned Python 3.4. I was looking for the same function in Python 2.7 and the cv2.cv.* was a problem leading to this question. Hope, the solution comes up for Python 3. – Michael McGarrah Apr 25 '17 at 18:40