예제 #1
0
 def _image_set(self, annotation_file):
     with open(annotation_file) as f:
         filename = f.readline().rstrip()
         while filename:
             log.debug(filename)
             image = Image(os.path.join(self.images_dir, filename + '.jpg'),
                           filename + '.jpg')
             face_num = int(f.readline().rstrip())
             log.debug(face_num)
             for _ in range(face_num):
                 annotations = f.readline().rstrip().split()
                 log.debug(annotations)
                 face = Face(annotations)
                 image.add_face(face)
             filename = f.readline().rstrip()
             yield image
    def draw_faces(self, image=None, color=(0, 0, 255), thickness=3):
        image = BaseImage.draw_faces(self, image, color, thickness)
        if image is None:
            image = self.image_as_nparray()
        for f in self.faces:
            x = int(f.x1)
            y = int(f.y1)
            cv2.rectangle(image, (x, y), (int(f.x2), int(f.y2)), color,
                          thickness)

            x1, y1, w1, h1 = f.occluder_bbox
            cv2.rectangle(image, (int(x + x1), int(y + y1)),
                          (int(x + w1), int(y + h1)), (0, 255, 255), thickness)

            x2, y2, w2, h2 = f.glasses_bbox
            if x2 != -1:
                cv2.rectangle(image, (int(x + x2), int(y + y2)),
                              (int(x + w2), int(y + h2)), (255, 0, 0),
                              thickness)

            if f.eye1:
                cv2.circle(image, f.eye1, 10, (0, 0, 255), thickness)

            if f.eye2:
                cv2.circle(image, f.eye2, 10, (0, 0, 255), thickness)

        return image
예제 #3
0
 def __init__(self, filename, raw_filename=None):
     BaseImage.__init__(self, filename, raw_filename)
예제 #4
0
 def __init__(self, filename, raw_filename=None):
     BaseImage.__init__(self, filename, raw_filename)
     self.event = Event(filename)
예제 #5
0
 def __init__(self, filename, raw_filename, width, height):
     BaseImage.__init__(self, filename, raw_filename)
     self._width = width
     self._height = height