コード例 #1
0
ファイル: robot.py プロジェクト: JoeSuber/CardSnake
 def draw_guides(self, cam_img):
     if self.ADJUSTING:
         saying = "Use Arrow Keys and Numbers (1-4) to adjust until warp is square"
         for pnt, r, c, ln in zip(self.pts1, self.radii, self.colors, self.lines):
             cv2.circle(cam_img, tuple(pnt), r, c, thickness=ln)
         for line, (label, pnt, hue) in enumerate(zip(["p1", "p2", "p3", "p4"], self.pts1, self.colors)):
             draw_str(cam_img, (10, 40 + (line * 15)), " =".join([label, str(tuple(pnt))]), color=hue)
     else:
         saying = "Press [a] to turn corner-adjustment on/off."
     draw_str(cam_img, (20, 17), saying)
     return cam_img
コード例 #2
0
ファイル: robot.py プロジェクト: JoeSuber/CardSnake
 def show_card_info(self, texts, chalkboard, max_expansion=2.6, topleft=(5, 5)):
     """ take a list of text lines and draw each so it fits in most of the width of the given image"""
     startx, starty = topleft
     max_x = chalkboard.shape[1] - startx * 2    # leaves margins
     for txt in texts:
         (sx, sy), baseline = cv2.getTextSize(txt, fontFace=cv2.FONT_HERSHEY_PLAIN, fontScale=1, thickness=2)
         # baseline: straggling font-pixels extending below base of most letters, i.e. g p q
         sy += baseline * 0.5
         size_ratio = min(max_x / sx, max_expansion)
         starty += (int(sy * size_ratio) + 2)
         draw_str(chalkboard, (startx, starty), txt, font=cv2.FONT_HERSHEY_PLAIN, size=size_ratio, color=(0, 255, 0))
     return chalkboard
コード例 #3
0
 def draw_guides(self, cam_img):
     if self.ADJUSTING:
         saying = "Use Arrow Keys and Numbers (1-4) to adjust until warp is square"
         for pnt, r, c, ln in zip(self.pts1, self.radii, self.colors,
                                  self.lines):
             cv2.circle(cam_img, tuple(pnt), r, c, thickness=ln)
         for line, (label, pnt, hue) in enumerate(
                 zip(["p1", "p2", "p3", "p4"], self.pts1, self.colors)):
             draw_str(cam_img, (10, 40 + (line * 15)),
                      " =".join([label, str(tuple(pnt))]),
                      color=hue)
     else:
         saying = "Press [a] to turn corner-adjustment on/off."
     draw_str(cam_img, (20, 17), saying)
     return cam_img
コード例 #4
0
 def show_card_info(self,
                    texts,
                    chalkboard,
                    max_expansion=2.6,
                    topleft=(5, 5)):
     """ take a list of text lines and draw each so it fits in most of the width of the given image"""
     startx, starty = topleft
     max_x = chalkboard.shape[1] - startx * 2  # leaves margins
     for txt in texts:
         (sx,
          sy), baseline = cv2.getTextSize(txt,
                                          fontFace=cv2.FONT_HERSHEY_PLAIN,
                                          fontScale=1,
                                          thickness=2)
         # baseline: straggling font-pixels extending below base of most letters, i.e. g p q
         sy += baseline * 0.5
         size_ratio = min(max_x / sx, max_expansion)
         starty += (int(sy * size_ratio) + 2)
         draw_str(chalkboard, (startx, starty),
                  txt,
                  font=cv2.FONT_HERSHEY_PLAIN,
                  size=size_ratio,
                  color=(0, 255, 0))
     return chalkboard