本文整理汇总了Python中pr0ntools.stitch.pto.project.PTOProject.from_default2方法的典型用法代码示例。如果您正苦于以下问题:Python PTOProject.from_default2方法的具体用法?Python PTOProject.from_default2怎么用?Python PTOProject.from_default2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pr0ntools.stitch.pto.project.PTOProject
的用法示例。
在下文中一共展示了PTOProject.from_default2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_core
# 需要导入模块: from pr0ntools.stitch.pto.project import PTOProject [as 别名]
# 或者: from pr0ntools.stitch.pto.project.PTOProject import from_default2 [as 别名]
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