回到首页 返回首页
回到顶部 回到顶部
返回上一页 返回上一页
best-icon

#物联网挑战赛#-智能教室小助手 简单

头像 阿琛 2023.05.29 132 4

项目介绍:

 

使用行空板作为主控板,通过摄像头识别二维码的方式统计作业收集情况,并将收集的结果显示在教室的大屏幕上。可以实时看到各科作业的收集情况,同时还能看到当前教室的光线亮度,噪音大小以及最新交作业的同学。实现智能教室小助手的功能。

QQ截图20230529224310.jpg

制作过程:

 

在智能作业收集助手的作品基础上,增加了行空板的物联网部分。通过物联网将数据实时与大屏联通,从而实现了将统计结果显示在大屏上的效果。

 

步骤一:打开物联网终端

image.png

 

步骤二:在网页打开物联网终端,并设定相关的主题

image.png

步骤三:为行空板连接物联网,并订阅相关主题

image.png

 

步骤四:设计大屏的显示效果,并为各模块绑定订阅数据

image.png

通过以上四步,就能够完成大屏与行空板的数据交互了,配置很简单,效果也非常棒!不仅能够将计算后的结果数据通过物联网同步到大屏,也可以把行空板监测到的实时数据同步过来,比如光线亮度和噪音等。从而实现一个智慧班级的管理功能。

 

作品演示:

 

https://m.v.qq.com/z/msite/play-short/index.html?cid=&vid=o3516r01rrq

材料清单

  • 行空板 X1
  • 摄像头 X1
代码
#  -*- coding: UTF-8 -*-

# MindPlus
# Python
import cv2
import numpy as np
from pyzbar.pyzbar import decode
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from unihiker import Audio
from unihiker import GUI
import siot
import xlrd
import math


def numberMap(x, in_min, in_max, out_min, out_max):
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min




siot.init(client_id="",server="192.168.1.4",port=1883,user="siot",password="dfrobot")
u_gui=GUI()
u_audio = Audio()
Board().begin()
siot.connect()
siot.getsubscribe(topic="siot/chinese")
siot.getsubscribe(topic="siot/math")
siot.getsubscribe(topic="siot/english")
siot.getsubscribe(topic="siot/now")
siot.getsubscribe(topic="siot/now2")
siot.getsubscribe(topic="siot/but")
siot.getsubscribe(topic="siot/light")
siot.getsubscribe(topic="siot/voice")
a=u_gui.draw_text(text="智能统计收作业系统",x=5,y=0,font_size=19, color="#000000")
stu = xlrd.open_workbook(filename="class-list.xls")
name = stu.sheet_by_index(0)
z1=u_gui.draw_text(text="",x=8,y=210,font_size=7, color="#000000")
z2=u_gui.draw_text(text="",x=8,y=230,font_size=7, color="#000000")
z3=u_gui.draw_text(text="",x=8,y=250,font_size=7, color="#000000")
zz=u_gui.draw_round_rect(x=3,y=190,w=230,h=94,r=5,width=2,color="#FFFFFF")
zz1=u_gui.fill_round_rect(x=60,y=180,w=118,h=22,r=3,color="#FFFFFF")
zz2=u_gui.draw_text(text="",x=67,y=181,font_size=11, color="#FFFFFF")
a1=u_gui.draw_image(image="1.jpg",x=8,y=185)
a2=u_gui.draw_text(text="作业写了么?",x=100,y=210,font_size=15, color="#000000")
a3=u_gui.draw_text(text="",x=90,y=240,font_size=15, color="#000000")
global chinese
global english
global math
global worklist
global namelist
namelist = []
worklist = {0}
namelist = name.col_values(0, start_rowx=1, end_rowx=name.nrows)
QuanBanZongRenShu = len(namelist)
print(namelist)
b6=u_gui.fill_round_rect(x=4,y=35,w=230,h=45,r=5,color="#FFCCCC")
b7=u_gui.fill_round_rect(x=8,y=40,w=55,h=35,r=5,color="#FF6666")
b=u_gui.draw_text(text="语文",x=11,y=40,font_size=18, color="#FFFFFF")
b1=u_gui.draw_text(text="已交0",x=70,y=40,font_size=12, color="#CC0000")
b2=u_gui.draw_text(text=(str("未交") + str(QuanBanZongRenShu)),x=130,y=40,font_size=12, color="#CC0000")
b3=u_gui.fill_round_rect(x=70,y=67,w=130,h=7,r=3,color="#FF6666")
b4=u_gui.fill_round_rect(x=70,y=67,w=0,h=7,r=3,color="#FFFFFF")
b5=u_gui.draw_text(text="0%",x=203,y=61,font_size=8, color="#CC0000")
c6=u_gui.fill_round_rect(x=4,y=85,w=230,h=45,r=5,color="#FFCC99")
c7=u_gui.fill_round_rect(x=8,y=90,w=55,h=35,r=5,color="#FF9966")
c=u_gui.draw_text(text="数学",x=11,y=90,font_size=18, color="#FFFFFF")
c1=u_gui.draw_text(text="已交0",x=70,y=90,font_size=12, color="#FF6600")
c2=u_gui.draw_text(text=(str("未交") + str(QuanBanZongRenShu)),x=130,y=90,font_size=12, color="#FF6600")
c3=u_gui.fill_round_rect(x=70,y=118,w=130,h=7,r=3,color="#FF9966")
c4=u_gui.fill_round_rect(x=70,y=118,w=0,h=7,r=3,color="#FFFFFF")
c5=u_gui.draw_text(text="0%",x=203,y=114,font_size=8, color="#FF6600")
d6=u_gui.fill_round_rect(x=4,y=135,w=230,h=45,r=5,color="#CCFFFF")
d7=u_gui.fill_round_rect(x=8,y=140,w=55,h=35,r=5,color="#33CCFF")
d=u_gui.draw_text(text="英语",x=11,y=140,font_size=18, color="#FFFFFF")
d1=u_gui.draw_text(text="已交0",x=70,y=140,font_size=12, color="#3366FF")
d2=u_gui.draw_text(text=(str("未交") + str(QuanBanZongRenShu)),x=130,y=140,font_size=12, color="#3366FF")
d3=u_gui.fill_round_rect(x=70,y=166,w=130,h=7,r=3,color="#33CCFF")
d4=u_gui.fill_round_rect(x=70,y=166,w=0,h=7,r=3,color="#FFFFFF")
d8=u_gui.draw_round_rect(x=70,y=166,w=130,h=7,r=3,width=1,color="#33CCFF")
d5=u_gui.draw_text(text="0%",x=203,y=161,font_size=8, color="#3366FF")
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
cap.set(cv2.CAP_PROP_BUFFERSIZE, 1)
while not cap.isOpened():
    continue

while True:
    siot.publish(topic="siot/voice", data=u_audio.sound_level())
    siot.publish(topic="siot/light", data=light.read())
    cv2.waitKey(10)
    qrimg_success, qrimg_src = cap.read()
    qrcode_val = decode(qrimg_src)

    if len(qrcode_val) > 0:
        for i in range(len(qrcode_val)):
            qrcode_str = qrcode_val[i][0].decode()
            point_x = qrcode_val[i][2][0]
            point_y = qrcode_val[i][2][1]
            point_w = qrcode_val[i][2][2]
            point_h = qrcode_val[i][2][3]
            point_1_x = qrcode_val[i][3][0][0]
            point_1_y = qrcode_val[i][3][0][1]
            point_2_x = qrcode_val[i][3][1][0]
            point_2_y = qrcode_val[i][3][1][1]
            point_3_x = qrcode_val[i][3][2][0]
            point_3_y = qrcode_val[i][3][2][1]
            point_4_x = qrcode_val[i][3][3][0]
            point_4_y = qrcode_val[i][3][3][1]
            cv2.rectangle(qrimg_src,(point_x,point_y),(point_x+point_w,point_y+point_h),(255,0,255),2)

            cv2.line(qrimg_src, (point_1_x, point_1_y), (point_2_x, point_2_y), (255,0,0), 2, cv2.FILLED)
            cv2.line(qrimg_src, (point_2_x, point_2_y), (point_3_x, point_3_y), (255,0,0), 2, cv2.FILLED)
            cv2.line(qrimg_src, (point_3_x, point_3_y), (point_4_x, point_4_y), (255,0,0), 2, cv2.FILLED)
            cv2.line(qrimg_src, (point_4_x, point_4_y), (point_1_x, point_1_y), (255,0,0), 2, cv2.FILLED)

            cv2.circle(qrimg_src,(point_1_x,point_1_y),5,(255,0,0),2)
            cv2.circle(qrimg_src,(point_2_x,point_2_y),5,(0,255,0),2)
            cv2.circle(qrimg_src,(point_3_x,point_3_y),5,(0,0,255),2)
            cv2.circle(qrimg_src,(point_4_x,point_4_y),5,(255,255,0),2)

            cv2.putText(qrimg_src,qrcode_str,(point_x,point_y-20),cv2.FONT_HERSHEY_COMPLEX,0.4,(0,0,255),1)

    if len(qrcode_val)>0:
        HuiFuYuanYang()
        DuQuErWeiMa = qrcode_val[1-1][0].decode()
        if (not DuQuErWeiMa in worklist):
            print(DuQuErWeiMa)
            a1.config(image="2.jpg")
            a2.config(text=(namelist[((int(float((DuQuErWeiMa[0:2])))) - 1)]))
            siot.publish(topic="siot/now", data=(namelist[((int(float((DuQuErWeiMa[0:2])))) - 1)]))
            if ((DuQuErWeiMa[2:4]).find("1")!=-1):
                a3.config(text="语文作业交啦!")
                siot.publish(topic="siot/now2", data="语文作业交啦!")
            elif ((DuQuErWeiMa[2:4]).find("2")!=-1):
                a3.config(text="数学作业交啦!")
                siot.publish(topic="siot/now2", data="数学作业交啦!")
            else:
                a3.config(text="英语作业交啦!")
                siot.publish(topic="siot/now2", data="英语作业交啦!")
        a1.config(image="1.jpg")
        a2.config(text="作业写了么?")
        a3.config(text="")
        worklist.update((str(",") + str(DuQuErWeiMa)).split(","))
        ShuXueYiJiao = 0
        YingYuYiJiao = 0
        YuWenYiJiao = 0
        for i in worklist:
            if (((str(i))[2:4]).find("01")!=-1):
                YuWenYiJiao = (YuWenYiJiao + 1)
            elif (((str(i))[2:4]).find("02")!=-1):
                ShuXueYiJiao = (ShuXueYiJiao + 1)
            elif (((str(i))[2:4]).find("03")!=-1):
                YingYuYiJiao = (YingYuYiJiao + 1)
        b1.config(text=(str("已交") + str(YuWenYiJiao)))
        c1.config(text=(str("已交") + str(ShuXueYiJiao)))
        d1.config(text=(str("已交") + str(YingYuYiJiao)))
        siot.publish(topic="siot/chinese", data=((YuWenYiJiao / QuanBanZongRenShu) * 100))
        siot.publish(topic="siot/math", data=((ShuXueYiJiao / QuanBanZongRenShu) * 100))
        siot.publish(topic="siot/english", data=((YingYuYiJiao / QuanBanZongRenShu) * 100))
        b2.config(text=(str("未交") + str((QuanBanZongRenShu - YuWenYiJiao))))
        c2.config(text=(str("未交") + str((QuanBanZongRenShu - ShuXueYiJiao))))
        d2.config(text=(str("未交") + str((QuanBanZongRenShu - YingYuYiJiao))))
        b4.config(w=(numberMap(YuWenYiJiao, 0, QuanBanZongRenShu, 0, 130)))
        c4.config(w=(numberMap(ShuXueYiJiao, 0, QuanBanZongRenShu, 0, 130)))
        d4.config(w=(numberMap(YingYuYiJiao, 0, QuanBanZongRenShu, 0, 130)))
        b5.config(text=(str((math.ceil((round((YuWenYiJiao / QuanBanZongRenShu),2) * 100)))) + str("%")))
        c5.config(text=(str((math.ceil((round((ShuXueYiJiao / QuanBanZongRenShu),2) * 100)))) + str("%")))
        d5.config(text=(str((math.ceil((round((YingYuYiJiao / QuanBanZongRenShu),2) * 100)))) + str("%")))
        if ((YuWenYiJiao == QuanBanZongRenShu) and ((ShuXueYiJiao == QuanBanZongRenShu) and (YingYuYiJiao == QuanBanZongRenShu))):
            a1.config(image="4.jpg")
            a2.config(text="作业都交齐啦!")
            a3.config(text="")

评论

user-avatar
  • 花生编程

    花生编程2023.08.02

    赞赞赞

    0
    • 花生编程

      花生编程2023.08.02

      厉害

      0
      • 三春牛-创客

        三春牛-创客2023.07.29

        赞赞赞赞

        0
        • 三春牛-创客

          三春牛-创客2023.07.29

          不错不错

          0