Exemplo n.º 1
0
 def write_buffer(self, img, header):
     if len(self.frames) >= self.frame_max:
         self.frames.pop()
         self.headers.pop()
     img = imtools.mirror_image(img)
     self.frames.append(img)
     self.headers.append(header)
Exemplo n.º 2
0
    def get_images_and_labels(self, path):
        import os

        image_paths = [os.path.join(path, f) for f in os.listdir(path)]
        # images will contains face images
        images = []
        # labels will contains the label that is assigned to the image
        labels = []
        for image_path in image_paths:
            # Read the image and convert to grayscale
            image = cv2.imread(image_path)
            # Convert the image format into numpy array
            image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
            # Get the label of the image
            name = os.path.split(image_path)[1].split("_")[0]
            self.add_names(name)

            labels.append(self.name_id[name])
            images.append(image)

            # add the mirrored image for training
            labels.append(self.name_id[name])
            images.append(imtools.mirror_image(image))
        print self.name_id
        return images, labels
Exemplo n.º 3
0
    def mirror_image(self, img):
        if self.should_mirror:
            from imtools import mirror_image

            img = mirror_image(img)
        return img