TypeError:' NoneType'对象没有属性' __ getitem __' opencv python

时间:2017-03-24 15:50:22

标签: image python-2.7 opencv

我尝试使用opencv按照以下代码裁剪图像:

import cv2
import numpy as np
import csv
path_image= '/home/'
img=cv2.imread(path_image+"image1.png")
img1=img[40:102,2442:2448]

但是我执行了一个错误:

 img1=img[40:102,2442:2448]

  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object has no attribute '__getitem__'

1 个答案:

答案 0 :(得分:0)

img=cv2.imread(os.path.join(path_image,'image1.png'))