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