首页 > 解决方案 > 运行 OpenCV 和 imutils 的属性错误

问题描述

我尝试在 jupyter Notebook 上使用 OpenCV 运行以下代码来做一些人脸识别应用程序

# load the input image and show its dimensions, keeping in mind that
# images are represented as a multi-dimensional NumPy array with
# shape no. rows (height) x no. columns (width) x no. channels (depth)
image = cv2.imread("jp.png")
(h, w, d) = image.shape
print("width={}, height={}, depth={}".format(w, h, d))
# display the image to our screen -- we will need to click the window
# open by OpenCV and press a key on our keyboard to continue execution
cv2.imshow("Image", image)
cv2.waitKey(0)

但出现以下属性错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-14-eaae43cadc51> in <module>
      3 # shape no. rows (height) x no. columns (width) x no. channels (depth)
      4 image = cv2.imread("jp.png")
----> 5 (h, w, d) = image.shape
      6 print("width={}, height={}, depth={}".format(w, h, d))
      7 # display the image to our screen -- we will need to click the window

AttributeError: 'NoneType' object has no attribute 'shape'

这里可能是什么问题?

标签: python-3.xjupyter-notebookcomputer-vision

解决方案


推荐阅读