Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: latin-1 -*-
- import sys
- import os
- import time
- import random
- import datetime
- import telepot
- import picamera
- import RPi.GPIO as GPIO
- from time import sleep
- from fractions import Fraction
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
- """
- Skript
- """
- def handle(msg):
- chat_id = msg['chat']['id']
- command = msg['text']
- print 'Got command: %s' % command
- if command == '/photo':
- with picamera.PiCamera() as camera:
- camera.start_preview()
- time.sleep(5)
- camera.resolution = (1024, 768)
- camera.capture('/opt/bewegung/dateien/BEWEGUNG.jpg')
- camera.stop_preview()
- bot.sendPhoto(-116762447, photo=open('dateien/BEWEGUNG.jpg', 'rb'), caption='Foto hochgeladen. Resolution: 1024x768')
- elif command == '/photo hd':
- with picamera.PiCamera() as camera:
- camera.start_preview()
- time.sleep(5)
- camera.resolution = (1920, 1080)
- camera.capture('/opt/bewegung/dateien/BEWEGUNG.jpg')
- camera.stop_preview()
- bot.sendPhoto(-116762447, photo=open('dateien/BEWEGUNG.jpg', 'rb'), caption='Foto hochgeladen. Resolution: 1920x1080')
- elif command == '/photo dunkel':
- with picamera.PiCamera() as camera:
- camera.start_preview()
- time.sleep(5)
- camera.resolution = (1920, 1080)
- # Set a framerate of 1/6fps, then set shutter
- # speed to 6s and ISO to 800
- camera.framerate = Fraction(1, 6)
- camera.shutter_speed = 6000000
- camera.exposure_mode = 'off'
- camera.iso = 800
- # Give the camera a good long time to measure AWB
- # (you may wish to use fixed AWB instead)
- sleep(10)
- # Finally, capture an image with a 6s exposure. Due
- # to mode switching on the still port, this will take
- # longer than 6 seconds
- camera.capture('/opt/bewegung/dateien/dark.jpg')
- camera.stop_preview()
- bot.sendPhoto(-116762447, photo=open('dateien/dark.jpg', 'rb'), caption='Foto hochgeladen. Shutter: 6s | ISO: 800 | Resolution: 1920x1080')
- elif command == '/video 5':
- with picamera.PiCamera() as camera:
- camera.resolution = (640, 480)
- camera.start_recording('dateien/video.h264')
- camera.wait_recording(5)
- camera.stop_recording()
- os.system('avconv -y -i "dateien/video.h264" -c:v copy "dateien/video.mp4"')
- sleep(5)
- bot.sendVideo(-116762447, open('dateien/video.mp4', 'rb'), caption='Video hochgeladen. Resolution: 640x480 | Dauer 5s', duration='5')
- bot = telepot.Bot('')
- bot.notifyOnMessage(handle)
- print 'I am listening ...'
- while 1:
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement