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)