Opencv图像形状元组拆包

时间:2018-02-03 21:08:55

标签: python-3.x opencv image-processing

# Importing the libraries
import numpy as np
import cv2


# Load two images
img1 = cv2.imread(r'C:\Users\user1\Pictures\messi.jpg')
img2 = cv2.imread(r'C:\Users\user1\Pictures\opencvimp.jpg')
# I want to put logo on top-left corner, So I create a ROI
rows,cols,channels = img2.shape

以上代码给出了以下错误。

rows,cols,channels = img2.shape
AttributeError: 'NoneType' object has no attribute 'shape

img2.shape我做错了什么?

1 个答案:

答案 0 :(得分:1)

img2None。看起来该文件不是有效图像