Ejemplo n.º 1
0
 def match_images(self):
     """
 Match images
 """
     im = match.ImageMatcher(self.params)
     self.matches, self.num_matches, self.interest_points, self.descriptors = im.match_images(
         self.images)
Ejemplo n.º 2
0
    def __init__(self,
                 image_queue,
                 output_queue,
                 image_db,
                 engine_id,
                 log_flag=True):
        super(ApertureServer, self).__init__(image_queue, output_queue,
                                             engine_id)
        self.log_flag = log_flag
        self.table = image_db
        self.matcher = match.ImageMatcher(self.table)
        self.prev_match = None

        # initialize database (if any)
        path = os.path.abspath('db/')
        if not os.path.exists(path):
            os.makedirs(path)

        surf = cv2.xfeatures2d.SURF_create()

        db_filelist = [
            os.path.join(path, f) for f in os.listdir(path)
            if f.lower().endswith("jpeg")
        ]
        for filename in db_filelist:
            img = cv2.resize(cv2.imread(filename, 0),
                             (config.IM_HEIGHT, config.IM_WIDTH))
            annotation_img = cv2.resize(
                cv2.imread(filename.replace('jpeg', 'png'), -1),
                (config.IM_HEIGHT, config.IM_WIDTH))

            # Choose betwen color hist and grayscale hist
            hist = cv2.calcHist([img], [0], None, [256], [0, 256])  # Grayscale
            #hist = cv2.calcHist([img], [0, 1, 2], None, [8, 8, 8], [0, 256, 0, 256, 0, 256])  # Color

            kp, des = surf.detectAndCompute(img, None)

            # Store the keypoints, descriptors, hist, image name, and cv image in database
            self.table.add_annotation(filename,
                                      kp,
                                      des,
                                      hist,
                                      img,
                                      annotation_img=annotation_img)
Ejemplo n.º 3
0
 def match_images(self):
   """
   Match images
   """
   im=match.ImageMatcher(self.params)
   self.matches, self.num_matches = im.match_images(self.images)