function detectEnds(contour, { maxStroke = 10, angleTol = 20 } = {}) {
  const result = [];
  contour.forEach((pt1, i) => {
    const pt2 = contour[mod(i+1, contour.length)],
          pt3 = contour[mod(i+2, contour.length)],
          pt4 = contour[mod(i+3, contour.length)],
          pt5 = contour[mod(i+4, contour.length)],
          pt6 = contour[mod(i+5, contour.length)];
    if (isEnd(pt1, pt2, pt3, pt4, pt5, pt6, { maxStroke, angleTol })) {
      result.push(mod(i+1, contour.length));
    }
  });
  return result;
}
Ends detection
@param { Contour } contour 
@param { { maxStroke: number, angleTol: number } } config
@returns { number[] }