def __del__(self): try: if os.path.exists(self.file_name): if config.keep_temp_files(): print 'KEEP: Deleted temp dir %s' % self.file_name else: shutil.rmtree(self.file_name) print 'Deleted temp dir %s' % self.file_name else: print "Didn't delete inexistant temp dir %s" % self.file_name # Ignore if it was never created except: print 'WARNING: failed to delete temp dir: %s' % self.file_name
def __del__(self): try: if os.path.exists(self.file_name): if config.keep_temp_files(): verbose('KEEP: Deleted temp file %s' % self.file_name) else: os.remove(self.file_name) verbose('Deleted temp file %s' % self.file_name) else: verbose("Didn't delete inexistant temp file %s" % self.file_name) # Ignore if it was never created except: print 'WARNING: failed to delete temp file: %s' % self.file_name
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.get() # without the slash they go into the parent directory with that prefix out_name_prefix = managed_temp_dir.file_name + "/" pto = self.pto.copy() print 'Making absolute' pto.make_absolute() print 'Cropping...' #sys.exit(1) pl = pto.get_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) remapper = Remapper(pto, out_name_prefix) remapper.remap() ''' Phase 2: blend the remapped images into an output image ''' print print 'Supertile phase 2: blending (enblend)' blender = Blender(remapper.get_output_files(), self.out) 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!'
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!'
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!'