Пример #1
0
    def draw_objs(self, img, is_id=False, is_rect=True, is_tag=True):
        for obj in self.tracker.get_objs():
            font = cv2.FONT_HERSHEY_SIMPLEX
            font_scale = 0.3
            thickness = 1
            x1, y1, x2, y2, oid = obj
            x1 = int(x1)
            y1 = int(y1)
            x2 = int(x2)
            y2 = int(y2)
            oid = int(oid)
            rectangle_color = (255, 255, 255)
            text_color = (0, 0, 0)

            tag = self.detected[oid]["tag"]
            if tag == "Bottle - NG":
                rectangle_color = (0, 0, 255)
                text_color = (255, 255, 255)

            if is_id:
                # img = cv2.putText(img, str(oid), (x, y), font, font_scale,
                #                  (0, 255, 255), thickness)
                img = draw_label(img, str(oid), (x1, y1))
            if is_tag:
                score = self.detected[oid]["score"]
                text = tag + " ( " + str(int(1000 * score) / 10) + "% )"
                img = draw_label(img, text, (x1, max(y1, 15)), rectangle_color,
                                 text_color)
            if is_rect:
                img = cv2.rectangle(img, (x1, max(y1, 15)), (x2, y2),
                                    rectangle_color, thickness)
                # img = cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 255),
                #                    thickness)
        return img
Пример #2
0
 def draw_objs(self, img, is_id=False, is_rect=True, is_tag=True):
     for obj in self.tracker.get_objs():
         font = cv2.FONT_HERSHEY_SIMPLEX
         font_scale = 0.3
         thickness = 1
         x1, y1, x2, y2, oid = obj
         x1 = int(x1)
         y1 = int(y1)
         x2 = int(x2)
         y2 = int(y2)
         oid = int(oid)
         if is_id:
             #img = cv2.putText(img, str(oid), (x, y), font, font_scale,
             #                  (0, 255, 255), thickness)
             img = draw_label(img, str(oid), (x1, y1))
         if is_tag:
             tag = self.detected[oid]['tag']
             score = self.detected[oid]['score']
             text = tag + ' ( ' + str(int(1000 * score) / 10) + '% )'
             img = draw_label(img, text, (x1, max(y1, 15)))
         if is_rect:
             img = cv2.rectangle(img, (x1, max(y1, 15)), (x2, y2),
                                 (255, 255, 255), thickness)
             #img = cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 255),
             #                    thickness)
     return img
Пример #3
0
def draw_confidence_level(img, prediction):
    height, width = img.shape[0], img.shape[1]

    font = cv2.FONT_HERSHEY_DUPLEX
    font_scale = 0.7
    thickness = 1

    prob_str = str(int(prediction['probability']*1000)/10)
    prob_str = ' (' + prob_str + '%)'

    (x1, y1), (x2, y2) = parse_bbox(prediction, width, height)

    text = prediction['tagName'] + prob_str
    img = draw_label(img, text, (x1, max(y1, 15)))

    return img
Пример #4
0
def draw_confidence_level(img, prediction):
    height, width = img.shape[0], img.shape[1]

    # font = cv2.FONT_HERSHEY_DUPLEX
    # font_scale = 0.5
    # thickness = 1

    prob_str = str(int(prediction["probability"] * 1000) / 10)
    prob_str = " (" + prob_str + "%)"

    (x1, y1), (x2, y2) = parse_bbox(prediction, width, height)

    # img = cv2.putText(img, prediction['tagName']+prob_str,
    #                  (x1, y1-5), font, font_scale, (255, 255, 255), thickness)
    text = prediction["tagName"] + prob_str
    img = draw_label(img, text, (x1, max(y1, 15)))

    return img
 def draw_objs(self, img, is_id=True, is_rect=True):
     for obj in self.tracker.get_objs():
         font = cv2.FONT_HERSHEY_DUPLEX
         font_scale = 0.7
         thickness = 1
         x1, y1, x2, y2, oid = obj
         x1 = int(x1)
         y1 = int(y1)
         x2 = int(x2)
         y2 = int(y2)
         oid = int(oid)
         x = x1
         y = y1 - 5
         if is_id:
             img = draw_label(img, str(oid), (x, y))
         if is_rect:
             img = cv2.rectangle(img, (x1, y1), (x2, y2), (255, 255, 255), thickness)
     return img