本文整理汇总了Python中pr0ntools.stitch.pto.project.PTOProject.from_text方法的典型用法代码示例。如果您正苦于以下问题:Python PTOProject.from_text方法的具体用法?Python PTOProject.from_text怎么用?Python PTOProject.from_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pr0ntools.stitch.pto.project.PTOProject
的用法示例。
在下文中一共展示了PTOProject.from_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: control_points_by_subimage
# 需要导入模块: from pr0ntools.stitch.pto.project import PTOProject [as 别名]
# 或者: from pr0ntools.stitch.pto.project.PTOProject import from_text [as 别名]
#.........这里部分代码省略.........
print 'WARNING: failed to gen control points @ %s' % repr(pair)
return None
out = ''
part_pair_index = 0
for line in fast_pair_project.__repr__().split('\n'):
if len(line) == 0:
new_line = ''
# This type of line is gen by autopano-sift-c
elif line[0] == 'c':
# c n0 N1 x1142.261719 y245.074757 X699.189408 Y426.042661 t0
'''
Okay def alphabetical issues
# Not strictly related to this code, but close enough
if not index_to_sub_file_name[0] == sub_image_0_file:
print '0 index indicated file: %s, pair gen order expected %s' % (index_to_sub_file_name[0], sub_image_0_file)
raise Exception('mismatch')
if not index_to_sub_file_name[1] == sub_image_1_file:
print '1 index indicated file: %s, pair gen order expected %s' % (index_to_sub_file_name[1], sub_image_1_file)
raise Exception('mismatch')
'''
# Parse
parts = line.split()
if not parts[1] == 'n0':
print parts[1]
raise Exception('mismatch')
if not parts[2] == 'N1':
print parts[2]
raise Exception('mismatch')
x = float(parts[3][1:])
y = float(parts[4][1:])
X = float(parts[5][1:])
Y = float(parts[6][1:])
#sub_image_1_x_end = image_1.width()
#sub_image_1_y_end = image_1.height()
# Adjust the image towards the upper left hand corner
if index_to_sub_file_name[0] == sub_image_0_file.file_name:
# normal adjustment
x += sub_image_0_x_delta
y += sub_image_0_y_delta
elif index_to_sub_file_name[1] == sub_image_0_file.file_name:
# they got flipped
X += sub_image_0_x_delta
Y += sub_image_0_y_delta
else:
print index_to_sub_file_name
print 'index_to_sub_file_name[0]: %s' % repr(index_to_sub_file_name[0])
print 'index_to_sub_file_name[1]: %s' % repr(index_to_sub_file_name[1])
print 'sub_image_0_file: %s' % repr(sub_image_0_file)
print 'sub_image_1_file: %s' % repr(sub_image_1_file)
raise Exception("confused")
# Write
new_line = "c n0 N1 x%f y%f X%f Y%f t0" % (x, y, X, Y)
out += new_line + '\n'
# This type of line is generated by pto_merge
elif line[0] == 'i':
# i w2816 h704 f0 a0 b-0.01 c0 d0 e0 p0 r0 v180 y0 u10 n"/tmp/pr0ntools_6691335AD228382E.jpg"
new_line = ''
for part in line.split():
t = part[0]
if t == 'i':
new_line += 'i'
elif t == 'w':
new_line += ' w%d' % images[0].width()
elif t == 'h':
new_line += ' w%d' % images[0].height()
elif t == 'n':
new_line += ' n%s' % pair_images[part_pair_index]
part_pair_index += 1
else:
new_line += ' %s' % part
print 'new line: %s' % new_line
# These lines are generated by autopanoaj
# The comment line is literally part of the file format, some sort of bizarre encoding
# #-imgfile 2816 704 "/tmp/pr0ntools_2D24DE9F6CC513E0/pr0ntools_6575AA69EA66B3C3.jpg"
# o f0 y+0.000000 r+0.000000 p+0.000000 u20 d0.000000 e0.000000 v70.000000 a0.000000 b0.000000 c0.000000
elif line.find('#-imgfile') == 0:
# Replace pseudo file names with real ones
new_line = line
index_to_sub_file_name[imgfile_index] = line.split('"')[1]
imgfile_index += 1
else:
new_line = line
out += new_line + '\n'
else:
out += line + '\n'
for k in sub_to_real:
v = sub_to_real[k]
print 'Replacing %s => %s' % (k, v)
out = out.replace(k, v)
final_pair_project = PTOProject.from_text(out)
return final_pair_project