According to your article:
However, your code divides by width: Distance1 = 11.5*(img.shape[1]/float(w))
Distance1 = 11.5*(img.shape[1]/float(w))
Shouldn't that be: Distance1 = 11.5*(img.shape[1]/float(h))
Distance1 = 11.5*(img.shape[1]/float(h))