Exemplo n.º 1
0
    def Execute(self):
        images = self.GetInputStageValue(0, "images")

        self.StartProcess()

        kds = []
        images.WriteFileList()
        ds = 0
        if (self._properties["Downsample"]): ds = 1

        for im in images.GetImages():
            keypointDescriptorFile = os.path.join(
                os.path.splitext(im.GetFilePath())[0] + ".key")

            if (Common.Utility.ShouldRun(self._properties["Force Run"],
                                         keypointDescriptorFile)):

                self.RunCommand(
                    "ASIFTkeypoint",
                    Common.Utility.CommandArgs(
                        Common.Utility.Quoted(im.GetFilePath()),
                        Common.Utility.Quoted(keypointDescriptorFile),
                        self._properties["Number of Tilts"], ds))

            kd = FeatureExtraction.KeypointDescriptorFileLowe(
                keypointDescriptorFile, False)
            kds.append(kd)

        kds = FeatureExtraction.KeypointDescriptors(images.GetPath(), kds)
        self.SetOutputValue("keypointDescriptors", kds)
Exemplo n.º 2
0
    def Execute(self):
        images = self.GetInputStageValue(0, "images")

        self.StartProcess()

        kds = []

        for im in images.GetImages():
            keypointDescriptorFile = os.path.join(
                os.path.splitext(im.GetFilePath())[0] + ".key")

            if (Common.Utility.ShouldRun(self._properties["Force Run"],
                                         keypointDescriptorFile)):

                daisyKD = self.Process(im.GetFilePath())

                kd = FeatureExtraction.KeypointDescriptorFileLowe(
                    daisyKD, self._properties["Parse Descriptors"])

                kd.Write(os.path.splitext(daisyKD.GetFilePath())[0] + ".key")

            else:
                kd = FeatureExtraction.KeypointDescriptorFileLowe(
                    keypointDescriptorFile,
                    self._properties["Parse Descriptors"])

            kds.append(kd)

        kds = FeatureExtraction.KeypointDescriptors(images.GetPath(), kds)
        self.SetOutputValue("keypointDescriptors", kds)
Exemplo n.º 3
0
 def Execute(self):
     images = self.GetInputStageValue(0, "images")
     
     self.StartProcess()
 
     q = multiprocessing.Queue()
     for i,im in enumerate(images.GetImages()):
         q.put_nowait((i,im))
         
     kds = [None]*len(images.GetImages())
     workers = []
     for i in range(self._properties["CPUs"]):
         w = Sift.Worker(q, kds, self)
         w.start()
         workers.append(w)
     
     errors = []
     for w in workers:
         w.join()
         errors.extend(w.getErrors())
         
     if (len(errors)>0):
         raise Exception(string.join(errors,"\n"))
     
     kds = FeatureExtraction.KeypointDescriptors(images.GetPath(), kds)
     self.SetOutputValue("keypointDescriptors", kds)        
Exemplo n.º 4
0
    def Execute(self):
        images = self.GetInputStageValue(0, "images")
        
        self.StartProcess()
    
        import cv
        MIN_DESC_VAL = -0.5
        MAX_DESC_VAL = 0.8
        CONV_FACTOR = 255.0 / (MAX_DESC_VAL-MIN_DESC_VAL)
        kds = []
        
        for im in images.GetImages():
            keypointDescriptorFile = os.path.join(os.path.splitext(im.GetFilePath())[0]+".key")
            
            if (Common.Utility.ShouldRun(self._properties["Force Run"], keypointDescriptorFile)):
                
                cvim = cv.LoadImageM(im.GetFilePath(), cv.CV_LOAD_IMAGE_GRAYSCALE)
                keypoints, descriptors = cv.ExtractSURF(cvim, None, cv.CreateMemStorage(),
                                                        (1,
                                                         self._properties["Hessian Threshold"],
                                                         self._properties["Number Octaves"],
                                                         self._properties["Number Octave Layers"]))
                l = []
                for i,descriptor in enumerate(descriptors):
                    
                    descr = [int((x-MIN_DESC_VAL)*CONV_FACTOR) for x in descriptor]

                    l.append(FeatureExtraction.KeypointDescriptor(keypoints[i][0][1],
                                                                  keypoints[i][0][0],
                                                                  keypoints[i][2],
                                                                  math.radians(keypoints[i][3]),
                                                                  descr))
                
                kdfl = FeatureExtraction.KeypointDescriptorFileLowe(l)
                kdfl.Write(keypointDescriptorFile)
                kdfl = FeatureExtraction.KeypointDescriptorFileLowe(keypointDescriptorFile, False)
                kds.append(kdfl)
        
        kds = FeatureExtraction.KeypointDescriptors(images.GetPath(), kds, False)
        self.SetOutputValue("keypointDescriptors", kds)