Python OpenCV 3:如何使用cv2.CV_COMP_HELLINGER

Python OpenCV 3: how to use cv2.CV_COMP_HELLINGER

我正在尝试使用 compareHist() 函数比较两个直方图,但我无法插入正确的比较方法。在文档中,选项是

CV_COMP_CORREL Correlation
CV_COMP_CHISQR Chi-Square
CV_COMP_CHISQR_ALT Alternative Chi-Square
CV_COMP_INTERSECT Intersection
CV_COMP_BHATTACHARYYA Bhattacharyya distance
CV_COMP_HELLINGER Synonym for CV_COMP_BHATTACHARYYA
CV_COMP_KL_DIV Kullback-Leibler divergence

每个都可以用 cv2.cv 调用。 我正在使用 openCv 3.2.0,但出现错误

    d = cv2.compareHist(query_hist, input_hist, cv2.CV_COMP_HELLINGER)
 AttributeError: 'module' object has no attribute 'CV_COMP_HELLINGER'

cv2.cv.CV_COMP_HELLINGER 和 cv2.CV_COMP_HELLINGER 我都试过了,但错误是一样的

使用cv2.HISTCMP_HELLINGER.


名称在 OpenCV 3 中已更改。您可以找到新名称 in the documentation:

HISTCMP_CORREL
HISTCMP_CHISQR
HISTCMP_INTERSECT
HISTCMP_BHATTACHARYYA
HISTCMP_HELLINGER       
HISTCMP_CHISQR_ALT
HISTCMP_KL_DIV