def run(self): from pr0ntools.stitch.pto.project import PTOProject '''Take in a list of pto files and merge them into pto''' pto_temp_file = ManagedTempFile.get(None, ".pto") args = ["pto_merge"] args.append("--output=%s" % pto_temp_file) for pto in self.ptos: args.append(pto.get_a_file_name()) print 'MERGING: %s' % (args, ) rc = execute.without_output(args) # go go go if not rc == 0: print print print #print 'Output:' #print output print 'rc: %d' % rc if rc == 35072: # ex: empty projects seem to cause this print 'Out of memory, expect malformed project file' raise Exception('failed pto_merge') if not os.path.exists(str(pto_temp_file)): raise Exception('Output file missing: %s' % (pto_temp_file, )) return PTOProject.from_temp_file(pto_temp_file)
def run(self): from pr0ntools.stitch.pto.project import PTOProject '''Take in a list of pto files and merge them into pto''' pto_temp_file = ManagedTempFile.get(None, ".pto") args = ["pto_merge"] args.append("--output=%s" % pto_temp_file) for pto in self.ptos: args.append(pto.get_a_file_name()) print 'MERGING: %s' % (args,) rc = execute.without_output(args) # go go go if not rc == 0: print print print #print 'Output:' #print output print 'rc: %d' % rc if rc == 35072: # ex: empty projects seem to cause this print 'Out of memory, expect malformed project file' raise Exception('failed pto_merge') if not os.path.exists(str(pto_temp_file)): raise Exception('Output file missing: %s' % (pto_temp_file,)) return PTOProject.from_temp_file(pto_temp_file)
def run(self, to_pto = False): from pr0ntools.stitch.pto.project import PTOProject others = self.files pto = self.pto '''Take in a list of pto files and merge them into pto''' if to_pto: pto_temp_file = self.pto.get_a_file_name() else: pto_temp_file = ManagedTempFile.get(None, ".pto") command = "pto_merge" args = list() args.append("--output=%s" % pto_temp_file) # Possible this is still empty if pto.file_name and os.path.exists(pto.file_name): args.append(pto.file_name) for other in others: args.append(other.get_a_file_name()) print_debug(args) (rc, output) = Execute.with_output(command, args) # go go go if not rc == 0: print print print print 'Output:' print output print 'rc: %d' % rc if rc == 35072: # ex: empty projects seem to cause this print 'Out of memory, expect malformed project file' raise Exception('failed pto_merge') if to_pto: self.pto.reopen() return self.pto else: return PTOProject.from_temp_file(pto_temp_file)
def generate_core(self, image_file_names): project_file = ManagedTempFile.get(None, ".pto") command = "autopano-sift-c" args = list() # Try to post process them to make them more accurate # args.append("--refine") # Perform RANSAC to try to get bad control points out # args.append("--ransac") # args.append("on") # Unlimited matches args.append("--maxmatches") args.append("0") # ? # args.append("--maxdim") # args.append("10000") # Project file args.append(project_file.file_name) # Images for image_file_name in image_file_names: args.append(image_file_name) # go go go # (rc, output) = Execute.with_output(command, args) (rc, output) = (exc_ret_istr(command, args), "") if not rc == 0: print print print print "output:\n%s" % output raise Exception("Bad rc: %d" % rc) # We return PTO object, not string return PTOProject.from_temp_file(project_file)
def generate_core(self, image_file_names): command = "autopanoaj" args = list() project_file = ManagedTempFile.get(None, ".pto") # default is .oto args.append("/project:hugin") # Use image args instead of dir args.append("/f") args.append("/path:Z:\\tmp") # Images for image_file_name in image_file_names: args.append(image_file_name.replace("/tmp/", "Z:\\tmp\\")) # go go go # (rc, output) = Execute.with_output(command, args) rc, output = exc_ret_istr(command, args, print_out=True) if not rc == 0: raise Exception("Bad rc: %d" % rc) # We return PTO object, not string # Ditch the gen file because its unreliable shutil.move("/tmp/panorama0.pto", project_file.file_name) f = open(project_file.file_name, "r") project_text = f.read() # Under WINE, do fixup project_text = project_text.replace("Z:\\tmp\\", "/tmp/") if 0: print print print print project_text print print print f.close() f = open(project_file.file_name, "w") f.write(project_text) return PTOProject.from_temp_file(project_file)
def generate_core(self, image_file_names): project_file = ManagedTempFile.get(None, ".pto") command = "autopano-sift-c" args = list() # Try to post process them to make them more accurate #args.append("--refine") # Perform RANSAC to try to get bad control points out #args.append("--ransac") #args.append("on") # Unlimited matches args.append("--maxmatches") args.append("0") # ? #args.append("--maxdim") #args.append("10000") # Project file args.append(project_file.file_name) # Images for image_file_name in image_file_names: args.append(image_file_name) # go go go #(rc, output) = Execute.with_output(command, args) (rc, output) = (exc_ret_istr(command, args), '') if not rc == 0: print print print print 'output:\n%s' % output raise Exception('Bad rc: %d' % rc) # We return PTO object, not string return PTOProject.from_temp_file(project_file)
def generate_core(self, image_file_names): command = "autopanoaj" args = list() project_file = ManagedTempFile.get(None, ".pto") # default is .oto args.append("/project:hugin") # Use image args instead of dir args.append("/f") args.append('/path:Z:\\tmp') # Images for image_file_name in image_file_names: args.append(image_file_name.replace("/tmp/", "Z:\\tmp\\")) # go go go #(rc, output) = Execute.with_output(command, args) rc, output = exc_ret_istr(command, args, print_out=True) if not rc == 0: raise Exception('Bad rc: %d' % rc) # We return PTO object, not string # Ditch the gen file because its unreliable shutil.move("/tmp/panorama0.pto", project_file.file_name) f = open(project_file.file_name, 'r') project_text = f.read() # Under WINE, do fixup project_text = project_text.replace('Z:\\tmp\\', '/tmp/') if 0: print print print print project_text print print print f.close() f = open(project_file.file_name, 'w') f.write(project_text) return PTOProject.from_temp_file(project_file)
def generate_core(self, image_file_names): command = "autopanoaj" args = list() final_project_file = ManagedTempFile.get(None, ".pto") temp_dir = ManagedTempDir.get() # default is .oto args.append("/project:hugin") # Use image args instead of dir # Images image_links = dict() for image_file_name in image_file_names: # args.append(image_file_name.replace("/tmp/", "Z:\\tmp\\")) image_file_name = os.path.realpath(image_file_name) link_file_name = os.path.join(temp_dir.file_name, os.path.basename(image_file_name)) print 'Linking %s -> %s' % (link_file_name, image_file_name) os.symlink(image_file_name, link_file_name) #sys.exit(1) # go go go (rc, output) = Execute.with_output(command, args, temp_dir.file_name) print 'Finished control point pair execution' if not rc == 0: print print print print 'output:\n%s' % output if output.find('This application has requested the Runtime to terminate it in an unusual way'): print 'WARNING: skipping crash' return None raise Exception('Bad rc: %d' % rc) ''' Doesn't like the match: PICTURE PAIRS VALIDATION Pair ( 0, 1) Ransac (In : 21, Out : 4, Residu : 4.43799) REMOVED Timing : 583.7 us ''' if output.find('REMOVED') >= 0: print 'WARNING: RANSAC invalidated control points' return None output_file_name = os.path.join(temp_dir.file_name, "panorama0.pto") # This happens occassionally, not sure why if not os.path.exists(output_file_name): print 'WARNING: missing output pto file!' return None # We return PTO object, not string # Ditch the gen file because its unreliable shutil.move(output_file_name, final_project_file.file_name) f = open(final_project_file.file_name, 'r') project_text = f.read() # Under WINE, do fixup # #-imgfile 2816 704 "Z:\tmp\pr0ntools_471477ADA1679A2E\pr0ntools_3CD1C0B1BB218E40.jpg" project_text = project_text.replace('Z:\\', '/').replace('\\', '/') for image_file_name in image_file_names: link_file_name = os.path.join(temp_dir.file_name, os.path.basename(image_file_name)) print 'Replacing %s -> %s' % (link_file_name, image_file_name) project_text = project_text.replace(link_file_name, image_file_name) if False: print print 'Raw control point project (after symbolic link and WINE file name substitution)' print print print project_text print print print #sys.exit(1) f.close() f = open(final_project_file.file_name, 'w') f.write(project_text) project = PTOProject.from_temp_file(final_project_file) return project