From 05f6963f5c410746001db41d0dcc1a1cca813bcd Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 26 Jun 2021 17:53:16 +0200 Subject: [PATCH] Initial commit --- README.md | 21 +- background.png | Bin 0 -> 8514 bytes background.svg | 553 +++++++++++++++++++++++++++++++++++++++++++++++++ tpc.py | 45 ++++ 4 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 background.png create mode 100644 background.svg create mode 100755 tpc.py diff --git a/README.md b/README.md index 2159807..ee0be46 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # Thermal-Printer-Camera -Thermal printer prints photos from Raspberry Pi camera. \ No newline at end of file +Thermal printer prints photos from Raspberry Pi camera. +Will be used on public events to show example projects and produce small give-aways for kids. + +Uses Python and esc-pos. + + +## Requirements +To install on Raspian install following dependencies: +``` +sudo apt-get install python3-pip +sudo pip3 install python-escpos +``` + +## ToDos +- [x] Working camera +- [x] Nice background picture +- [ ] Add buzzer to take picture +- [ ] Add Case for Raspberry Pi and camera +- [ ] Integrate everything into priner +- [ ] Add lighting for camera diff --git a/background.png b/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f803884408d92d07eb17e0d7293fc36630533b86 GIT binary patch literal 8514 zcmeHtc{o)6-}j+Hq)7OpLdFuIj4gYMWsIf9mc7l$zK`rmC6o$7LzbAqSj$+l3{oO{ z*6fsBmW-V-_h)|h^T+dh{(SzpultYRxh|K>nR7npbKc8qd5@?YM!M{*{HzcJu_N@Z zqacVO9Q>@aFo84jzPk^=ucMxNmOc=4{0seup~)lnJ~+wet9{GY!~^Z?f5+Pa^7r?b zadLO@xp&9YLB_+|F=bheAA*D+#Putt58o|~1_Yb-QE7j-+8YdD!X?i$SxhBj>UmvU z`a-21KRzdP^+#gk60`jU?JzS*Kew38MU>5l$Gz-dc?zS$wZep07zx@Ul2>mfsGs8y z(qcq3tL*F_=*hLeep>M4dw{y&D~gcMO667>;_Y5q(6ToSZ0~>akax8UQOe-43{ir@ z;rw4~;hD7p5R@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kWdi6Dc{V>OkVK&b)) znKazd+^kpTF>VKj^+P2N$PWT~s1NKo9ImCkU41&p9n3E}R9Dmpc>IIma<}Pzsk0?= zA|hG67h^%rKf5KmBF{YF*y~{WD;CWGK}JbTA6KSe7yn<5?R(AigwGayhct0mMj3o* w_rKuK%0RJ!ZG55sFTnqT?fn04LF?8w?cwE5ys)_dL;4yBZKLZ&S8qT5FA_+~od5s; literal 0 HcmV?d00001 diff --git a/background.svg b/background.svg new file mode 100644 index 0000000..f98dad3 --- /dev/null +++ b/background.svg @@ -0,0 +1,553 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tpc.py b/tpc.py new file mode 100755 index 0000000..62db583 --- /dev/null +++ b/tpc.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 + + +from escpos import printer +from picamera import PiCamera +from PIL import Image +from io import BytesIO +import time + +p = printer.Usb(0x0493, 0x8760, in_ep=0x81, out_ep=0x03) + + +camera = PiCamera() +camera.resolution = (284, 284) + + +def capture(width=284, height=284): + stream = BytesIO() + camera.resolution = (width, height) + camera.capture(stream, format='jpeg') + stream.seek(0) + return stream + + +def main(): + # wait for camera to initialize + sleep(1) + image = Image.open(capture(284,284)) + image.seek(0) + + background = Image.open("background.png") + foreground = Image.open("background.png") + + background.paste(image, (50,50)) + background.paste(foreground, (0, 0), foreground) + + # Optional: save image + # timestr = time.strftime("%Y%m%d-%H%M%S") + #background.save(timestr+".png", "PNG") + + p.image(background, high_density_vertical=True, high_density_horizontal=True, fragment_height=1) + + +if __name__ == '__main__': + main()