一个基于python和pcduino的智慧校园系统,本着开(zhuang)源(bi)的精神可以用来借鉴。233。

运行在pcduino上的,需要搭配一些元件。

在程序的函数里已经写的很详细了。结合硬件,里面可以实现在线人脸识别,火灾警报,太阳能充电控制,雨水收集灌溉,大屏幕控制,上放学语音灯控等功能。

p.s.上学铃声是个双和弦的《小星星》,虽然歌很简单,但是写死我了-_-

至于像analog_read,digital_write,digital_read一类的函数还是需要根据嵌入设备型号自己写的。

这个小程序是今天3月份全国创客竞赛初中组特等奖的作品。个人觉得由此可见初中创客学生水平低下。勿喷。

#!/usr/bin/python2.6
# -*- coding:utf-8 -*-
#--------------UTF-8!!!!!!-------------
from pcduino import *
import time
import numpy as np
import cv2
import Image
import sys
import os
#import os.system
import datetime
import time
import random
import string# Definitions of musical notes:-----------------
ISOTIME = '%Y-%m-%d %X'
Z = 261.9
X = 293.7
C = 329.6
V = 349.2
B = 392.0
N = 440
M = 493.9
A = 523.3
S = 587.3
D = 659.3
F = 698.5
G = 784
H = 880
J = 987.5
Q = 1047
W = 1175
E = 1319
R = 1397
T = 1568
Y = 1760
U = 1970
X = 0
#muse_dict ={'.1'=261.9,'.2'=293.7,'.3'=329.6,'.4'=349.2,'.5'=392.0,'.6'=440,'.7'=493.9,'1'=523.3,'2'=587.3,'3'=659.3,'4'=698.5,'5'=784,'6'=880,'7'=987.5,'1.'=1047,'2.'=1175,'3.'=1319,'4.'=1397,'5.'=1568,'6.'=1760,'7.'=1970}
def f(x): return muse_dict[x];#definitions over。----------------------.
tempthreshold = 38
smokethreshold = 300nums = string.digits
cam = cv2.VideoCapture(0)
#facedetection.-----------------.
IMAGE_FR = "FACE" # frontal name...
_CONTENT_TYPES = { 'image/png': '.png', 'image/gif': '.gif','image/jpeg':'.jpg', 'image/jpeg': '.jpeg' }  #supporting types dictionary#def lenIM(text):
#    n = 0
#    for i in text:
#        if i not in ' \n!"#$%^&*?/.:;[\\]@_-|`~'
#            n ++
#        return n
def sound(muse,port=5,times=0.5,volume=8):if muse != 0:pin_mode(port,PWM)    #sound a note
        pwm_set(port,volume,muse)pwm_enable(port)time.sleep(times)else:time.sleep(times)def Soil(port = 4):return analog_read(port) >= 100#def dualsound(musea,museb,porta=5,portb=6,times=0.5):
#    pin_mode(porta,pwm)
#    pin_mode(portb,pwm)
#    pwm_set(porta,8,musea)
#    pwm_set(portb,5,museb)
#    pwm_enable(porta)
#    pwm_enable(portb)
#    time.sleep(times)def dualsound(musea,museb,porta,portb,time=0.5):sound(musea,porta,0.1,8)sound(museb,portb,time,4)pwm_disable(porta)pwm_disable(portb)def mute():pwm_disable(5)pwm_disable(6)def clear():for i in range(1,10):    #clear all
        pin_mode(i,0)digital_write(i,0)pwm_disable(5)def readWater(port=1):return analog_read(port) >= 2000    #if there is water and how deep?def readHumid(port=5):#found a question!!!!the port is definitly not this(5).pin_mode(port,INPUT)    #if there is waterreturn "question!!!"def readSmoke(port=1):return analog_read(port) >= smokethreshold    #if the voltage of sensor is smaller than 300def changedirection(normal = 1,porta=1,portb=0):pin_mode(porta,OUTPUT)pin_mode(portb,OUTPUT)if normal == 0:digital_write(portb,LOW)digital_write(porta,LOW)elif normal == 1:digital_write(portb,HIGH)digital_write(porta,LOW)elif normal == 2:digital_write(porta,HIGH)digital_write(portb,LOW)def readTemp(port=3):return analog_read(port)/10def LightCtrl(state,port=10):pin_mode(port,OUTPUT)if state == True:digital_write(port,HIGH)else:digital_write(port,LOW)def cls(): # clear screentemp = os.system('clear')def mediumprint(strs): ad = strsif len(ad) >= 57:print 'an error occured:string length mismatch.'total = 57 beginpoint = (total-len(ad))/2print beginpoint*' ',strs def ScreenCali(str=None): timecur = time.strftime(ISOTIME,time.localtime())mediumprint('HHHHHHHHHHHHHHHH')mediumprint(timecur)#temp = readTemp() & ' C'#mediumprint(temp)
    mediumprint(str)def ReadFile(filepath):file = open(filepath)try:tempa = file.read()finally:file.close()return tempadef WaterPump(open,port=2):pin_mode(port,OUTPUT)if open:digital_write(port,HIGH)else:digital_write(port,LOW)
def check(a):try:f = float(a)except ValueError:return Falsereturn Truedef facecomp(): # face recognization#print 'start!'cmd = 'curl -X POST "https://api-cn.faceplusplus.com/facepp/v3/compare" -F "api_key=jb0zKEEB2jiG2GMNt29Gej-GxNTPbeCM" -F "api_secret=5AHULy15PjagzVvnHLUa2ouVJpWCPHMZ" -F "face_token1=f216f8b56678831f6dc5720ae10f341f" -F "image_file2=@photo.jpg"'#print 'here is the datas!'result = os.popen( cmd ).read()print result#print result#print 'here is the splited data:'splresult = result.split(',')confidenceraw =  splresult[-1]confidencestr = confidenceraw[-7:-1]if check(confidencestr):confidence = string.atof(confidencestr)else:confidence = 0print confidenceraw,confidencestr,confidence,'.'if confidence >= 70:return Trueelse:return False#-----------------START-------------
#tempb = os.system('rm /var/log/apache2/access.log')
tempb = os.system('mkdir /var/log/apache2')
tempb = os.system('cd /var/log/apache2')
tempb = os.system('touch /var/log/apache2/access.log')
tempb = os.system('/etc/init.d/apache2 restart')
cls()
waiting = True
bef = ReadFile('/var/log/apache2/access.log')
cur = befwhile waiting:time.sleep(0.5)if bef != cur  :waiting = Falsebef = curcur = ReadFile('/var/log/apache2/access.log')#notes = [E,E,E,E,D,C,C,B1,A1,A1,B1,C,E,A,A,A,A,G,F,F,E,D,D,E,F,E,F,E,G,F,E,E,D,C,C,B1,A1,B1,B1,B1,B1,C,B1,A1] #爱的罗曼史
#notes = [A]
notes = [Q,J,H,G,D,D,S,A,S,G,D,D,S,A,S,A,A,A]
#notesII = [C,G,G,G,G,G,C,G,G,G,G,C,G,G,G,G,C,A,A,A,A,D,A,A,A,A,A,B1,G,C,G,C,G,G,G,G,G,C,G,B1,G,A1,E,E,E,E,A1,E,E,E,E,F1,C,C,C,C,C2]
blinkingI = [A]
#blinkingI = [Q,X,Q,X,T,X,T,X,Y,X,Y,X,T,X,X,X,R,X,R,X,E,X,E,X,W,X,W,X,Q]
blinkingII = [A,G,D,G,A,G,D,G,A,H,F,H,A,G,D,G,M,G,S,G,A,G,D,G,M,G,S,G,A,G,D,G,A]
for i in range(0,len(blinkingI)):dualsound(blinkingI[i],blinkingII[i],5,6,0.4)clear()
curnote = 0
needtoplay = False
current = True
#thedebugworldexistence = False
tot = 0
while True: #大循环------------------------------------------.
    cls()mat = [8,5,7,2]for b in mat: #open the desired portspin_mode(b,OUTPUT) #read datas...bef = curcur = ReadFile('/var/log/apache2/access.log')
#    watercur = readWater()
#    humidcur = readHumid()tempcur = readTemp()ifsmoke = readSmoke() #read ended._, frame = cam.read()issoil = Soil()tempb = os.system('sudo rm /home/photo.jpg')cv2.imwrite('/home/photo.jpg',frame)#face = facecomp()#thedebugworldexistence = Trueif ifsmoke:changedirection(2)sound(U,volume=18)sound(T,volume=18)ScreenCali('火情发现,请学生有序撤离。')else:if tempcur >= tempthreshold:changedirection(1)else:changedirection(0)ScreenCali('浙师大附属杭州笕桥实验中学欢迎您!')if not issoil:WaterPump(True)else:WaterPump(False)tot = tot + 1if tot >= 3:tot = 0if facecomp():sound(U,volume=18)sound(T,volume=18)### --------!!!--------- ####if face != None:#    cv2.namedWindow('Image')#    cv2.imshow('Video',face)#    cv2.waitKey(0)#    cv2.destroyWindow('Video')
time.sleep(1)if cur != bef:tempb = os.system('sudo rm /home/photo.jpg')break  #found user terminated the program.
#-----while over-------------------------------------------------.
digital_write(0,HIGH)
digital_write(0,LOW)
digital_write(7,LOW)
digital_write(10,LOW)
digital_write(0,HIGH)
digital_write(1,HIGH)for a in notes: time.sleep(0.1)sound(a)clear()
LightCtrl(False)
# shutdown...

转载于:https://www.cnblogs.com/pityhero233/p/7246862.html

一个基于Python2.7的智慧校园系统相关推荐

  1. 基于JAVA智慧校园系统后端计算机毕业设计源码+系统+数据库+lw文档+部署

    基于JAVA智慧校园系统后端计算机毕业设计源码+系统+数据库+lw文档+部署 基于JAVA智慧校园系统后端计算机毕业设计源码+系统+数据库+lw文档+部署 本源码技术栈: 项目架构:B/S架构 开发语 ...

  2. 基于Springboot+Vue2前后端分离框架的智慧校园系统源码,智慧学校源码+微信小程序+人脸电子班牌

    ▶ 智慧校园开发环境: 1.使用springboot框架Java+vue2 2.数据库MySQL5.7 3.移动端小程序使用小程序原生语音开发 4.电子班牌固件安卓7.1:使用Java Android ...

  3. 基于AIOT技术的智慧校园空调集中管控系统设计与实现

    毕业论文(设计) 题 目 基于AIOT技术的智慧校园空调集中管控系统设计与实现 指导老师 XXXX 专业班级 电子商务2XXXX 姓 名 XXXX 学 号 20XXXXXXXXX 20XX年XX月XX ...

  4. (附源码)计算机毕业设计SSM智慧校园系统

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  5. 大型智慧校园系统源码 智慧校园源码 Android电子班牌源码

    一款针对中小学研发的智慧校园系统源码,智慧学校源码带电子班牌.人脸识别系统.系统有演示,可正常上线运营+正版授权. 私信了解更多! 技术架构: 后端:Java 框架:springboot 前端页面:v ...

  6. 大型智慧校园系统源码 智慧班牌 智慧安防 家校互联 智慧校园小程序源码

    一款针对中小学研发的智慧校园系统源码,智慧学校源码,系统有演示,可正常上线运营+正版授权. 技术架构: 后端:Java 框架:springboot 前端页面:vue +element-ui 小程序:小 ...

  7. android日记 设计说明,基于Android的掌上校园系统的设计与实现毕业论文.doc

    中文题目:基于Android的掌上校园系统的设计与实现 外文题目:THE DESIGN AND IMPLEMENTATION OF A HANDHELD CAMPUS SYSTEM BASED ON ...

  8. 基于Beacon技术的智慧校园解决方案

    近年来,以移动互联网.智能手机为代表的信息技术快速推广普及,对学校信息化形成了巨大的挑战,以智能终端.移动互联.物联网为代表的移动化风潮不但冲击着校园网络建设,更是扭转了信息系统建设的思路与方向.基于 ...

  9. 计算机毕业设计Java智慧校园系统前端(源码+系统+mysql数据库+lw文档)

    计算机毕业设计Java智慧校园系统前端(源码+系统+mysql数据库+lw文档) 计算机毕业设计Java智慧校园系统前端(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目架构:B/S架构 ...

最新文章

  1. 编译u-boot时候,make distclean 出现rm:无法删除,****是一个目录
  2. 女朋友存好多网上男明星的照片,我准备用python全部换成我的脸
  3. php 元素添加子元素,css,html_怎么在添加的子元素上继承父元素上已存在的子元素的属性?,css,html,javascript - phpStudy...
  4. shell实例第10讲:判断用户输入的是否为数字
  5. javaScript设计模式---(单例模式学习)
  6. 关于WM_NCHITTEST消息
  7. Sicily 1346. 金明的预算方案
  8. ad证书服务器在ADgroup,ACS 5.x :根据AD组成员配置示例和Authorization命令的TACACS+认证...
  9. linux 搭建go编译环境搭建,linux上搭建完整go语言vim开发环境
  10. JAVA之继承的必要性
  11. mtk6595能否运行linux,“被妖魔化”的联发科MTK6595到底如何?
  12. JAVA链表中的回文链表结构
  13. 谷歌浏览器JSON格式化插件
  14. 基于HTML+CSS+JavaScript+Bootstarp响应式健身网站(web前端期末大作业)
  15. AD域创建及加入域的办法
  16. 离线环境遇到Problems loading reference..Unable to load schema from https-解决篇
  17. 计算机排名2018全国,2018全国90所计算机专业大学排名,分为ABC三个等级
  18. 求职经验丨应届毕业生,如何找到一份程序员工作呢?
  19. svn提交怎么全选_SVN 一次性提交多个目录中文件
  20. 天啊!你居然还不知道如何防止缓存击穿?用布隆过滤器啊!!!

热门文章

  1. 本地的文件怎么放到虚拟桌面_搬新家桌面文件怎么收纳?5个便宜实用的收纳神器,你买过几个?...
  2. h3csnmp管理命令_H3C S5500V2-EI系列以太网交换机 命令参考-Release 1118-6W100_网络管理和监控命令参考_SNMP命令-新华三集团-H3C...
  3. 深度学习总结——CS231n课程深度学习(机器视觉相关)笔记整理
  4. 笔记:Matrix completion by Truncated Nuclear Norm Regularization
  5. 【模型解读】resnet中的残差连接,你确定真的看懂了?
  6. vc++6.0 同步本机时间到Internet NTP服务器 编译通过
  7. vs2005制作安装包(自动安装.net framework 2.0)(小寿原创)
  8. idea插件手动安装
  9. vue axios拦截器的封装
  10. 在浏览器上浏览vue项目,后退按钮是可以正常返回上一页的,但打包成app后,点击手机上的物理返回按钮就直接退出app回到桌面...