How do I detect polygon contours that I drew by using opencv?

The problem may be you are directly passing edge image for find contour, which may contain many unconnected edges.

So before find contour apply Morphology Transformations.

like,

   Size kernalSize (5,5);
   Mat element = getStructuringElement (MORPH_RECT, kernalSize, Point(1,1)  );
   morphologyEx( bw, bw, MORPH_CLOSE, element );

See the result.

Bounding rectangle for contours

bounding rectangle for  contours

approxPolyDP for contours

approxPolyDP for  contours