查看: 1742|回复: 2
收起左侧

[求助] 树莓派红外报警并拍照传到yeelink

2016-4-28 19:14:16 | 显示全部楼层 |阅读模式
import RPi.GPIO as GPIO
import time

def init():
        GPIO.setwarnings(False)
        Gpio.setmode(GPIO.BOARD)
        GPIO.setup(12,GPIO.in)
        GPIO.setup(29,GPIO.out)
        pass
def beep():
        while   GPIO.input(12):

                GPIO.output(29,GPIO.LOW)
                time.sleep(0.5)
                GPIO.output(29,GPIO.HIGH)
                time.sleep(0.5)
def detct():
        for i in range(1,101):
                if GPIO.input(12)) == True:
                        print("有人靠近!")
                        beep()
                else:
                        GPIo.output(29,GPIO.HIGH)
                        print("没有人!")
                time.sleep(2)
time.sleep(5)
init()
detct()
GPIO.cleanup()               

如果 while   GPIO.input(12):
就执行这行代码。sudo fswebcam -d /dev/ video0 -r --320x240 --bottom-banner --tittle "RaspberryPi@Yeelink" --save /home/pi/yeelink/yeelink.jpg
谁帮我看下,这个应该怎么弄


回复

使用道具 举报

2016-5-6 11:56:50 | 显示全部楼层
我猜你是想在Ptython程序调用系统命令,请参考:
http://raspberrypi.stackexchange ... o-files-with-python

简单说:
import os;
os.system('sudo fswebcam -d /dev/ video0 -r --320x240 --bottom-banner --tittle "RaspberryPi@Yeelink" --save /home/pi/yeelink/yeelink.jpg')
你试试,我用这个明白在Python里播放音频文件成功!
回复 支持 反对

使用道具 举报

2016-5-6 12:05:53 | 显示全部楼层
试试 Python 调用系统命令:
http://raspberrypi.stackexchange ... o-files-with-python

import os;
os.system('sudo fswebcam -d /dev/ video0 -r --320x240 --bottom-banner --tittle "RaspberryPi@Yeelink" --save /home/pi/yeelink/yeelink.jpg')
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热点推荐

关注我们,了解更多

官方微信

服务时间:10:00-16:00

13714503811

公司地址:深圳市龙岗区南湾街道东门头路8号

Copyright © 2012-2020 Powered by 树莓派论坛 2019.4  粤ICP备15075382号-1
快速回复 返回列表 返回顶部