Esempio n. 1
0
    def loadLibrary(self, filename, dtype=np.float32):
        """
			Load Library
		"""
        self.images = []
        print('Load images')
        with open(filename, 'r') as f:
            c = time.clock()
            self.nbImage = int(f.readline())
            for i in range(self.nbImage):
                name = f.readline()
                nbDesc = int(f.readline())
                k = []
                d = []
                for i in range(nbDesc):
                    x = float(f.readline())
                    y = float(f.readline())
                    size = float(f.readline())
                    angle = float(f.readline())
                    class_id = int(f.readline())
                    octave = int(f.readline())
                    response = float(f.readline())
                    k.append(
                        cv2.KeyPoint(x, y, size, angle, response, octave,
                                     class_id))
                    d.append(np.fromstring(eval(f.readline()), dtype=dtype))
                self.images.append((name, (k, d)))
                loadBar(i, self.nbImage)
            print('time to read the library:', time.clock() - c)
Esempio n. 2
0
    def loadLibrary(self, filename, dtype=np.float32):
        """
			Load Library
		"""
        self.images = []
        print("Load images")
        with open(filename, "r") as f:
            c = time.clock()
            self.nbImage = int(f.readline())
            for i in range(self.nbImage):
                name = f.readline()
                nbDesc = int(f.readline())
                k = []
                d = []
                for i in range(nbDesc):
                    x = float(f.readline())
                    y = float(f.readline())
                    size = float(f.readline())
                    angle = float(f.readline())
                    class_id = int(f.readline())
                    octave = int(f.readline())
                    response = float(f.readline())
                    k.append(cv2.KeyPoint(x, y, size, angle, response, octave, class_id))
                    d.append(np.fromstring(eval(f.readline()), dtype=dtype))
                self.images.append((name, (k, d)))
                loadBar(i, self.nbImage)
            print("time to read the library:", time.clock() - c)
Esempio n. 3
0
 def save(self, filename):
     print("Save image list")
     with open(filename, "w") as f:
         t = time.clock()
         f.write(str(self.nbImage))
         f.write("\n")
         for j, (name, (klist, dlist)) in enumerate(self.images):
             f.write(name + "\n" + str(len(klist)) + "\n")
             for i, k in enumerate(klist):
                 l = [k.pt[0], k.pt[1], k.size, k.angle, k.class_id, k.octave, k.response, dlist[i].tostring(), ""]
                 f.write("\n".join([str(e) for e in l]))
             loadBar(j, self.nbImage)
     elapsed = time.clock()
     print("Elapsed time : ", elapsed - t)
     print("Time to save one image :", (elapsed - t) / len(imageList))
Esempio n. 4
0
 def save(self, filename):
     print("Save image list")
     with open(filename, 'w') as f:
         t = time.clock()
         f.write(str(self.nbImage))
         f.write('\n')
         for j, (name, (klist, dlist)) in enumerate(self.images):
             f.write(name + '\n' + str(len(klist)) + '\n')
             for i, k in enumerate(klist):
                 l = [
                     k.pt[0], k.pt[1], k.size, k.angle, k.class_id,
                     k.octave, k.response, dlist[i].tostring(), ''
                 ]
                 f.write('\n'.join([str(e) for e in l]))
             loadBar(j, self.nbImage)
     elapsed = time.clock()
     print("Elapsed time : ", elapsed - t)
     print("Time to save one image :", (elapsed - t) / len(imageList))