How to close the contour

Sorry
try approxyPolyDP