Manufactura industrial
Internet industrial de las cosas | Materiales industriales | Mantenimiento y reparación de equipos | Programación industrial |
home  MfgRobots >> Manufactura industrial >  >> Manufacturing Technology >> Proceso de manufactura

Cámara con Seguimiento Facial DIY Alimentada por Arduino UNO

Componentes y Suministros

Componente Cantidad
Arduino UNO 1
Webcam 1
Goma elástica 1
Fuente de alimentación 9V 1A 1
Servos MG-90s 2
Conector jack 2.1x5.5mm 1
Regulador lineal 7805 1
Tornillos autorroscantes M2x10mm 15
Clip de papel 1
Kit de cable 22 AWG 1
Header de pines 1
LED 5mm Rojo 1
LED 5mm Verde 1
LED 5mm Amarillo 1
Resistencia 220 ohm 3
Tubo termorretráctil 1

Herramientas y Máquinas Necesarias

Aplicaciones y Servicios en Línea

Sobre este Proyecto

Hace unos meses, el autor modeló e imprimió en 3D la cabeza de un compañero por diversión. Decidió llevar la broma más allá construyendo un mecanismo para que la cabeza detectara personas y las siguiera con la mirada mientras se mueven por la habitación.

Al tener dificultades para hacer el mecanismo lo suficientemente pequeño para la impresión 3D, optó por crear un modelo fácil de ensamblar con software fácil de usar para que todos puedan disfrutarlo y mejorarlo.

¿Cómo Funciona?

La cámara se mueve mediante dos servos controlados por un Arduino Uno. La cámara se conecta a un PC donde un software (Python) detecta rostros en las imágenes recibidas.

El software es flexible con opciones como: rangos de servo modificables, inversión de rotación de servos y control manual.

Se añadieron 3 LEDs que indican el estado de detección:

La comunicación entre Arduino y software es serial (USB). El software de detección facial fue escrito en Python y está disponible en GitHub. También hay versión ejecutable en la web del autor.

Todo lo que Necesitas

Lista completa de componentes en la sección correspondiente.

Ensamblaje

Instrucciones de montaje mecánico (ver videos del autor).

Cableado

Esquema de conexiones eléctricas (ver sección esquemáticos).

Software y Configuración

Código Arduino y software Python en GitHub: Repositorio

Código

Código Arduino

// Basado en trabajo de Robin2 en foro Arduino
// https://forum.arduino.cc/index.php?topic=225329.msg1810764#msg1810764

#include 

Servo panServo;
Servo tiltServo;

byte redledPin = 2;
byte yellowledPin = 3;
byte greenledPin = 4;

const byte buffSize = 40;
char inputBuffer[buffSize];
const char startMarker = '<';
const char endMarker = '>';
byte bytesRecvd = 0;
boolean readInProgress = false;
boolean newDataFromPC = false;

float panServoAngle = 90.0;
float tiltServoAngle = 90.0;
int LED_state = 0;

void setup() {
  Serial.begin(115200);
  panServo.attach(8);
  tiltServo.attach(9);
  pinMode(redledPin, OUTPUT);
  pinMode(yellowledPin, OUTPUT);
  pinMode(greenledPin, OUTPUT);
  
  start_sequence();
  delay(200);
  Serial.println("");
}

void loop() {
  getDataFromPC();
  replyToPC();
  moveServo();
  setLED();
}

void getDataFromPC() {
  if (Serial.available() > 0) {
    char x = Serial.read();
    if (x == endMarker) {
      readInProgress = false;
      newDataFromPC = true;
      inputBuffer[bytesRecvd] = 0;
      processData();
    }
    if (readInProgress) {
      inputBuffer[bytesRecvd] = x;
      bytesRecvd++;
      if (bytesRecvd == buffSize) bytesRecvd = buffSize - 1;
    }
    if (x == startMarker) {
      bytesRecvd = 0;
      readInProgress = true;
    }
  }
}

void processData() {
  char *strtokIndx = strtok(inputBuffer, ",");
  panServoAngle = atof(strtokIndx);
  
  strtokIndx = strtok(NULL, ",");
  tiltServoAngle = atof(strtokIndx);
  
  strtokIndx = strtok(NULL, ",");
  LED_state = atoi(strtokIndx);
}

void replyToPC() {
  if (newDataFromPC) {
    newDataFromPC = false;
    Serial.print("<");
    Serial.print(panServo.read());
    Serial.print(",");
    Serial.print(tiltServo.read());
    Serial.println(">");
  }
}

void moveServo() {
  panServo.write(panServoAngle);
  tiltServo.write(tiltServoAngle);
}

void setLED() {
  if (LED_state == 2) {        // Amarillo - detectado, no centrado
    digitalWrite(redledPin, LOW);
    digitalWrite(yellowledPin, HIGH);
    digitalWrite(greenledPin, LOW);
  } else if (LED_state == 1) { // Verde - detectado y centrado
    digitalWrite(redledPin, LOW);
    digitalWrite(yellowledPin, LOW);
    digitalWrite(greenledPin, HIGH);
  } else if (LED_state == 0) { // Rojo - sin detección
    digitalWrite(redledPin, HIGH);
    digitalWrite(yellowledPin, LOW);
    digitalWrite(greenledPin, LOW);
  } else if (LED_state == 3) { // Todos encendidos
    digitalWrite(redledPin, HIGH);
    digitalWrite(yellowledPin, HIGH);
    digitalWrite(greenledPin, HIGH);
  } else {                     // Apagados
    digitalWrite(redledPin, LOW);
    digitalWrite(yellowledPin, LOW);
    digitalWrite(greenledPin, LOW);
  }
}

void start_sequence() {
  panServo.write(90);
  tiltServo.write(90);
  delay(300);
  digitalWrite(redledPin, HIGH); delay(100);
  digitalWrite(redledPin, LOW); digitalWrite(yellowledPin, HIGH); delay(100);
  digitalWrite(yellowledPin, LOW); digitalWrite(greenledPin, HIGH); delay(100);
  digitalWrite(redledPin, LOW); digitalWrite(yellowledPin, LOW); digitalWrite(greenledPin, LOW); delay(100);
  digitalWrite(redledPin, HIGH); digitalWrite(yellowledPin, HIGH); digitalWrite(greenledPin, HIGH); delay(100);
  digitalWrite(redledPin, LOW); digitalWrite(yellowledPin, LOW); digitalWrite(greenledPin, LOW);
}

Software de Detección Facial

Repositorio con archivos Python y versión ejecutable: GitHub

Partes Personalizadas y Cajas

Piezas para imprimir en 3D disponibles en Thingiverse y en la web del autor: Descargar CAD

Esquemáticos

Diagrama de cableado completo disponible en el proyecto original.

Proceso de manufactura

  1. Seguimiento Facial Pan/Tilt en Tiempo Real en Raspberry Pi – Guía Práctica
  2. Tarjeta de visita PCB 4×4 Tic Tac Toe personalizada – Guía de diseño, construcción y código
  3. Sistema de Sensor de Temperatura Multiposición para Integración en Hogar Inteligente
  4. Controlador DIY para soldador 862D+ — Precisión y fiabilidad
  5. MotionSense: Detección inteligente de intrusos con Arduino y ESP8266
  6. Prevención de Incendios en Impresoras 3D: Sistema de Seguridad con Sensor Inteligente
  7. Crear un medidor IoT web con Arduino, Yaler e IFTTT
  8. Levitación magnética repulsiva con Arduino: Circuito simple y guía DIY
  9. Robot pinza controlado remotamente para manipulación de precisión
  10. Registrador de Datos de Alto Rendimiento para Globo Meteorológico con Arduino
  11. CoroFence: Detector Térmico Avanzado con Sensor PIR e Integración IoT