Esempio n. 1
0
                               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)

            for c in contours:
                approx = cv2.approxPolyDP(c, 1, False)
                if len(approx) >= 4:
                    x, y, w, h = cv2.boundingRect(approx)
                    x2 = x + w
                    y2 = y + h
                    for d in dice:
                        if (d.isBelongs([x, x2], [y, y2])):
                            if d.dots < 7:
                                d.dots += 1
                            cv2.drawContours(frame, [approx], 0, (0, 200, 200),
                                             2)
                            cv2.drawContours(maskDots, [approx], 0,
                                             (90, 90, 90), 2)

            for d in dice:
                if d.dots == 0:
                    d.dots = 0
                else:
                    d.dots -= 1
            #endregion

            if len(dice) > 0: