working functions for contours & restrict createVideoWriter