Here, cv2 utilizes NumPy for manipulating the imager, so the legitimate and most ideal approach to get the size of a picture is utilizing numpy.shape. Expecting you are working with BGR pictures, here is an example:
>>> import numpy as np
>>> import cv2
>>> img = cv2.imread('foo.jpg')
>>> height, width, channels = img.shape
>>> print height, width, channels
600 800 3
On the off chance that you were working with binary pictures, IMG will have two measurements, and consequently you should change the code to height, width = img.shape
Are you interested to learn the concepts of Python? Join the python training course fast!