Get the smallest rectangle from image

Thanks , I went through and tried implementing , I need to draw contours to the smallest rectangle , I see contours in my entire image. Can you please explain me on how do I get the rectangle or any document which gives me on how to get the smallest rectangle from the image with explanation.Please see the ref link , Dealing with contours and bounding rectangle in OpenCV 2.4 - python 2.7 - Stack Overflow, here cod e is in Python