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


Python project.PTOProject类代码示例

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


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

示例1: test_tile_real

	def test_tile_real(self):
		project = PTOProject.parse_from_file_name('in.pto')
		print 'Creating tiler'
		t = Tiler(project, 'out', st_scalar_heuristic=2)
		self.assertEqual(len(list(t.gen_supertiles())), 4)
		print 'Unit test running tiler (real)'
		t.run()
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:7,代码来源:test.py

示例2: run

    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)
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:32,代码来源:merger.py

示例3: test_multi

	def test_multi(self):
		print 'Multi test'
		project = PTOProject.parse_from_file_name('in.pto')
		remapper = Remapper(project)
		remapper.image_type = Remapper.TIFF_SINGLE
		remapper.run()	
		self.clean()
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:7,代码来源:test.py

示例4: test_single

	def test_single(self):
		print 'Single test'
		project = PTOProject.from_file_name('in.pto')
		remapper = Remapper(project)
		remapper.image_type = Remapper.TIFF_SINGLE
		remapper.run()	
		self.clean()
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:7,代码来源:test.py

示例5: test_tile_dry

	def test_tile_dry(self):
		'''
		Inputs are 1632 x 1224
		a 3 x 3 grid allows testing edge boundary conditions as well as internal
		The reference fully stitched image is 3377 x 2581
		'''
		project = PTOProject.parse_from_file_name('in.pto')
		print 'Creating tiler'
		t = Tiler(project, 'out', st_scalar_heuristic=2)
		#iw = 1632
		#ih = 1224
		#t.set_size_heuristic(iw, ih)
		'''
		Should make 4 tiles with 3 X 3
		'''
		#t.super_tw = 2 * iw
		#t.super_th = 2 * ih
		'''
		Each supertile should cover two images as setup
		There will be some overlap in the center and unique area on all four edges
		'''
		self.assertEqual(len(list(t.gen_supertiles())), 4)
		print 'Unit test running tiler (real)'
		t.dry = True
		t.run()
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:25,代码来源:test.py

示例6: test_center_anchor

	def test_center_anchor(self):
		project = PTOProject.from_file_name('in.pto')
		center_anchor(project)
		'''
		Image 4 at (1, 1) is the correct answer
		'''
		#vl = project.get_variable_lines()[4]
		project.save()
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:8,代码来源:test.py

示例7: test_optimize

    def test_optimize(self):
		print 'Loading raw project...'
		project = PTOProject.from_file_name('in.pto')
		print 'Creating optimizer...'
		optimizer = PTOptimizer(project)
		#self.assertTrue(project.text != None)
		print 'Running optimizer...'
		optimizer.run()
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:8,代码来源:test.py

示例8: resave_hugin

def resave_hugin(pto):
	from pr0ntools.stitch.merger import Merger
	from pr0ntools.stitch.pto.project import PTOProject
	
	# pto_merge -o converted.pto out.pto out.pto
	blank = PTOProject.from_blank()
	m = Merger([blank])
	m.pto = pto
	new = m.run(to_pto=True)
	if new != pto:
		raise Exception('Expected self merge')
	print 'Merge into self'
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:12,代码来源:util.py

示例9: pto_unsub

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,代码行数:50,代码来源:control_point.py

示例10: run

	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)
开发者ID:xorrhks0216,项目名称:pr0ntools,代码行数:43,代码来源:merger.py

示例11: generate_core

    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)
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:41,代码来源:control_point.py

示例12: help

                arg_key = arg[2:]

            if arg_key == "help":
                help()
                sys.exit(0)
            else:
                arg_fatal("Unrecognized arg: %s" % arg)
        else:
            if arg.find(".pto") > 0:
                project_file_names.append(arg)
            elif os.path.isfile(arg) or os.path.isdir(arg):
                image_file_names.append(arg)
            else:
                arg_fatal("unrecognized arg: %s" % arg)

    project = PTOProject.from_file_name("out.pto")
    project.parse()

    reset_photometrics = True
    if reset_photometrics:
        # Overall exposure
        # *very* important
        project.panorama_line.set_variable("E", 1)
        # What about m's p and s?

        for image_line in project.image_lines:
            # Don't adjust exposure
            image_line.set_variable("Eev", 1)
            # blue and red white balance correction at normal levels
            image_line.set_variable("Eb", 1)
            image_line.set_variable("Er", 1)
开发者ID:BigEd,项目名称:pr0ntools,代码行数:31,代码来源:pr0npto.py

示例13: int

'''

import argparse
from pr0ntools.stitch.pto.project import PTOProject
from pr0ntools.stitch.image_coordinate_map import ImageCoordinateMap
import subprocess
import shutil

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='create tiles from unstitched images')
    parser.add_argument('--border', default='1', help='border size')
    parser.add_argument('pto', default='out.pto', nargs='?', help='pto project')
    args = parser.parse_args()
    args.border = int(args.border, 0)
    
    pto_orig = PTOProject.from_file_name(args.pto)
    img_fns = []
    for il in pto_orig.get_image_lines():
        img_fns.append(il.get_name())
    icm = ImageCoordinateMap.from_tagged_file_names(img_fns)
    
    # Reduced .pto
    pto_red = pto_orig.copy()
    # Delete all lines not in the peripheral
    pto_orig.build_image_fn_map()
    ils_del = []
    for y in xrange(args.border, icm.height() - args.border):
        for x in xrange(args.border, icm.width() - args.border):
            im = icm.get_image(x, y)
            if im is None:
                continue
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:31,代码来源:pr0nhugin.py

示例14: test_center

	def test_center(self):
		project = PTOProject.from_file_name('in.pto')
		center(project)
		(ybar, xbar) = calc_center(project)
		print 'Final xbar %f, ybar %f' % (ybar, xbar)
		project.save()
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:6,代码来源:test.py

示例15: test_optimize_conversion

    def test_optimize_conversion(self):
		project = PTOProject.from_file_name('in.pto')
		pt = project.copy()
开发者ID:JohnDMcMaster,项目名称:pr0ntools,代码行数:3,代码来源:test.py


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