예제 #1
0
    def run(self):
        '''
        Phase 1: remap the relevant source image areas onto a canvas
        
        Note that nona will load ALL of the images (one at a time)
        but will only generate output for those that matter
        Each one takes a noticible amount of time but its relatively small compared to the time spent actually mapping images
        '''
        print
        print 'Supertile phase 1: remapping (nona)'
        if self.out.find('.') < 0:
            raise Exception('Require image extension')
        # Hugin likes to use the base filename as the intermediates, lets do the sames
        out_name_base = self.out[0:self.out.find('.')].split('/')[-1]
        print "out name: %s, base: %s" % (self.out, out_name_base)
        #ssadf
        if out_name_base is None or len(out_name_base) == 0 or out_name_base == '.' or out_name_base == '..':
            raise Exception('Bad output file base "%s"' % str(out_name_base))

        # Scope of these files is only here
        # We only produce the single output file, not the intermediates
        managed_temp_dir = ManagedTempDir.get2(prefix_mangle='st_%06dx_%06dy_' % (self.bounds[0], self.bounds[1]))
        # without the slash they go into the parent directory with that prefix
        out_name_prefix = managed_temp_dir.file_name + "/"
        
        '''
        For large projects this was too slow
        Instead, we simply copy the project and manually fix up the relevant portion
        '''
        print 'Copying pto'
        pto = self.pto.copy(control_points=False)
        #pto = self.mini_pto.copy()
        
        print 'Cropping...'
        #sys.exit(1)
        pl = pto.panorama_line
        # It is fine to go out of bounds, it will be black filled
        #pl.set_bounds(x, min(x + self.tw(), pto.right()), y, min(y + self.th(), pto.bottom()))
        pl.set_crop(self.bounds)
        # try to fix remapper errors due to excessive overlap
        rm_red_img(pto)
        #print 'debug break' ; sys.exit(1)
        
        print 'Preparing remapper...'
        remapper = Nona(pto, out_name_prefix)
        remapper.pprefix = self.pprefix
        remapper.args = self.nona_args
        print 'Starting remapper...'
        remapper.remap()
        
        '''
        Phase 2: blend the remapped images into an output image
        '''
        print
        print 'Supertile phase 2: blending (enblend)'
        blender = Enblend(remapper.get_output_files(), self.out, lock=self.enblend_lock)
        blender.pprefix = self.pprefix
        blender.args = self.enblend_args
        blender.run()
        # We are done with these files, they should be nuked
        if not config.keep_temp_files():
            for f in remapper.get_output_files():
                os.remove(f)
        
        print 'Supertile ready!'
예제 #2
0
    def run(self):
        '''
        Phase 1: remap the relevant source image areas onto a canvas
        
        Note that nona will load ALL of the images (one at a time)
        but will only generate output for those that matter
        Each one takes a noticible amount of time but its relatively small compared to the time spent actually mapping images
        '''
        print
        print 'Supertile phase 1: remapping (nona)'
        if self.out.find('.') < 0:
            raise Exception('Require image extension')
        # Hugin likes to use the base filename as the intermediates, lets do the sames
        out_name_base = self.out[0:self.out.find('.')].split('/')[-1]
        print "out name: %s, base: %s" % (self.out, out_name_base)
        #ssadf
        if out_name_base is None or len(
                out_name_base
        ) == 0 or out_name_base == '.' or out_name_base == '..':
            raise Exception('Bad output file base "%s"' % str(out_name_base))

        # Scope of these files is only here
        # We only produce the single output file, not the intermediates
        managed_temp_dir = ManagedTempDir.get2(
            prefix_mangle='st_%06dx_%06dy_' % (self.bounds[0], self.bounds[1]))
        # without the slash they go into the parent directory with that prefix
        out_name_prefix = managed_temp_dir.file_name + "/"
        '''
        For large projects this was too slow
        Instead, we simply copy the project and manually fix up the relevant portion
        '''
        print 'Copying pto'
        pto = self.pto.copy(control_points=False)
        #pto = self.mini_pto.copy()

        print 'Cropping...'
        #sys.exit(1)
        pl = pto.panorama_line
        # It is fine to go out of bounds, it will be black filled
        #pl.set_bounds(x, min(x + self.tw(), pto.right()), y, min(y + self.th(), pto.bottom()))
        pl.set_crop(self.bounds)
        # try to fix remapper errors due to excessive overlap
        rm_red_img(pto)
        #print 'debug break' ; sys.exit(1)

        print 'Preparing remapper...'
        remapper = Nona(pto, out_name_prefix)
        remapper.pprefix = self.pprefix
        remapper.args = self.nona_args
        print 'Starting remapper...'
        remapper.remap()
        '''
        Phase 2: blend the remapped images into an output image
        '''
        print
        print 'Supertile phase 2: blending (enblend)'
        blender = Enblend(remapper.get_output_files(),
                          self.out,
                          lock=self.enblend_lock)
        blender.pprefix = self.pprefix
        blender.args = self.enblend_args
        blender.run()
        # We are done with these files, they should be nuked
        if not config.keep_temp_files():
            for f in remapper.get_output_files():
                os.remove(f)

        print 'Supertile ready!'