def generate_core(self, img_fns): # cpfind (and likely cpclean) trashes absolute file names # we need to restore them so that tools recognize the file names real_fn_base2full = {} args = list() project = PTOProject.from_default2() fn_obj = ManagedTempFile.get(None, ".pto") project.set_file_name(fn_obj.file_name) # Start with cpfind args.append("--multirow") args.append("--fullscale") # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) # Images for img_fn in img_fns: # xxx: why do we take the realpath? real_fn = os.path.realpath(img_fn) real_fn_base2full[os.path.basename(real_fn)] = img_fn project.add_image(real_fn, def_opt=True) project.save() print print print print project.get_text() print print print # (rc, output) = Execute.with_output('cpfind', args, print_output=self.print_output) (rc, output) = exc_ret_istr("cpfind", args, print_out=self.print_output) print "PanoCP: cpfind done" if not rc == 0: print print print print "output:" print output print raise Exception("Bad rc: %d" % rc) # Now run cpclean args = list() # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) (rc, output) = exc_ret_istr("cpclean", args, print_out=self.print_output) print "PanoCP: cpclean done" if not rc == 0: print print print print "output:" print output print raise Exception("Bad rc: %d" % rc) project.reopen() print "Fixing image lines..." for il in project.image_lines: src = il.get_name() dst = real_fn_base2full[src] print " %s => %s" % (src, dst) il.set_name(dst) project.set_file_name(None) fn_obj = None # Will happen if failed to match # be optimistic: cpclean work will be wasted but avoids parsing project twice if len(project.get_control_point_lines()) == 0: print "WARNING: failed" return None return project
def generate_core(self, img_fns): # cpfind (and likely cpclean) trashes absolute file names # we need to restore them so that tools recognize the file names real_fn_base2full = {} args = list() project = PTOProject.from_default2() fn_obj = ManagedTempFile.get(None, ".pto") project.set_file_name(fn_obj.file_name) # Start with cpfind args.append("--multirow") args.append("--fullscale") # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) # Images for img_fn in img_fns: # xxx: why do we take the realpath? real_fn = os.path.realpath(img_fn) real_fn_base2full[os.path.basename(real_fn)] = img_fn project.add_image(real_fn, def_opt=True) project.save() print print print print project.get_text() print print print #(rc, output) = Execute.with_output('cpfind', args, print_output=self.print_output) print 'cpfind' + ' '.join(args) (rc, output) = exc_ret_istr('cpfind', args, print_out=self.print_output) print 'PanoCP: cpfind done' if not rc == 0: print print print print 'output:' print output print # Happens very rarely # 2018-01-24T04:00:18.720954: Exception: Bad rc: -11 # Log it but consider it a known failure if rc == -11: return None raise Exception('Bad rc: %d' % rc) # Now run cpclean args = list() # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) (rc, output) = exc_ret_istr('cpclean', args, print_out=self.print_output) print 'PanoCP: cpclean done' if not rc == 0: print print print print 'output:' print output print raise Exception('Bad rc: %d' % rc) project.reopen() print 'Fixing image lines...' for il in project.image_lines: src = il.get_name() dst = real_fn_base2full[src] print ' %s => %s' % (src, dst) il.set_name(dst) project.set_file_name(None) fn_obj = None # Will happen if failed to match # be optimistic: cpclean work will be wasted but avoids parsing project twice if len(project.get_control_point_lines()) == 0: print 'WARNING: failed' return None return project
def generate_core(self, img_fns): # cpfind (and likely cpclean) trashes absolute file names # we need to restore them so that tools recognize the file names real_fn_base2full = {} args = list() project = PTOProject.from_default2() fn_obj = ManagedTempFile.get(None, ".pto") project.set_file_name(fn_obj.file_name) # Start with cpfind args.append("--prealigned") args.append("--fullscale") args.append("--minmatches") args.append("1") args.append("--ransacdist") args.append("5") args.append("--kdtreeseconddist") args.append("0.5") # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) # Images for img_fn in img_fns: # xxx: why do we take the realpath? real_fn = os.path.realpath(img_fn) real_fn_base2full[os.path.basename(real_fn)] = img_fn project.add_image(real_fn, def_opt=True) project.save() print print print print project.get_text() print print print #(rc, output) = Execute.with_output('cpfind', args, print_output=self.print_output) print 'cpfind' + ' '.join(args) (rc, output) = exc_ret_istr('cpfind', args, print_out=self.print_output) print 'PanoCP: cpfind done' if not rc == 0: print print print print 'output:' print output print # Happens very rarely # 2018-01-24T04:00:18.720954: Exception: Bad rc: -11 # Log it but consider it a known failure if rc == -11: return None raise Exception('Bad rc: %d' % rc) # Now run cpclean args = list() # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) (rc, output) = exc_ret_istr('cpclean', args, print_out=self.print_output) print 'PanoCP: cpclean done' if not rc == 0: print print print print 'output:' print output print raise Exception('Bad rc: %d' % rc) # Now run geocpset args = list() # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) (rc, output) = exc_ret_istr('geocpset', args, print_out=self.print_output) print 'PanoCP: geocpset done' if not rc == 0: print print print print 'output:' print output print raise Exception('Bad rc: %d' % rc) project.reopen() print 'Fixing image lines...' for il in project.image_lines: src = il.get_name() dst = real_fn_base2full[src.split('/')[-1]] print ' %s => %s' % (src, dst) il.set_name(dst) project.set_file_name(None) fn_obj = None # Will happen if failed to match # be optimistic: cpclean work will be wasted but avoids parsing project twice if len(project.get_control_point_lines()) == 0: print 'WARNING: failed' return None return project
def generate_core(self, img_fns): # cpfind (and likely cpclean) trashes absolute file names # we need to restore them so that tools recognize the file names real_fn_base2full = {} args = list() project = PTOProject.from_default2() fn_obj = ManagedTempFile.get(None, ".pto") project.set_file_name(fn_obj.file_name) # Start with cpfind args.append("--multirow") args.append("--fullscale") # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) # Images for img_fn in img_fns: # xxx: why do we take the realpath? real_fn = os.path.realpath(img_fn) real_fn_base2full[os.path.basename(real_fn)] = img_fn project.add_image(real_fn, def_opt=True) project.save() print print print print project.get_text() print print print #(rc, output) = Execute.with_output('cpfind', args, print_output=self.print_output) (rc, output) = exc_ret_istr('cpfind', args, print_out=self.print_output) print 'PanoCP: cpfind done' if not rc == 0: print print print print 'output:' print output print raise Exception('Bad rc: %d' % rc) # Now run cpclean args = list() # output file args.append("-o") args.append(project.file_name) # input file args.append(project.file_name) (rc, output) = exc_ret_istr('cpclean', args, print_out=self.print_output) print 'PanoCP: cpclean done' if not rc == 0: print print print print 'output:' print output print raise Exception('Bad rc: %d' % rc) project.reopen() print 'Fixing image lines...' for il in project.image_lines: src = il.get_name() dst = real_fn_base2full[src] print ' %s => %s' % (src, dst) il.set_name(dst) project.set_file_name(None) fn_obj = None # Will happen if failed to match # be optimistic: cpclean work will be wasted but avoids parsing project twice if len(project.get_control_point_lines()) == 0: print 'WARNING: failed' return None return project