[F-简易无接触温度测量与身份识别装置] F题-辽宁省-大连理工大学-简易无接触温度测量与身份识别装置

[复制链接]

1

主题

5

帖子

25

积分

一粒轻沙

Rank: 1

积分
25
楼主
查看: 2644回复: 0 发表于 2020-10-27 19:38:52   只看该作者








2020 年“TI”杯辽宁省大学生电子设计竞赛


简易无接触温度测量与身份识别装置(F 题)
【本科组】
















2020 年 10 月 13 日


摘要

简易无接触温度测量与身份识别装置通过无接触温度测量模块测量人体温度,使用MSP430f5529采集数据和处理数据,利用树莓派进行人脸识别,检测身份信息,检测是否符合防疫要求。本系统采用 MSP430f5529 完成控制,主要包含主控板模块,无接触温度测量模块,OLED 显示屏模块,人脸识别模块。
关键词:简易无接触温度测量与身份识别装置;MSP430f5529 单片机;人脸识别



Abstract

The simple non-contact temperature measurement and identification device measures the human body temperature through the non-contact temperature measurement module, uses msp430f5529 to collect and process data, uses raspberry pie for face recognition, detects identity information, and detects whether it meets the requirements of epidemic prevention. The system uses msp430f5529 to complete the control, including the main control board module, non-contact temperature measurement module, OLED display module, face recognition module.
Key word: Simple non-contact temperature measurement and identification device; msp430f5529 MCU; face recognition





目录
1系统方案        4
1.1无接触测温模块的论证与选择        4
1.2身份识别模块的论证与选择        4
2系统理论分析与计算        5
2.1温度测量原理的分析        5
2.2面部识别技术分析        5
2.3  系统整合方案分析        5
3电路与程序设计        6
3.1无接触测温主电路设计        6
3.2  测温模块程序设计        7
3.3  身份识别程序设计        7
4测试方案与结果        8
4.1  温度的测量与显示        8
4. 2  图像的采集与处理        8
4. 3  身份的识别与判断        9
4. 4  系统整体调试        9

1系统方案

本系统硬件部分主要包括 MSP430f5529 主控模块、OLED模块,MLX90614无接触测温模块、摄像头模块、树莓派模块。使用 OLED 液晶显示屏显示温度,显示身份识别状态,并通过按键控制树莓派身份学习,LED 来发出超过温度阈值报警。

1.1无接触测温模块的论证与选择
方案一:选择 MSP430 单片机控制,MLX90614模块采集。MLX90614使用红外的非接触测温,通讯方式是I2C通信协议。MSP430与MLX90614通信,在0到50摄氏度时,MLX90614的测量精度可达0.5摄氏度,满足题目要求。
方案二:线扫描测温成像,能够远程测定被测物体的表面温度。
方案三:紫外测温仪(点测温),目前主要用于国外蓝宝石炉测温,价格比较昂贵。
综合以上三种方案,考虑此场景中低功耗,稳定测温的要求,选择方案一。
1.2身份识别模块的论证与选择
方案一:采用单片机识别,但是对环境的适应性较差,人为编写程序识别图像容易因光照,环境色彩的变化而发生误判,且特征提取难度较大,在背景复杂的状况下识别更为困难。
方案二:采用open-MV模块识别,open-MV模块可进行较为复杂的面部图像处理,识别,但使用高度封装的图像处理模块,难以针对实际需要修改调整算法和参数,且open-MV摄像头型号确定,对不同光照适应性较差,性能受限。
方案三:采用彩色摄像头,使用open-CV识别,open-CV同样含有封装的图像处理函数,同时其可定制程度高,可自行修改设计。
综合以上三种方案,选择方案三。




2系统理论分析与计算


2.1温度测量原理的分析
红外测温器由光学系统、光电探测器、信号放大器和信号处理及输出等部分组成。 光学系统汇聚其视场内的目标红外辐射能量,视场的大小由测温仪的光学零件及其位置确定。红外能量聚焦在光电探测器上并转变为相应的电信号。该信号经过放大器和信号处理电路,并按照仪器内的算法和目标发射率校正后转变为被测目标的温度值。
2.2面部识别技术分析
通过摄像头获取图像,使用open-CV库处理图像,提取面部特征,确定图像位置,进一步分析处理。
提前获取需要分辨的目标图像,尽可能保证训练图片的光照条件较好,采集各个方向及角度的面部图像,加入神经网络进行训练,获取的网络模型用于识别是否为特定人物。
口罩识别采用已有模型,经过实际验证,效果稳定。

2.3 系统整合方案分析

单片机和树莓派采用串口通讯,单片机扫描发现按键被按下后向树莓派发送字符,树莓派识别到特定字符后开始采集数据,采集完成向单片机发送字符,开始训练,训练完成后再次发送信号,之后采用训练完成的模型识别摄像头图像,判断是否为目标人物,并判断是否佩戴口罩,将以上信息显示在屏幕上。
单片机测量温度,通过OLED屏显示,同时根据树莓派完成图像采集及训练的情况显示相应字符。

3电路与程序设计

3.1无接触测温主电路设计



3.2 测温模块程序设计
控制线路主控为低功耗的 MSP430f5529,测温模块为MLX90614红外的非接触测温,测温模块向MSP430传送数据,I2C通信实现温度读取,然后MSP430进行数据处理。

        3.3 身份识别程序设计
from threading import Timer
import serial
import time
import cv2
import os
from PIL import Image
import numpy as np
import pickle

def uartRead(inc):
    global readBuff
    global taskFlag
    if ser.in_waiting:
        readBuff=ser.read()
        print(readBuff)

    if readBuff==b'A':
        if taskFlag==1:
            taskFlag=0
        else:
            taskFlag=1
    elif readBuff==b'b':
        taskFlag=2
    elif readBuff==b'C':
#         if taskFlag==3:
#             taskFlag=0
#         else:
        taskFlag=3

    readBuff=0
    t = Timer(inc, uartRead,(inc,))
    t.start()

def detect_face(img):
    face_img = img.copy()
    gray = cv2.cvtColor(face_img, cv2.COLOR_BGR2GRAY)
    face_rects = face_cascade.detectMultiScale(face_img,scaleFactor=1.1, minNeighbors=5)
    for (x,y,w,h) in face_rects:
        print(x,y,w,h)
        cv2.rectangle(face_img, (x,y), (x+w,y+h), (255,255,255), 5)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = face_img[y:y+h, x:x+w]
        id_, conf = recognizer.predict(roi_gray)

        mask_face = mask_detector.detectMultiScale(gray, 1.1, 5)
        print('id', mask_face)

        if conf>=45 and conf<=85:
            print(id_)
            print(labels[id_])
            font = cv2.FONT_HERSHEY_PLAIN
            name = labels[id_]


            if list(mask_face):
                cv2.putText(face_img, str(name)+"  masked", (x-50, y-20), font, 1.5, (255, 255, 255), 2, cv2.LINE_AA)
            else:
                cv2.putText(face_img, str(name)+"  no mask", (x-50, y-20), font, 1.5, (255, 255, 255), 2, cv2.LINE_AA)

                cv2.putText(face_img, name, (x-50, y - 20), font, 1.5, (255, 255, 255), 2, cv2.LINE_AA)
        else:


            if list(mask_face):
                cv2.rectangle(face_img, (x, y), (x + w, y + h), (0, 255, 255), 5)
            else:
                cv2.rectangle(face_img, (x, y), (x + w, y + h), (0, 0, 255), 5)

        img_item = "new.png"
        cv2.imwrite(img_item, roi_color)
    return face_img

readBuff=0
taskFlag=3
try:
    portx="/dev/ttyUSB0"
    bps=115200
    timex=5
    ser=serial.Serial(portx,bps,timeout=timex)

    uartRead(0.1)

    while True:
        print(taskFlag)
        if taskFlag==1:
            capture = cv2.VideoCapture(0)
            capture.set(3,320)
            capture.set(4,240)
            imgcount = 1
        elif taskFlag==2:
            face_cascade = cv2.CascadeClassifier('cascades/data/haarcascade_frontalface_alt2.xml')
            recognizer = cv2.face.LBPHFaceRecognizer_create()
            BASE_DIR =  os.path.dirname(os.path.abspath(__file__))
            image_dir = os.path.join(BASE_DIR, "images")

            current_id = 0
            label_ids = {}
            y_labels = []
            x_train = []

            for **, dirs, files in os.walk(image_dir):
                for file in files:
                    if file.endswith("png") or file.endswith("jpg"):
                        path = os.path.join(**, file)
                        label = os.path.basename(**).replace(" ","-").lower()
                        print(label, path)
                        if not label in label_ids:
                            label_ids[label] = current_id
                            current_id +=1

                        id_ = label_ids[label]
                        print(label_ids)
                        pil_image = Image.open(path).convert("L")
                        image_array = np.array(pil_image, "uint8")
                        faces = face_cascade.detectMultiScale(image_array,scaleFactor=1.2, minNeighbors=10)

                        for(x,y,w,h) in faces:
                            roi = image_array[y:y+h, x:x+w]
                            x_train.append(roi)
                            y_labels.append(id_)

            cap = cv2.VideoCapture(0)
            cap.set(3,320)
            cap.set(4,240)

            while True:
                 ret, frame = cap.read(0)
                 frame = detect_face(frame)
                 cv2.imshow('Video Face Detection', frame)
                 key = cv2.waitKey(50)
                 if taskFlag!=3:
                     break

            cap.release()
            cv2.destroyAllWindows()

    ser.close()

except Exception as e:
    print("---异常---:",e)



4测试方案与结果

4.1 温度的测量与显示:

用水标定效果
实际温度(温度计)/℃        非接触测温温度/℃
48        48.2
40        39.7
37        36.9
35        35.2
32        31.8
28        27.5

4. 2 图像的采集与处理

程序可正常读取图像,并改变为相应尺寸存入设定的文件夹内。训练速度较快,限定时间内可训练较多图片,提高识别的稳定性及准确性
快速回复 返回顶部 返回列表