2

I have to compare two images using cv2.compareHist() function. But I got error on the comparison method i.e. CV_COMP_CORREL. I use OpenCV 3.1.0. Error is NameError: name 'CV_COMP_CORREL' is not defined.

I tried with cv.CV_COMP_CORREL and cv2.cv.CV_COMP_CORREL, but I got the same type error.

Here is my code:

import cv2
import numpy as np
from matplotlib import pyplot as plt
image = cv2.imread("29.jpg",0)
image1 = cv2.imread("29.jpg",0)
hist1 = cv2.calcHist([image],[0],None,[256],[0,256])
hist2 = cv2.calcHist([image1],[0],None,[256],[0,256])
compare = cv2.compareHist(hist1,hist2,CV_COMP_CORREL)
aland
  • 4,829
  • 2
  • 24
  • 42
dip deb
  • 69
  • 3
  • 14

1 Answers1

6

If you're still struggling with this; I found the answer, searching through the cv2.__dict__ dictionary:

for option in cv2.__dict__:
    if 'CORREL' in option:
        print option

I find cv2.HISTCMP_CORREL.

Aidenhjj
  • 1,249
  • 1
  • 14
  • 27