markers.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 #This script generates a pdf-file of a checkerboard marker
00004 #Usage: ./markers <size in cm> <width x height>
00005 #
00006 #Example: ./markers 1.0 4x6 
00007 #         -> generates a pdf with 4x6 squares with a width of 1cm
00008 
00009 import sys
00010 import os
00011 import Image,ImageDraw,ImageFont,ImageChops
00012 
00013 print sys.argv[1]
00014 print sys.argv[2]
00015 
00016 s = float(sys.argv[1])
00017 for n in sys.argv[2:]:
00018   w,h = n.split("x")
00019   w = int(w)
00020   h = int(h)
00021   img = Image.new("L",(w+1,h+1),1)
00022   draw = ImageDraw.Draw(img)
00023   for x in range(w+1):
00024     for y in range(h+1):
00025       c=(x+y)%2
00026      # print c
00027       draw.point( (x,y), c*255 )
00028   img.save("%s.png"%n,"PNG")
00029 
00030 with open('markers.tex', 'w') as f:
00031   f.write("""
00032         \\documentclass[a4paper,10pt]{article}\n
00033         \\usepackage{graphicx}\n
00034         \\usepackage{a4wide}\n
00035         \\usepackage{color}\n
00036         \\begin{document}\n
00037         \\tiny
00038         \\definecolor{gray}{rgb}{0.5,0.5,0.5}
00039         \\color{gray}
00040 """)
00041         
00042   for n in sys.argv[2:]:
00043     w,h = n.split("x")
00044     w = int(w)
00045     h = int(h)
00046     f.write("\\indent\\hspace{-2cm}\\includegraphics[width=%dcm]{%s}\\newline$ $\\newline %s\\vspace{2cm}\n\\newline \\newline "%((w+1)*s,n,n.replace("_","-")))
00047         
00048   f.write("\\end{document}\n")
00049 
00050 os.system("pdflatex markers")
00051 os.system("evince markers.pdf")
00052 
00053 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


checkerboard_detector2
Author(s): Rosen Diankov, Felix Endres
autogenerated on Wed Dec 26 2012 15:30:15