关于 ‘float’ object has no attribute ‘astype’ 的错误
在写python程序的时候,经常遇到**‘float’ object has no attribute ‘astype’ **,这种情况下,通常是因为输入有问题。
比如,我是做图像处理的,用到如下代码:
import cv2
cap=cv2.VideoCapture(0)
while cap.isOpened():
_,frame=cap.read()
cv2.imshow('frame',frame)
k=cv2.waitKey(25)
if k==27:
break
到最后的时候,会出现AttributeError:‘float' object has no attribute 'astype'
这个时候是因为这句程序出现了问题:
while cap.isOpened():
图像输入有误,导致的报错,检查图像或者摄像头输入即可!