use*_*265 4 python opencv raspberry-pi2
你好我正在使用OpenCV的Raspberry Pi.我想在链接中尝试一个关于球跟踪的教程 http://www.pyimagesearch.com/2015/09/14/ball-tracking-with-opencv/
但是当我编译它时,我得到一个错误:'NoneType'对象没有属性'shape'.
我该怎么办?
希望这可以帮助任何面临同样问题的人
要确切地知道发生在哪里,因为正在运行的程序没有将其作为行号错误提及
'NoneType' object has no attribute 'shape'
确保assert加载后添加image/frame
对于图像
image = cv2.imread('myimage.png')
assert not isinstance(image,type(None)), 'image not found'
Run Code Online (Sandbox Code Playgroud)
对于视频
cap = cv2.VideoCapture(0)
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret:
assert not isinstance(frame,type(None)), 'frame not found'
Run Code Online (Sandbox Code Playgroud)
帮助我解决了类似的问题,在一个很长的脚本中
我今天也遇到了同样的问题,请检查cybseccrypt提到的图像路径。读取后,尝试打印图像并查看。如果获得值,则表示文件已打开。
码:
img_src = cv2.imread('/home/deepak/python-workout/box2.jpg',0)
print img_src
希望这可以帮助!