diff --git a/README.md b/README.md index d680de4..bf68939 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ PDF pattern generator of AprilTags and AR tags * [*PyFPDF*](https://pyfpdf.readthedocs.io/en/latest/index.html) a library for PDF document generation under Python * [*PyYAML*](https://pyyaml.org/) a full-featured YAML framework for the Python ``` -sudo pip install fpdf pyyaml +sudo pip3 install fpdf pyyaml ``` ## Usage * Configuration file [**cfg.yaml**](https://github.com/cgdsss/pattern_generator/blob/master/cfg.yaml) * Run scripts ``` - python tag.py + python3 tag.py ``` * A pdf file was generated, like [pattern.pdf](https://github.com/cgdsss/pattern_generator/blob/master/pattern.pdf) ## Resources diff --git a/tag.py b/tag.py index a07e896..9b95764 100644 --- a/tag.py +++ b/tag.py @@ -3,7 +3,7 @@ import os current_path = os.path.abspath(os.path.dirname(__file__)) -stream = file(os.path.join(current_path, 'cfg.yaml'), 'r') +stream = open(os.path.join(current_path, 'cfg.yaml'), 'r') cfg = yaml.load(stream) tag_type = cfg['tag_type'] @@ -14,17 +14,17 @@ pdf = FPDF(orientation = 'P', unit = 'cm', format=(pdf_size[0]*100.0, pdf_size[1]*100.0)) pdf.add_page() -print "Drawing: " +print("Drawing: ") for i in range(len(tags_id)): - print "--" - print "id: ", str(tags_id[i]) - print "size: {0}m".format(tags_size[i]) - print "position: {0}m, {1}m".format(tags_pose[i][0], tags_pose[i][1]) + print("--") + print("id: ", str(tags_id[i])) + print("size: {0}m".format(tags_size[i])) + print("position: {0}m, {1}m".format(tags_pose[i][0], tags_pose[i][1])) img = os.path.join(current_path, 'png/' + tag_type + "/" + str(tags_id[i]) + ".png") pdf.image(img, ((tags_pose[i][0] - tags_size[i] / 2.0) + pdf_size[0]/2.0) * 100.0, ((-tags_pose[i][1] - tags_size[i] / 2.0) + pdf_size[1]/2.0) * 100.0, tags_size[i] * 100.0, tags_size[i] * 100.0) pdf_file = os.path.join(current_path, 'pattern.pdf') pdf.output(pdf_file, 'F') -print "Done." -print "Already generated:", pdf_file \ No newline at end of file +print("Done.") +print("Already generated:", pdf_file)