Commit 057ebdbb authored by Michael Murtaugh's avatar Michael Murtaugh

info on shutdown button

parent fd56933d
venv/
images/
Adafruit_Thermal.pyc simplephotobooth.pyc
......@@ -7,3 +7,32 @@
<https://github.com/adafruit/Python-Thermal-Printer/blob/master/Adafruit_Thermal.py>
Hardware setup
-------------------
Using the "BCM" pin ordering
Pins 1 + 2 are the top pins when viewing pi sd card up / usb ports down -- gpio pins on the top right of profile.
Wiring
=============
Shutdown Button
-----------------
Pins 14 & 16 (7th & 8th in case-side) (gnd + gpio23)
in boot/config.txt
dtoverlay=gpio-shutdown,gpio_pin=23
Flash on Pi
--------------
GPIO -Purple -- Pin7: GPIO4
GND Gray --- Pin 6 : Ground
GND White? -- not connected
5V -- Black -- Pin 2: 5V
Button
-----------
35 Yellow GPIO19
37 Green GPIO26
39 Blue GND
(button 2 is purple, gray, white ipv yellow green blue)
from simplephotobooth import get_faces
import argparse
import numpy, cv2
from PIL import Image, ImageOps, ImageEnhance
import os
ap = argparse.ArgumentParser("")
ap.add_argument("image")
args = ap.parse_args()
face_cascade = cv2.CascadeClassifier(os.path.join("./models", 'haarcascade_frontalface_default.xml'))
im = Image.open(args.image).convert("RGB")
image_bgr = im
im_bgr = cv2.cvtColor(numpy.array(im), cv2.COLOR_RGB2BGR)
faces = get_faces(face_cascade, im_bgr)
print (len(faces), "faces")
def fit_size (im, box):
bw, bh = box
iw, ih = im.size
w = bw
h = int((ih/iw) * w)
if h <= bh:
return (w, h)
h = bh
w = int((iw/ih) * h)
return (w, h)
def make_print_version(im):
im = im.convert("L")
rw, rh = fit_size(im, (384, 10000))
im = im.resize((rw, rh), resample=Image.BICUBIC) # Image.BICUBIC
im = ImageOps.autocontrast(im, 5)
im = ImageEnhance.Contrast(im).enhance(2.0)
# im = ImageOps.equalize(im)
im = im.convert("1")
return im
for i, face in enumerate(faces):
x, y, width, height = face['x'], face['y'], face['width'], face['height']
x1, y1, x2, y2 = x, y, x+width, y+height
current_face_bgr = im_bgr[y1:y2, x1:x2]
fname = os.path.join("face{0}.jpg".format(i))
current_face_pil = Image.fromarray(cv2.cvtColor(current_face_bgr,cv2.COLOR_BGR2RGB))
# current_face_pil = make_print_version(current_face_pil)
current_face_pil.save(fname)
fname = os.path.join("face{0}.print.jpg".format(i))
make_print_version(current_face_pil).save(fname)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment