Python 3.x Opencv图像形状元组解包

Python 3.x Opencv图像形状元组解包,python-3.x,opencv,image-processing,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

上面的代码给出了以下错误

# 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

img2.shape有什么问题?

img2没有。文件似乎不是有效的图像

谢谢。实际上,我正在尝试实现这个url的“按位操作”部分给出的代码。。。所以我从网上下载了两张图片,从Spyder开始。我将图像格式从JPG更改为PNG。我用MS Paint打开了图像,并以“png”格式保存了图像。然后尝试了以下代码。但仍然存在相同的错误img2=cv2.imreadr'C:\Users\user1\Pictures\opencvimp.png'错误:AttributeError:'NoneType'对象没有属性'shapeHello@Marat'。你确实是对的。我给错图片的名字了。
rows,cols,channels = img2.shape
AttributeError: 'NoneType' object has no attribute 'shape