Beispiel #1
0
	def test_multi(self):
		print 'Multi test'
		project = PTOProject.from_file_name('in.pto')
		remapper = Remapper(project)
		remapper.image_type = Remapper.TIFF_SINGLE
		remapper.run()	
		self.clean()
Beispiel #2
0
    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()
Beispiel #3
0
	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()
Beispiel #4
0
        _outdate = IOTimestamp(sys, 'stdout')
        _errdate = IOTimestamp(sys, 'stderr')

    if exist:
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('*' * 80 + '\n')
        _outlog.out_fd.write('*' * 80 + '\n')
        _outlog.out_fd.write('*' * 80 + '\n')
    print 'pr0npto starting'
    print 'In: %s' % pto_in
    print 'Out: %s' % pto_out
    bench = Benchmark()

    pto = PTOProject.from_file_name(pto_in)
    # Make sure we don't accidently override the original
    pto.remove_file_name()
    
    if args.center is True:
        center(pto)
    
    if args.anchor:
        print 'Re-finding anchor'
        center_anchor(pto)
    
    if args.basename:
        print 'Converting to basename'
        make_basename(pto)
        
    if args.hugin:
Beispiel #5
0
 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()
Beispiel #6
0
    args = parser.parse_args()

    if args.threads < 1:
        raise Exception('Bad threads')
    print 'Using %d threads' % args.threads
    
    log_dir = args.log
    out_dir = 'out'
    _dt = logwt(log_dir, 'main.log', shift_d=True)

    fn = args.pto[0]
    
    auto_size = not (args.stp or args.stm or args.stw or args.sth)
    
    print 'Assuming input %s is pto project to be stitched' % args.pto
    project = PTOProject.from_file_name(args.pto)
    print 'Creating tiler'
    stp = None
    if args.stp:
        stp = mksize(args.stp)
    elif args.stm:
        stp = mem2pix(mksize(args.stm))
        print 'Memory %s => %s pix' % (args.stm, size2str(stp))
    elif auto_size:
        stm = config.super_tile_memory()
        if stm:
            stp = mem2pix(mksize(stm))
            # having issues creating very large 
            if stp > 2**32/4:
                # 66 GB max useful as currently written
                print 'WARNING: reducing to maximum tile size'
Beispiel #7
0
        _outdate = IOTimestamp(sys, 'stdout')
        _errdate = IOTimestamp(sys, 'stderr')

    if exist:
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('\n')
        _outlog.out_fd.write('*' * 80 + '\n')
        _outlog.out_fd.write('*' * 80 + '\n')
        _outlog.out_fd.write('*' * 80 + '\n')
    print 'pr0npto starting'
    print 'In: %s' % pto_in
    print 'Out: %s' % pto_out
    bench = Benchmark()

    pto = PTOProject.from_file_name(pto_in)
    # Make sure we don't accidently override the original
    pto.remove_file_name()

    if args.center is True:
        center(pto)

    if args.anchor:
        print 'Re-finding anchor'
        center_anchor(pto)

    if args.basename:
        print 'Converting to basename'
        make_basename(pto)

    if args.hugin:
Beispiel #8
0
                   help='project to use for creating linear system (default: in)')
	parser.add_argument('--allow-missing', action="store_true", dest="allow_missing", default=False, help='Allow missing images')
	parser.add_argument('pto', metavar='.pto in', type=str, nargs=1,
                   help='project to work on')
	parser.add_argument('out', metavar='.pto out', type=str, nargs='?',
                   help='output file, default to override input')
	args = parser.parse_args()
	pto_in = args.pto[0]
	pto_out = args.out
	if pto_out is None:
		pto_out = pto_in

	print 'In: %s' % pto_in
	print 'Out: %s' % pto_out

	pto = PTOProject.from_file_name(pto_in)
	# Make sure we don't accidently override the original
	pto.remove_file_name()
	
	if args.center is True:
		center(pto)
	
	if args.anchor:
		print 'Re-finding anchor'
		center_anchor(pto)
	
	if args.basename:
		print 'Converting to basename'
		make_basename(pto)
		
	if args.hugin:
Beispiel #9
0
				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('panorama0.pto')
	project.parse()
	
	calc_centroid()
	sys.exit(1)
	
	project.regen()
	print
	print
	print
	print project.get_text()
	#project.save_as('out_reparsed.pto')
	print
	print
	print
	
Beispiel #10
0
				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()
	
	
	
	# 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)
Beispiel #11
0
'''

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
Beispiel #12
0
                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)
Beispiel #13
0
def usage():
    print 'optimizer <file in> [file out]'
    print 'If file out is not given it will be file in'

if __name__ == "__main__":
    from pr0ntools.stitch.pto.project import PTOProject

    if len(sys.argv) < 2:
        usage()
        sys.exit(1)
    file_name_in = sys.argv[1]
    if len(sys.argv) > 2:
        file_name_out = sys.argv[2]
    else:
        file_name_out = file_name_in
    
    print 'Loading raw project...'
    project = PTOProject.from_file_name(file_name_in)
    print 'Creating optimizer...'
    optimizer = PTOptimizer(project)
    #self.assertTrue(project.text != None)
    print 'Running optimizer...'
    print 'Parsed main pre-run: %s' % str(project.parsed)
    optimizer.run()
    print 'Parsed main: %d' % project.parsed
    print 'Saving...'
    project.save_as(file_name_out)
    print 'Parsed main done: %s' % str(project.parsed)

Beispiel #14
0
 def test_optimize_conversion(self):
     project = PTOProject.from_file_name('in.pto')
     pt = project.copy()
Beispiel #15
0
 def test_load(self):
     project = PTOProject.from_file_name('in.pto')
     #self.assertTrue(project.text != None)
     self.assertEqual(len(project.image_lines), 4)
Beispiel #16
0
	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()
Beispiel #17
0
    def test_load(self):
		project = PTOProject.from_file_name('in.pto')
		#self.assertTrue(project.text != None)
		self.assertEqual(len(project.image_lines), 4)
Beispiel #18
0
    def test_optimize_conversion(self):
		project = PTOProject.from_file_name('in.pto')
		pt = project.copy()
Beispiel #19
0
def usage():
    print 'optimizer <file in> [file out]'
    print 'If file out is not given it will be file in'

if __name__ == "__main__":
    from pr0ntools.stitch.pto.project import PTOProject

    if len(sys.argv) < 2:
        usage()
        sys.exit(1)
    file_name_in = sys.argv[1]
    if len(sys.argv) > 2:
        file_name_out = sys.argv[2]
    else:
        file_name_out = file_name_in
    
    print 'Loading raw project...'
    project = PTOProject.from_file_name(file_name_in)
    print 'Creating optimizer...'
    optimizer = PTOptimizer(project)
    #self.assertTrue(project.text != None)
    print 'Running optimizer...'
    print 'Parsed main pre-run: %s' % str(project.parsed)
    optimizer.run()
    print 'Parsed main: %d' % project.parsed
    print 'Saving...'
    project.save_as(file_name_out)
    print 'Parsed main done: %s' % str(project.parsed)

Beispiel #20
0
                   help='output file name (default: out.pto)')
	parser.add_argument('--allow-missing', action="store_true", dest="allow_missing", default=True, help='Allow missing images')
	parser.add_argument('--border', action="store_true", dest="border", default=False, help='Manually optimize border')
	args = parser.parse_args()
	pto_ref_fn = args.pto_ref[0]
	pto_out_fn = args.pto_out

	print 'Reference in: %s' % pto_ref_fn
	print 'Out: %s' % pto_out_fn

	# Have to start somewhere...
	pto_out = PTOProject.from_default()
	# Add the images in
	for image in args.images:
		pto_out.add_image(image)
	
	pto_ref = PTOProject.from_file_name(pto_ref_fn)
	pto_ref.remove_file_name()
	
	linear_reoptimize(pto_out, pto_ref, allow_missing=args.allow_missing, order=2, border=args.border)

	print 'Centering...'
	center(pto_out)
	
	print 'Converting to Hugin form...'
	resave_hugin(pto_out)
	
	print 'Saving to %s' % pto_out_fn
	pto_out.save_as(pto_out_fn)