我最近开始使用openCV和python,并决定分析一些示例代码,以了解事情是如何完成的.
但是,我找到的示例代码不断抛出此错误:
Traceback (most recent call last):
File "test.py", line 9, in <module>
img = cv2.imread(sys.argv[1],cv2.CV_LOAD_IMAGE_COLOR) ## Read image file
AttributeError: 'module' object has no attribute 'CV_LOAD_IMAGE_COLOR'
我使用的代码可以在下面找到:
import cv2
import sys
import numpy as np
if len(sys.argv) != 2: ## Check for error in usage syntax
    print "Usage : python display_image.py <image_file>"
else:
    img = cv2.imread(sys.argv[1], cv2.CV_LOAD_IMAGE_COLOR) ## Read image file
if img == None: ## Check for invalid input
    print "Could not open or find the image"
else: …