Added checks for all of vertices from each contour instead of checking only for the first vertex.
Attach a file by drag & drop or click to upload