AttributeError: ‘NoneType‘ object has no attribute ‘copy‘解决方法

在做图片提取的时候发生了报错,查了好多说是图片读取路径有中文,看了一下发现我的路径也确实有中文,(图片为了方便就放在桌面上)。但是改了路径之后依然报错,仔细检查才发现是二点图片格式不对,保存到电脑格式是jpg.但原程序读取的是png.改了之后就可以正确运行。

# import the necessary packages
import matplotlib.pyplot as plt
import imutils
from imutils import perspective
import numpy as np
import cv2

# load the notecard code image, clone it, and initialize the 4 points
# that correspond to the 4 corners of the notecard
notecard = cv2.imread("../image/notecard.png")
clone = notecard.copy()
pts = np.array([(73, 239), (356, 117), (475, 265), (187, 443)])

# loop over the points and draw them on the cloned image
for (x, y) in pts:
    cv2.circle(clone, (x, y), 5, (0, 255, 0), -1)

# apply the four point tranform to obtain a "birds eye view" of
# the notecard
warped = perspective.four_point_transform(notecard, pts)

# show the original and warped images
cv2.imshow("Original", clone)
cv2.imshow("Warped", warped)
plt.figure("Original opencv2matplotlib")
plt.imshow(imutils.opencv2matplotlib(clone))
plt.show()
cv2.waitKey(0)

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值