# 基于人脸识别的图书馆智能台灯 **Repository Path**: HKQQSNHDZX/lamp ## Basic Information - **Project Name**: 基于人脸识别的图书馆智能台灯 - **Description**: 一款能实现“人来开灯,人走关灯”的智能台灯 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-08 - **Last Updated**: 2024-03-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: scratch, 创新作品 ## README # 基于人脸识别的图书馆智能台灯 ## 简要介绍 这是一款可以实现“人来开灯,人走关灯”的效果,适用于图书馆(或家中)的智能台灯。 ## 技术层面 ### 编程软件 使用 **Mind+** 进行编程 ### 使用硬件 #### 二哈摄像头 ![输入图片说明](%E4%BA%8C%E5%93%88%E6%91%84%E5%83%8F%E5%A4%B4.png) #### 掌控版 ![输入图片说明](%E6%8E%8C%E6%8E%A7%E6%9D%BF.PNG) #### LED灯板 ### 程序流程 ![输入图片说明](%E6%B5%81%E7%A8%8B%E5%9B%BE.png) ### 产品代码 #### C ``` /*! * MindPlus * mpython * */ #include #include #include // 动态变量 volatile float mind_n_nohead; // 函数声明 void DF_GuanDeng(); // 创建对象 DFRobot_HuskyLens huskylens; IOBOX_Motor motor_ib; // 主程序开始 void setup() { mPython.begin(); mind_n_nohead = 0; display.setCursorLine(2); display.printLine("欢迎光临科技图书馆"); motor_ib.motorRun(motor_ib.M2, motor_ib.CW, 255); huskylens.beginI2CUntilSuccess(); huskylens.writeAlgorithm(ALGORITHM_FACE_RECOGNITION); } void loop() { huskylens.request(); if ((!(huskylens.readBlockCenterParameterDirect().width>40))) { display.setCursorLine(1); display.printLine("未检测到人脸"); DF_GuanDeng(); } else { display.setCursorLine(1); display.printLine("检测到人脸,开灯"); motor_ib.motorRun(motor_ib.M2, motor_ib.CW, 255); } delay(300); } // 自定义函数 void DF_GuanDeng() { mind_n_nohead = 1; for (int index = 0; index < 10; index++) { huskylens.request(); if ((mind_n_nohead==1)) { delay(500); if ((huskylens.readBlockCenterParameterDirect().width>40)) { display.setCursorLine(1); display.printLine("检测到人脸,开灯"); motor_ib.motorRun(motor_ib.M2, motor_ib.CW, 255); mind_n_nohead = 0; } } yield(); } if ((mind_n_nohead==1)) { motor_ib.motorStop(motor_ib.M2); while (!(huskylens.readBlockCenterParameterDirect().width>40)) { huskylens.request(); yield(); } display.setCursorLine(1); display.printLine("检测到人脸,开灯"); motor_ib.motorRun(motor_ib.M2, motor_ib.CW, 255); mind_n_nohead = 0; } } ``` #### 图形化: ![输入图片说明](%E5%9B%BE%E5%BD%A2%E5%8C%96%E4%BB%A3%E7%A0%81.png) ## 设计思路 ### 创意由来 很多人喜欢在图书馆读书、学习。这也导致了图书馆的人流量大,每个座位上的台灯也要经常手动开关,这样是不卫生的。因此,我开发了这一款基于人脸识别的图书馆智能台灯。这款台灯可以实现“人来开灯,人走关灯”的功能。让一个座位前有人来时,机器会自己开灯,人走后就会自动关灯。人不需要接触台灯就能开关台灯,避免因为忘记关灯而造成浪费,同时减少接触带来的健康风险。 ### 未来展望 1. 消毒桌面功能:在人离开后,对桌面进行消毒,使风险进一步降低 2. 久坐提醒功能:当用户在座位前做了太久的时间,提醒用户站起来活动活动。 3. 护眼功能:使用更加护眼的灯板、根据环境光调整亮度等等。保护用户的眼睛。 ## 开发中的问题及解决方法 ### 供电不足 #### 问题描述 将电源插到扩展板上,灯板因分配到的电量不足而闪烁 #### 解决方式 使用分线器将摄像头与其他两个东西分开供电 ## 参考资料 1. https://mc.dfrobot.com.cn/