OpenCV NoneType object has no attribute shape

user3748265 picture user3748265 · Oct 3, 2016 · Viewed 145.8k times · Source

Hello I'm working on Raspberry Pi with OpenCV. I want to try a tutorial which is ball tracking in link http://www.pyimagesearch.com/2015/09/14/ball-tracking-with-opencv/

But when I compile it, i get an error: 'NoneType' object has no attribute 'shape'.

What should I do?

Answer

asc11 picture asc11 · Oct 3, 2016

It means that somewhere a function which should return a image just returned None and therefore has no shape attribute. Try "print img" to check if your image is None or an actual numpy object.