我从这段代码中得到一个过载解决失败的错误。有什么想法吗?
cv2.error: OpenCV(4.7.0) :-1: error: (-5:Bad argument) in function 'calcHist'
\> 过载解析失败:
\> - hist 不是 numpy 数组,也不是标量
\> - 参数 'hist' 的预期 Ptr
for file_name in os.listdir(images_directory): # Load the image image = cv2.imread(os.path.join(images_directory, file_name))
# Resize the target image to match the size of the image
target_img_resized = cv2.resize(target_img, (image.shape[1], image.shape[0]))
# Convert the images to the LAB color space
target_lab = cv2.cvtColor(target_img_resized, cv2.COLOR_RGB2LAB)
image_lab = cv2.cvtColor(image, cv2.COLOR_RGB2LAB)
print(target_lab.shape, target_lab.dtype)
print(image_lab.shape, image_lab.dtype)
# Calculate the difference between the LAB values of the images
delta_e = cv2.compareHist(cv2.calcHist(target_lab, [0, 1], None, [256, 256], [0, 256], [0, 256]),
cv2.calcHist(image_lab, [0, 1], None, [256, 256], [0, 256], [0, 256]),
cv2.HISTCMP_CHISQR_ALT)
我试过将内容更改为 np.array 或 uMAT,但没有成功