OpenCV Smoother contour

Well, it’s quit hard to manage your code, bc it has lots of useless code spam which makes it more complicated to understand the main idea. Could you please share the code without all that functions related to the time and other staff? (Actually, this is a good way to get answer more quickly on any forums to share only the part of code, where you have problem)