Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 version. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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
print("Done.")
print("Already generated:", pdf_file)