np.uint8)) maskDots = cv2.erode(maskDots, np.ones(hue["dot_erode"], np.uint8)) #endregion # Find contours and draw them #region Dice contours, _ = cv2.findContours(maskDice, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) dice = [] for c in contours: approx = cv2.approxPolyDP(c, hue["dice_epsilon"], True) if len(approx) == 4: coords = [a[0] for a in approx] d = Die(coords, 0) if (d.isSquare()): color = (0, 200, 0) dice.append(Die(coords, 0, hue["color"])) else: color = (200, 0, 0) cv2.drawContours(frame, [approx], 0, color, 2) cv2.drawContours(maskDice, [approx], 0, (90, 90, 90), 2) cv2.circle(frame, tuple(d.roundedCenter), int(d.minCenterDistance), (0, 0, 255), 3) cv2.circle(frame, tuple(d.roundedCenter), int(d.maxCenterDistance), (255, 255, 255), 3) #endregion #region Dots contours, _ = cv2.findContours(maskDots, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)