Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.

Commit 2269dfe

Browse files
dog42fmalcher
authored andcommitted
initial
0 parents  commit 2269dfe

File tree

9 files changed

+151
-0
lines changed

9 files changed

+151
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# selfie

autostart.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
echo "Egal bei welchem Wetter.....im Stecker!"
3+
#if [[ "$(cat firstrun)" == "1" ]];then
4+
#echo "0" >firstrun
5+
#sudo reboot
6+
#else
7+
#echo "1"> firstrun
8+
#fi
9+
sleep 10
10+
sudo rm /home/pi/steckerfoto/upload/*
11+
sudo sshfs [email protected]:/srv/www/fotos/html/selfi /home/pi/steckerfoto/upload -o IdentityFile=/home/pi/.ssh/id_rsa
12+
cd /home/pi/steckerfoto && sudo python photobooth.py &

steckerfoto/0_.png

36.7 KB
Loading

steckerfoto/1_.png

25 KB
Loading

steckerfoto/2_.png

28.3 KB
Loading

steckerfoto/3_.png

28.7 KB
Loading

steckerfoto/logo.png

65.8 KB
Loading

steckerfoto/photobooth.py

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
##Fotoautomat mit Raspberry Pi
2+
#Make 1/15
3+
#
4+
5+
import RPi.GPIO as IO
6+
import time
7+
import picamera
8+
from os.path import basename, splitext
9+
import sys
10+
import getopt
11+
import ftplib
12+
import PIL.Image
13+
import PIL.ImageEnhance
14+
from PIL import Image
15+
import pygame
16+
17+
18+
fuser='pi2'
19+
key='a'
20+
secret='hier bitte eigene Dateneintragen'
21+
list=['3_', '2_', '1_', '0_']
22+
23+
24+
def shot():
25+
Zeit= time.ctime(time.time())
26+
Zeit= Zeit.replace(" ", "_")
27+
Zeit= Zeit.replace(":", "")
28+
Datei="./upload/stecker" + Zeit+ ".jpg"
29+
30+
for i in list:
31+
32+
nmbr = Image.open('./' + i + '.png')
33+
size = Image.new('RGB', ( ((nmbr.size[0] + 31) // 32) * 32, ((nmbr.size[1] + 15) // 16) * 16, ) )
34+
size.paste(nmbr, (0, 0))
35+
c = PiCam.add_overlay(size.tostring(), size=nmbr.size)
36+
c.alpha = 100
37+
c.layer = 3
38+
time.sleep(1)
39+
PiCam.remove_overlay(c)
40+
41+
print "Aufnahme"
42+
PiCam.capture(Datei)
43+
44+
# Load the arbitrarily sized image
45+
img = Image.open(Datei)
46+
# Create an image padded to the required size with
47+
# mode 'RGB'
48+
pad = Image.new('RGB', ( ((img.size[0] + 31) // 32) * 32, ((img.size[1] + 15) // 16) * 16, ) )
49+
# Paste the original image into the padded one
50+
pad.paste(img, (0, 0))
51+
# Add the overlay with the padded image as the source,
52+
# but the original image's dimensions
53+
54+
PiCam.annotate_text=""
55+
56+
o = PiCam.add_overlay(pad.tostring(), size=img.size)
57+
# By default, the overlay is in layer 0, beneath the
58+
# preview (which defaults to layer 2). Here we make
59+
# the new overlay semi-transparent, then move it above
60+
# the preview
61+
o.alpha = 255
62+
o.layer = 3
63+
64+
65+
bild = PIL.Image.open(Datei)
66+
logo = PIL.Image.open('./logo.png')
67+
logo = logo.resize((170, 60), Image.ANTIALIAS)
68+
brightness = 0.8
69+
logo = PIL.ImageEnhance.Brightness(logo).enhance(brightness)
70+
pos = (10,680)
71+
bild = bild.transpose(Image.FLIP_LEFT_RIGHT)
72+
bild.paste(logo, pos, mask=logo)
73+
#mask=logo for logo tranzperance
74+
#bild.alpha_composite(logo,bild)
75+
bild.save(Datei)
76+
t = splitext(basename(Datei))[0]
77+
78+
79+
80+
# PiCam.stop_preview()
81+
# PiCam.preview_fullscreen= True
82+
# PiCam.start_preview()
83+
# print "Auf Flicker hochladen..."
84+
# response=flickr.upload(filename=Datei, title=t, is_public=1, format='etree')
85+
# photoID = response.find('photoid').text
86+
# photoURL = 'http://www.flickr.com/photos/%s/%s/' % (fuser, photoID)
87+
# print "Fertig"
88+
time.sleep(8)
89+
PiCam.remove_overlay(o)
90+
91+
92+
#flickr = FlickrAPI(key, secret)
93+
#(token, frob) = flickr.get_token_part_one(perms='write')
94+
95+
#if not token:
96+
# raw_input("Bitte Anwendung im Browser autorisieren und dann ENTER druecken")
97+
#flickr.get_token_part_two((token, frob))
98+
pygame.init()
99+
PiCam = picamera.PiCamera()
100+
PiCam.preview_fullscreen= True
101+
PiCam.resolution=(1024, 768)
102+
PiCam.hflip=True
103+
PiCam.preview_window = (1, 1 , 800, 600)
104+
PiCam.annotate_text_size=160
105+
#PiCam.annotate_background=picamera.Color('red')
106+
PiCam.start_preview()
107+
108+
PiCam.iso=0
109+
PiCam.video_stabilization=True
110+
#PiCam.exposure_mode="auto"
111+
PiCam.exposure_compensation=5
112+
#PiCam.awb_mode="flash"
113+
#myftp=ftplib.FTP("")
114+
#myftp.login("","");
115+
#dir="/selfi"
116+
#myftp.cwd(dir)
117+
IO.setwarnings(False)
118+
IO.setmode(IO.BCM)
119+
Taster = 24
120+
IO.setup(Taster, IO.IN, pull_up_down=IO.PUD_DOWN)
121+
finished = False
122+
123+
while not finished:
124+
#if(IO.input(Taster)):
125+
# print "Startffe Fullscreen-Vorschau"
126+
# PiCam.stop_preview()
127+
# PiCam.preview_fullscreen= True
128+
# PiCam.start_preview()
129+
# time.sleep(1)
130+
131+
while not IO.input(Taster):
132+
pygame.event.get()
133+
pass
134+
time.sleep(0.05)
135+
if IO.input(Taster):
136+
shot()
137+
print "Stecker-selfi: push the button!"
138+

steckerfoto/test.png

2.66 MB
Loading

0 commit comments

Comments
 (0)