当前位置: 首页>>代码示例>>Python>>正文


Python PTOProject.from_simple方法代码示例

本文整理汇总了Python中pr0ntools.stitch.pto.project.PTOProject.from_simple方法的典型用法代码示例。如果您正苦于以下问题:Python PTOProject.from_simple方法的具体用法?Python PTOProject.from_simple怎么用?Python PTOProject.from_simple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pr0ntools.stitch.pto.project.PTOProject的用法示例。


在下文中一共展示了PTOProject.from_simple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pto_unsub

# 需要导入模块: from pr0ntools.stitch.pto.project import PTOProject [as 别名]
# 或者: from pr0ntools.stitch.pto.project.PTOProject import from_simple [as 别名]
def pto_unsub(src_prj, sub_image_files, deltas, sub_to_real):
    """
    Transforms a sub-project back into original control point coordinate space using original file names
    Returns a new project file
    src_prj: base project that needs to be transformed
    sub_image_files: tuple specifying original project 0/1 positions
        needed to correctly apply deltas
    deltas: delta to apply to pair_project coordinates to bring back to target (original) project space
        0: x
        1: y
        images are relative to each other
        only has delta within relative image frame, not entire project canvas
    sub_to_real: map of project file names to target (original) project file names
        the output project must use these instead of the original names
    """
    ret = PTOProject.from_simple()

    same_order = True
    # Copy/fix images
    print "Order check"
    for i, src_il in enumerate(src_prj.get_image_lines()):
        # copy it
        dst_il = ImageLine(str(src_il), ret)
        # fix the name so that it can be merged
        dst_il.set_name(sub_to_real[src_il.get_name()])
        # add it
        ret.add_image_line(dst_il)
        same_order = same_order and sub_image_files[i].file_name == src_il.get_name()
        print "  %d: %s vs %s" % (i, sub_image_files[i].file_name, src_il.get_name())

    # Copy/shift control points
    # Should have been filtered out earlier
    if len(src_prj.get_control_point_lines()) == 0:
        raise Exception("No source control point lines")
    for src_cpl in src_prj.get_control_point_lines():
        # copy it
        dst_cpl = ControlPointLine(str(src_cpl), ret)
        # shift to original coordinate space
        if same_order:
            # normal adjustment
            dst_cpl.set_variable("x", src_cpl.get_variable("x") + deltas[0])
            dst_cpl.set_variable("y", src_cpl.get_variable("y") + deltas[1])
        else:
            # they got flipped
            dst_cpl.set_variable("X", src_cpl.get_variable("X") + deltas[0])
            dst_cpl.set_variable("Y", src_cpl.get_variable("Y") + deltas[1])
        # add it
        ret.add_control_point_line(dst_cpl)

    return ret
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:52,代码来源:control_point.py

示例2: ajpto2pto_text

# 需要导入模块: from pr0ntools.stitch.pto.project import PTOProject [as 别名]
# 或者: from pr0ntools.stitch.pto.project.PTOProject import from_simple [as 别名]
def ajpto2pto_text(pto_str, sub_image_0_file, sub_image_1_file, sub_image_0_x_delta, sub_image_0_y_delta, sub_to_real, load_images = True):
	'''Take in an old style autopanoaj project and return a .pto object'''

	# image index to subimage file name link (not symbolic link)
	index_to_sub_file_name = dict()
	imgfile_index = 0
	part_pair_index = 0
	
	ret = PTOProject.from_simple()
	
	#out = ''
	
	'''Convert .oto text (like from autopanoaj) to a .pto'''
	# Actually I think really is a .pto, just in a less common format
	for line in pto_str.split('\n'):
		if len(line) == 0:
			continue
		# 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'
			ret.add_control_point_line_by_text(new_line)
		# This type of line is generated by pto_merge
		elif line[0] == 'o':
			'''
			#-imgfile 1632 408 "/tmp/pr0ntools_6691335AD228382E.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
			to
			i w2816 h704 f0 a0 b-0.01 c0 d0 e0 p0 r0 v180 y0  u10 n"/tmp/pr0ntools_6691335AD228382E.jpg"
			'''
			new_line = ''
			new_line += 'i'
			# Deferred to end
			if 0:
				# panotools fails in very exciting ways if you don't set this
				new_line += ' w%d' % images[0].width()
				new_line += ' w%d' % images[0].height()
			# default FOV
			new_line += ' v51'
			
			orig_fn = index_to_sub_file_name[part_pair_index]
			new_fn = sub_to_real[orig_fn]
			print 'Replacing %s => %s' % (orig_fn, new_fn)
			new_line += ' n"%s"' % new_fn
			
			part_pair_index += 1
			print 'new line: %s' % new_line
			ret.add_image_line_by_text(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
#.........这里部分代码省略.........
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:103,代码来源:control_point.py


注:本文中的pr0ntools.stitch.pto.project.PTOProject.from_simple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。