Contour Detection Python Code Using Functions In Javascript