Doubt in Bounding Rectangle Algorithm

Okay, Now I am a bit confused so …first where can I find the actual src code?

but contours are the boundaries right? of the objects in an image so if we apply the bounding rect to the below image

it should work right ?
Thank you!