本设计无接触温度测量模块由STC89C52单片机电路+1602液晶显示电路+MLX90614ESF红外非接触温度检测电路+按键电路+蜂鸣器报警电路。
身份识别模块的选择:使用K210+NT35310液晶显示屏+OV5640摄像头模块。 K210是基于RISC-V精简指令集的一款MCU,芯片架构包含了一个神经网络硬件加速器KPU,可以高性能地进行卷积神经网络运算,可以更好地在机器视觉和听觉上发挥作用。从传统的人工设计特征加浅层分类器的框架,到基于深度学习的端到端的检测框架。通过创建被识别对象(参赛队3名队员,以及口罩防疫识别)的数据集,之后进行深度学习及算法训练。
main.c
#include
#include
#include
#include "delay.h"
#include "1602.h"
#include "mlx90614.h"
sbit buzzer=P1^0;
sbit key1=P2^0;
sbit key2=P2^1;
unsigned long time_20ms;
char dis0[16];
char dis1[16];
unsigned int setNum = 37;
bit rekey =0;
bit disFlag =0;
unsigned int Tem;
float objTemp,envTemp;
void Init_Timer0(void);
void main (void)
{
Init_Timer0();
LCD_Init();
DelayMs(20);
LCD_Clear();
while (1)
{
if(disFlag==1)
{
Tem=ReadObjectTemp();
objTemp=(float)(Tem)*0.02-273.15;
Tem=ReadEnvironTemp();
envTemp=(float)(Tem)*0.02-273.15;
sprintf(dis0,"E: %4.1f'C ",envTemp);
LCD_Write_String(0,0,dis0);
sprintf(dis1,"O:%5.1f'C %3d ",objTemp,setNum);
LCD_Write_String(0,1,dis1);
if(objTemp>setNum)
{buzzer =0; }
else
{buzzer=1;}
disFlag = 0;
}
if((key1 == 0)||(key2 == 0))
{
if(rekey == 0)
{
DelayMs(10);
if(key1 == 0)
{
rekey =1;
if(setNum<200) setNum++;
}
else if((key2 == 0))
{
rekey =1;
if(setNum>0) setNum--;
}
}
}
else
{
rekey = 0;
}
}
}
void Init_Timer0(void)
{
TMOD |= 0x01;
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
EA=1;
ET0=1;
TR0=1;
}
void Timer0_isr(void) interrupt 1
{
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
time_20ms++;
if(time_20ms%20==0)
{disFlag = 1;}
}
代码块
kpu_image.pixel = 3;
kpu_image.width = 320;
kpu_image.height = 240;
image_init(&kpu_image);
display_image.pixel = 2; //2->3 LIUSEN
display_image.width = 320;
display_image.height = 240;
image_init(&display_image);
crop_image.pixel = 3;
crop_image.width = 224;
crop_image.height = 224;
image_init(&crop_image);
//存放AI图像的地址,供AI模块进行算法处理(红色、绿色、蓝色/分量地址)
dvp_set_ai_addr((uint32_t)kpu_image.addr, (uint32_t)(kpu_image.addr + 320 * 240), (uint32_t)(kpu_image.addr + 320 * 240 * 2));
//设置采集图像在内存中的存放地址,可以用来显示
dvp_set_display_addr((uint32_t)display_image.addr);
//图像开始采集中断| 图像结束采集中断
dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 0);
//禁用自动接收图像模式
dvp_disable_auto();
/* DVP interrupt config */
printf("DVP interrupt config\n");
plic_set_priority(IRQN_DVP_INTERRUPT, 1); //设置中断优先级
plic_irq_register(IRQN_DVP_INTERRUPT, dvp_irq, NULL); //注册外部中断函数
plic_irq_enable(IRQN_DVP_INTERRUPT); //使能外部中断
/* init model */
//加载 kmodel,需要与 nncase 配合使用
if (kpu_load_kmodel(&task1, model_data) != 0)
{
printf("Cannot load kmodel.\n");
exit(-1);
}
sysctl_enable_irq();
/* system start */
printf("System start\n");
while (1)
{
g_dvp_finish_flag = 0;
dvp_clear_interrupt(DVP_STS_FRAME_START | DVP_STS_FRAME_FINISH);
dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 1);
while (g_dvp_finish_flag == 0)
;
image_crop(&kpu_image, &crop_image, 48, 8);
g_ai_done_flag = 0;
if (kpu_run_kmodel(&task1, crop_image.addr, DMAC_CHANNEL5, ai_done, NULL) != 0)
{
printf("Cannot run kmodel.\n");
exit(-1);
}
while (!g_ai_done_flag);
float *features;
size_t output_size;
// 获取 KPU 最终处理的结果 KPU任务句柄 结果的索引值 结果 大小(字节)
kpu_get_output(&task1, 0, &features, &output_size);
size_t cls = argmax(features, 2);
const char *text = NULL;
//{'cat': 0, 'dog': 1},
switch (cls)
{
case 0:
text = "people1";
break;
case 1:
text = "people2";
break;
case 2:
text = "people3";
break;
}
/* display pic*/
if (features[cls] > PROB_THRESH)
ram_draw_string(display_image.addr, 150, 20, text, RED);
lcd_draw_picture(0, 0, 320, 240, (uint32_t *)display_image.addr);
}
}
资源链接!!!https://download.csdn.net/download/wangshuqian1314/85206253