50浏览
查看: 50|回复: 5

[项目] 【Arduino 动手做】实现残障人对智能家居无接触便捷控制

[复制链接]
使用基于手势的创新技术,使残疾人能够对智能家居设备进行非接触式控制。

智能家居辅助系统旨在通过赋予身体残疾者独立控制家庭设备的能力来增强他们的能力。这个项目的灵感来自于我对残疾人生活的研究。我发现的一个共同主题是减少日常任务对他人的依赖的强烈愿望。
在我的研究过程中,我看到了一段视频,视频中一名截瘫男子失去了手指。在视频中,他演示了如何在病情不佳的情况下使用手机。这引起了我的共鸣,并促使我开发一种设备,可以让他和其他处于类似情况的人更轻松地使用手机。
结果是 Air Clicker——一款像手套一样贴合的可穿戴鼠标。鼠标指针沿手部方向移动,单击是通过语音命令实现的。该设备可以通过USB连接到PC、手机或平板电脑,从而扩展其跨多个平台的可用性。
为了解决依赖性问题,Air Clicker 简化了与手机和 PC 的交互,从而促进了通过这些接口控制智能家居设备。这项创新可以帮助残疾人独立执行任务,例如查看门口的人、解锁门或打开和关闭电器。

基于这个概念,我扩展了该项目,包括一个完整的智能家居系统,恰如其分地命名为 Smart Home Assist。除空气答题器外,该系统还包括三个主要组件:
门摄像头:一种门铃摄像头,可在按下按钮时捕获图像并将其发送给房主。
继电器控制器:管理各种家用电器和电子产品(例如灯泡和风扇)的设备。
UniHiker 仪表板:智能家居系统的用户界面,允许用户控制设备并查看来自摄像头的图像。

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图1

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图2

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图3


【Arduino 动手做】实现残障人对智能家居无接触便捷控制图4

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图5


【Arduino 动手做】实现残障人对智能家居无接触便捷控制图6

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图7

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图8

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图9

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图11

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图10

驴友花雕  中级技神
 楼主|

发表于 昨天 12:30

【Arduino 动手做】实现残障人对智能家居无接触便捷控制

1、空中鼠标项目代码

  1. #include <MPU6050_light.h>
  2. MPU6050 mpu(Wire);
  3. unsigned long timer = 0;
  4. #include "USB.h"
  5. #include "USBHIDMouse.h"
  6. USBHIDMouse Mouse;
  7. #include "DFRobot_DF2301Q.h"
  8. //I2C communication
  9. DFRobot_DF2301Q_I2C DF2301Q;
  10. #include <Wire.h>
  11. #define SDA 4
  12. #define SCL 5
  13. #define AD0 7
  14. #define INT 15
  15. #define LED 48
  16. #define DEBUG 1  // change to one to enable debugging
  17. #if DEBUG == 1
  18. #define debug(x) Serial.print(x)
  19. #define debugln(x) Serial.println(x)
  20. #define debugf(x, y) Serial.printf(x, y)
  21. #else
  22. #define debug(x)
  23. #define debugln(x)
  24. #define debugf(x, y)
  25. #endif
  26. void setup() {
  27.   Serial.begin(115200);
  28.   pinMode(INT, INPUT);  //int goes high when activity is detected(wakeup?)
  29.   pinMode(AD0, OUTPUT);
  30.   digitalWrite(AD0, LOW);  //sets I2C adress
  31.   delay(50);
  32.   Wire.begin(SDA, SCL);
  33.   Mouse.begin();
  34.   USB.begin();
  35.   Serial.println("Starting mouse work!");
  36.   //! Init voice recongintion module
  37.   while (!(DF2301Q.begin())) {
  38.     Serial.println("Communication with device failed, please check connection");
  39.     delay(3000);
  40.   }
  41.   delay(5000);  //<! give enough time for voice recognition module to boot
  42.   Serial.println("Voice recognition begin ok!");
  43.   Mouse.begin();
  44.   USB.begin();
  45.   /**
  46.    * @brief Set mute mode
  47.    * @param mode - Mute mode; set value 1: mute, 0: unmute
  48.    */
  49.   DF2301Q.setMuteMode(0);
  50.   /**
  51.    * @brief Set wake-up duration
  52.    * @param wakeTime - Wake-up duration (0-255)
  53.    */
  54.   DF2301Q.setWakeTime(15);
  55.   byte status = mpu.begin();
  56.   debug(F("MPU6050 status: "));
  57.   debugln(status);
  58.   while (status != 0) {}                                   // stop everything if could not connect to MPU6050
  59.   neopixelWrite(48, 255, 0, 0);                            // Red, mouse in not ready stay still
  60.   debugln(F("Calculating offsets, do not move MPU6050"));  // use rgb as indicator
  61.   delay(2000);
  62.   // mpu.upsideDownMounting = true; // uncomment this line if the MPU6050 is mounted upside-down
  63.   mpu.calcOffsets();  // gyro and accelero
  64.   debugln("Done!\n");
  65.   neopixelWrite(LED, 0, 255, 0);  // Green, meaning mouse is ready
  66. }
  67. void loop() {
  68.   mpu.update();
  69.   int x = map(mpu.getAngleX(), -90, 90, 10, -10);
  70.   int y = map(mpu.getAngleY(), -90, 90, -10, 10);
  71.   int z = map(mpu.getAngleZ(), -90, 90, -10, 10);
  72.   Mouse.move(x, y);
  73.   if ((millis() - timer) > 10) {  // print data every 10ms
  74.     debug("X : ");
  75.     debug(mpu.getAngleX());
  76.     debug(x);
  77.     debug("\tY : ");
  78.     debug(mpu.getAngleY());
  79.     debug(y);
  80.     debug("\tZ : ");
  81.     debugln(mpu.getAngleZ());
  82.     debug(z);
  83.     timer = millis();
  84.   }
  85.   uint8_t CMDID = 0;
  86.   CMDID = DF2301Q.getCMDID();
  87.   if (0 != CMDID) {
  88.     debug("CMDID = ");
  89.     Serial.println(CMDID);
  90.   }
  91.   if (6 == CMDID) {
  92.     neopixelWrite(LED, 255, 255, 0);  //purple
  93.   }
  94.   switch (CMDID) {
  95.     case 5:
  96.       Mouse.click();
  97.       debugln("left click");
  98.       neopixelWrite(LED, 0, 0, 0);
  99.       neopixelWrite(LED, 255, 255, 0);  //purple
  100.       break;
  101.     case 6:
  102.       Mouse.click(MOUSE_RIGHT);
  103.       debugln("right click");
  104.       neopixelWrite(LED, 0, 0, 0);
  105.       neopixelWrite(LED, 0, 255, 255);  // yellow
  106.       break;
  107.     case 7:
  108.       Mouse.click();
  109.       delay(500);
  110.       Mouse.click();
  111.       debugln(" double left click");
  112.       neopixelWrite(LED, 0, 0, 0);
  113.       neopixelWrite(LED, 255, 255, 0);  //purple
  114.       break;
  115.     case 8:
  116.       {
  117.         //left click hold
  118.         if (!Mouse.isPressed(MOUSE_LEFT)) {
  119.           Mouse.press(MOUSE_LEFT);
  120.           debugln("left click hold");
  121.         }
  122.         break;
  123.       }
  124.     case 9:
  125.       {
  126.         if (Mouse.isPressed(MOUSE_LEFT)) {
  127.           Mouse.release(MOUSE_LEFT);
  128.           debugln("mouse released");
  129.         }
  130.         break;
  131.       }
  132.     default:
  133.       debugln("command not mapped to any function");
  134.       break;
  135.   }
  136. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 昨天 12:34

【Arduino 动手做】实现残障人对智能家居无接触便捷控制

2、视频门铃项目代码

调试
如果 LED 不亮,则表示与服务器的连接存在问题。它可能是以下之一
相机与服务器不在同一个 WiFi 网络上
服务器未运行
用于创建网络的路由器未打开或不可用
相机在连接到路由器时遇到问题
如果 LED 亮起并且图像未发送给独行者,则相机存在问题。问题可能是以下任何一种
您使用的相机型号与我不同
如果您与我使用相同的相机,您可能在板选项中选择了错误的板。板应该 ve M5unitcam
告诉用户记下 unihiker IP 地址 为 Unihiker 智能家居的所有组件提供单独的自述文件

  1. /* Author: Pius Onyema Ndukwu
  2. code adapted from Rui santos tutorial on RandomNerd Tutorials
  3.   Rui Santos
  4.   Complete project details at:
  5.   https://RandomNerdTutorials.com/esp32-cam-http-post-php-arduino/
  6.   https://RandomNerdTutorials.com/esp32-cam-post-image-photo-server/
  7.   
  8.   Permission is hereby granted, free of charge, to any person obtaining a copy
  9.   of this software and associated documentation files.
  10.   
  11.   The above copyright notice and this permission notice shall be included in all
  12.   copies or substantial portions of the Software.
  13.   */
  14. #include <Arduino.h>
  15. #include <WiFi.h>
  16. #include "soc/soc.h"
  17. #include "soc/rtc_cntl_reg.h"
  18. #include "esp_camera.h"
  19. #include <WiFiManager.h>  // https://github.com/tzapu/WiFiManager
  20. bool connectedFlag = true;
  21. String serverName = "192.168.0.187";  // REPLACE with flask server IP ADDRESS running on unihiker
  22. String serverPath = "/upload";  // The default serverPath
  23. const int serverPort = 5001; // unihiker flask server port
  24. WiFiClient client;
  25. // board: m5unitcam
  26. // CAMERA_MODEL_M5STACK_V2_PSRAM
  27. #define PWDN_GPIO_NUM -1
  28. #define RESET_GPIO_NUM 15
  29. #define XCLK_GPIO_NUM 27
  30. #define SIOD_GPIO_NUM 22
  31. #define SIOC_GPIO_NUM 23
  32. #define Y9_GPIO_NUM 19
  33. #define Y8_GPIO_NUM 36
  34. #define Y7_GPIO_NUM 18
  35. #define Y6_GPIO_NUM 39
  36. #define Y5_GPIO_NUM 5
  37. #define Y4_GPIO_NUM 34
  38. #define Y3_GPIO_NUM 35
  39. #define Y2_GPIO_NUM 32
  40. #define VSYNC_GPIO_NUM 25
  41. #define HREF_GPIO_NUM 26
  42. #define PCLK_GPIO_NUM 21
  43. #define BELL_BUTTON 4
  44. #define LED 13
  45. void setup() {
  46.   WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
  47.   Serial.begin(115200);
  48.   WiFi.mode(WIFI_STA);
  49.   WiFiManager wm;
  50.   bool res;
  51.   // res = wm.autoConnect(); // auto generated AP name from chipid
  52.   res = wm.autoConnect("Door-cam");  // anonymous ap
  53.   //res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
  54.   camera_config_t config;
  55.   config.grab_mode = CAMERA_GRAB_LATEST; // get the latest image from the frame buffer
  56.   config.ledc_channel = LEDC_CHANNEL_0;
  57.   config.ledc_timer = LEDC_TIMER_0;
  58.   config.pin_d0 = Y2_GPIO_NUM;
  59.   config.pin_d1 = Y3_GPIO_NUM;
  60.   config.pin_d2 = Y4_GPIO_NUM;
  61.   config.pin_d3 = Y5_GPIO_NUM;
  62.   config.pin_d4 = Y6_GPIO_NUM;
  63.   config.pin_d5 = Y7_GPIO_NUM;
  64.   config.pin_d6 = Y8_GPIO_NUM;
  65.   config.pin_d7 = Y9_GPIO_NUM;
  66.   config.pin_xclk = XCLK_GPIO_NUM;
  67.   config.pin_pclk = PCLK_GPIO_NUM;
  68.   config.pin_vsync = VSYNC_GPIO_NUM;
  69.   config.pin_href = HREF_GPIO_NUM;
  70.   config.pin_sscb_sda = SIOD_GPIO_NUM;
  71.   config.pin_sscb_scl = SIOC_GPIO_NUM;
  72.   config.pin_pwdn = PWDN_GPIO_NUM;
  73.   config.pin_reset = RESET_GPIO_NUM;
  74.   config.xclk_freq_hz = 20000000;
  75.   config.pixel_format = PIXFORMAT_JPEG;
  76.   // init with high specs to pre-allocate larger buffers
  77.   if (psramFound()) {
  78.     config.frame_size = FRAMESIZE_SVGA;
  79.     config.jpeg_quality = 10;  //0-63 lower number means higher quality
  80.     config.fb_count = 2;
  81.   } else {
  82.     config.frame_size = FRAMESIZE_CIF;
  83.     config.jpeg_quality = 12;  //0-63 lower number means higher quality
  84.     config.fb_count = 1;
  85.   }
  86.   // camera init
  87.   esp_err_t err = esp_camera_init(&config);
  88.   if (err != ESP_OK) {
  89.     Serial.printf("Camera init failed with error 0x%x", err);
  90.     delay(1000);
  91.     ESP.restart();
  92.   }
  93.   sensor_t *s = esp_camera_sensor_get();
  94.   s->set_vflip(s, 1);  // flip it back
  95.                        // sendPhoto();
  96.   pinMode(BELL_BUTTON, INPUT_PULLUP);
  97.   pinMode(LED,OUTPUT);
  98.   digitalWrite(LED,1);// turn off LED, to indicate camera is not ready. LED is active low
  99.   Serial.println("connecting to Server");
  100. }
  101. void loop() {
  102.   while (!client.connect(serverName.c_str(), serverPort)) {
  103.     Serial.print(".");
  104.     digitalWrite(LED,1);// turn off LED, to indicate bot connected to server. LED is active low
  105.   }
  106.   if (connectedFlag) {
  107.     //print connection successful once
  108.     Serial.println("Connection successful!");
  109.     digitalWrite(LED,0);// turn on LED, to indicate successful connection to server. LED is active low
  110.     connectedFlag = false;
  111.   }
  112.   String head = "--doorCam\r\nContent-Disposition: form-data; name="file"; filename="door-cam.jpg"\r\nContent-Type: image/jpeg\r\n\r\n";
  113.   String tail = "\r\n--doorCam--\r\n";
  114.     if (digitalRead(BELL_BUTTON) == 0) {
  115.       String getAll;
  116.       String getBody;
  117.       camera_fb_t *fb = NULL;
  118.       fb = esp_camera_fb_get();
  119.       Serial.println("Initializing camera.");
  120.       while (!fb) {
  121.         Serial.print(".");
  122.         
  123.       }
  124.       Serial.println("Camera is ready");
  125.       digitalWrite(LED,0);// turn on LED, to indicate camera is ready. LED is active low
  126.       uint32_t imageLen = fb->len;
  127.       uint32_t extraLen = head.length() + tail.length();
  128.       uint32_t totalLen = imageLen + extraLen;
  129.       client.println("POST " + serverPath + " HTTP/1.1");
  130.       client.println("Host: " + serverName);
  131.       client.println("Content-Length: " + String(totalLen));
  132.       client.println("Content-Type: multipart/form-data; boundary=doorCam");
  133.       client.println();
  134.       client.print(head);
  135.       uint8_t *fbBuf = fb->buf;
  136.       size_t fbLen = fb->len;
  137.       for (size_t n = 0; n < fbLen; n = n + 1024) {
  138.         if (n + 1024 < fbLen) {
  139.           client.write(fbBuf, 1024);
  140.           fbBuf += 1024;
  141.         } else if (fbLen % 1024 > 0) {
  142.           size_t remainder = fbLen % 1024;
  143.           client.write(fbBuf, remainder);
  144.         }
  145.       }
  146.       client.print(tail);
  147.       esp_camera_fb_return(fb);
  148.       int timoutTimer = 10000;
  149.       long startTimer = millis();
  150.       boolean state = false;
  151.       while ((startTimer + timoutTimer) > millis()) {
  152.         Serial.print(".");
  153.         delay(100);
  154.         while (client.available()) {
  155.           char c = client.read();
  156.           if (c == '\n') {
  157.             if (getAll.length() == 0) { state = true; }
  158.             getAll = "";
  159.           } else if (c != '\r') {
  160.             getAll += String(c);
  161.           }
  162.           if (state == true) { getBody += String(c); }
  163.           startTimer = millis();
  164.         }
  165.         if (getBody.length() > 0) { break; }
  166.       }
  167.       Serial.println();
  168.       client.stop();
  169.       Serial.println(getBody);
  170.     }
  171.   
  172. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 昨天 12:37

【Arduino 动手做】实现残障人对智能家居无接触便捷控制

3、智能家居控制中心项目代码

  1. /*
  2. @brief
  3. The code receives http request from a server containing a message.
  4. based on the content of the message it turns on certain GPIO's
  5. connected to relays.
  6. */
  7. #include <WiFi.h>
  8. #include <NetworkClient.h>
  9. #include <WebServer.h>
  10. #include <ESPmDNS.h>
  11. #include <WiFiManager.h>  // https://github.com/tzapu/WiFiManager
  12. WebServer server(80);
  13. const int led = 13;
  14. const int outputs[] = { 13, 14, 27, 26, 5, 33, 32, 4 };
  15. void handleNotFound() {
  16.   digitalWrite(led, 1);
  17.   String message = "File Not Found\n\n";
  18.   message += "URI: ";
  19.   message += server.uri();
  20.   message += "\nMethod: ";
  21.   message += (server.method() == HTTP_GET) ? "GET" : "POST";
  22.   message += "\nArguments: ";
  23.   message += server.args();
  24.   message += "\n";
  25.   for (uint8_t i = 0; i < server.args(); i++) {
  26.     message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  27.   }
  28.   server.send(404, "text/plain", message);
  29. }
  30. void setup(void) {
  31.   for (int i = 0; i < 8; i++) {
  32.     pinMode(outputs[i], OUTPUT);
  33.     digitalWrite(outputs[i],1);
  34.   }
  35.   Serial.begin(115200);
  36.   WiFi.mode(WIFI_STA);
  37.   WiFiManager wm;
  38.   bool res;
  39.   // res = wm.autoConnect(); // auto generated AP name from chipid
  40.   res = wm.autoConnect("Relay Controller");  // anonymous ap
  41.                                         //res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
  42.   if (!res) {
  43.     Serial.println("Failed to connect");
  44.     // ESP.restart();
  45.   } else {
  46.     //if you get here you have connected to the WiFi
  47.     Serial.println("connected...yeey :)");
  48.   }
  49.   server.on("/pin", []() {
  50.     String response = server.arg("plain");
  51.     //Serial.println(response);
  52.     Serial.print("index: ");
  53.     Serial.println(response[0]);
  54.     Serial.print("state: ");
  55.     Serial.println(response[1]);
  56.     int pinIndex= response[0] - '0';
  57.     int pinState = response[1] - '0';
  58.     digitalWrite(outputs[pinIndex],!pinState); //<! relay is active low
  59.     server.send(200, "text/plain", "received with thanks");
  60.   });
  61.   server.onNotFound(handleNotFound);
  62.   server.begin();
  63.   Serial.println("HTTP server started");
  64. }
  65. void loop(void) {
  66.   server.handleClient();
  67.   delay(2);  //allow the cpu to switch to other tasks
  68. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 昨天 12:40

【Arduino 动手做】实现残障人对智能家居无接触便捷控制

4、UniHiker 仪表板:智能家居系统的用户界面,允许用户控制设备并查看来自摄像头的图像。

  1. from flask import Flask, request, redirect, url_for, send_from_directory
  2. import os
  3. from unihiker import GUI   # Import the package
  4. from dataclasses import dataclass
  5. import time
  6. from pinpong.board import Board, Pin, Tone  # Import the Board, Pin, and Tone modules from the pinpong.board package
  7. import requests
  8. debug = True # allows me to turn of some print functions
  9. Board().begin("UNIHIKER")  # Initialize the board, choose the board type and port number (auto-detection if not specified)
  10. gui = GUI()  # Instantiate the GUI class
  11. #esp32 node url
  12. node_url= "http://192.168.0.134/pin"
  13. @dataclass
  14. class button:
  15.     name:str     #button name
  16.     state: bool  #button state
  17.     image: gui   #button image
  18.     cor: list    #coordinate of the button
  19.         
  20. def switch_clicked(button):
  21.     gui.remove(button.image)
  22.    
  23.     if button.state:
  24.         button.image= gui.draw_image(x=button.cor[0], y=button.cor[1], w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button))
  25.         
  26.     else:
  27.         button.image= gui.draw_image(x=button.cor[0], y=button.cor[1], w=50, h=50, image='/root/my_codes/smart_home/images/power-button-on.png', onclick=lambda: switch_clicked(button))
  28.    
  29.     button.state=not button.state
  30.     data = button.name+ (str(1) if button.state else str(0))
  31.     response = requests.post(node_url, data)
  32.    
  33.    
  34.     if debug:
  35.         print(response.status_code)
  36.         print(response.text)
  37.         print(button.name,button.state)
  38. tone = Tone(Pin(Pin.P26))  # Create a Tone object with Pin.P26 for analog output
  39. tone.freq(200)  # Set the frequency to 200 for the tone playback
  40. # button are named from 0-7
  41. button1 = button(name="0",state=0,image=gui.draw_image(x=5, y=50, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button1)),cor=[5,50])
  42. button2 = button(name="1", state=0, image=gui.draw_image(x=60, y=50, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button2)),cor=[60,50])
  43. button3 = button(name="2", state=0, image=gui.draw_image(x=115, y=50, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button3)),cor=[115,50])
  44. button4 = button(name="3", state=0, image=gui.draw_image(x=170, y=50, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button4)),cor=[170,50])
  45. button5 = button(name="4", state=0, image=gui.draw_image(x=5, y=105, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button5)),cor=[5,105])
  46. button6 = button(name="5", state=0, image=gui.draw_image(x=60, y=105, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button6)),cor=[60,105])
  47. button7 = button(name="6", state=0, image=gui.draw_image(x=115, y=105, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button7)),cor=[115,105])
  48. button8 = button(name="7", state=0, image=gui.draw_image(x=170, y=105, w=50, h=50, image='/root/my_codes/smart_home/images/power-button-off.png', onclick=lambda: switch_clicked(button8)),cor=[170,105])
  49. #image of person at doorbell
  50. door_bell= gui.draw_image(x=30, y=170, w=180, h=180, image='/root/my_codes/smart_home/images/person.jpg')
  51. door_cam_text =gui.draw_text(text="Door bell",origin="center",x=130,y=300,color="#0066CC")
  52. app = Flask(__name__)
  53. # Define the folder to store uploaded files
  54. UPLOAD_FOLDER = 'uploads'
  55. if not os.path.exists(UPLOAD_FOLDER):
  56.     os.makedirs(UPLOAD_FOLDER)
  57. app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
  58. app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024  # Max upload size is 16MB
  59. @app.route('/')
  60. def index():
  61.     return '''
  62.     <!doctype html>
  63.     <title>Upload File</title>
  64.     <h1>Upload a file</h1>
  65.     <form action="/upload" method=post enctype=multipart/form-data>
  66.       <input type=file name=file>
  67.       <input type=submit value=Upload>
  68.     </form>
  69.     '''
  70. @app.route('/upload', methods=['POST'])
  71. def upload_file():
  72.     global door_bell
  73.     if 'file' not in request.files:
  74.         return 'No file part', 400
  75.     file = request.files['file']
  76.     if file.filename == '':
  77.         return 'No selected file', 400
  78.     if file:
  79.         filename = file.filename
  80.         filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
  81.         gui.remove(door_bell)
  82.         file.save(filepath)
  83.         door_bell= gui.draw_image(x=50, y=170, w=150, h=150, image=filepath)
  84.         tone.on()  # Turn on the tone output
  85.         time.sleep(1.5)  # Delay for 1.5 seconds
  86.         tone.off()  # Turn off the tone output
  87.         file.close()
  88.         os.remove(filepath)
  89.         return f'File uploaded successfully: {filename}', 200
  90. @app.route('/uploads/<filename>')
  91. def uploaded_file(filename):
  92.     return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
  93. if __name__ == '__main__':
  94.     app.run(host='0.0.0.0', port=5001, debug=True)
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 昨天 12:41

【Arduino 动手做】实现残障人对智能家居无接触便捷控制

【Arduino 动手做】通过手势识别技术,实现残障人士对智能家居的无接触式便捷控制
项目链接:https://www.hackster.io/pius4109 ... sable-people-e31e34
项目作者:皮乌斯·奥涅马·恩杜库

项目视频 :
https://www.youtube.com/watch?v=-BtSs9keBJQ
https://www.youtube.com/watch?v=kl-4lKPXUrc
项目代码:https://github.com/Pius171/Unihiker-Smart-Home

【Arduino 动手做】实现残障人对智能家居无接触便捷控制图1

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4 备案 沪公网安备31011502402448

© 2013-2025 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail