Giter Site home page Giter Site logo

ihc-accesibility's Introduction

Práctica IHC: Paradigmas de Interacción

Reconocimiento de voz || Speech Recognition

image

  • El código funciona con el webkit Speech Recognition image

  • Acepta los siguientes comandos para moverse image

  • Mostrará el comando ingresado en este apartado:

    • image
    • En caso de ser érroneo mostrará:
      • image
  • Los comandos se irán guardando en formato de lista dejando en primer lugar al último comando dicho por el usuario:

    • image

Reconocimiento gestual || python

Usa la misma interfaz de arriba pero ahora con el uso del lenguaje python

Librerías

import cv2
import numpy as np
import pygame
import sys
  • En caso de no tenerlas usar:

cv2

pip install opencv-python

numpy

pip install numpy

pygame

pip install pygame

Variables de entorno

# Configuración de la pantalla
SCREEN_WIDTH = 300
SCREEN_HEIGHT = 300
GRID_SIZE = 3
CELL_SIZE = SCREEN_WIDTH // GRID_SIZE
BALL_RADIUS = CELL_SIZE // 2

# Colores
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)

Función que dibuja la cuadrícula y el círculo

def draw_grid_and_ball():
    screen.fill(WHITE)

    for x in range(GRID_SIZE):
        for y in range(GRID_SIZE):
            pygame.draw.rect(screen, BLACK, (x * CELL_SIZE, y * CELL_SIZE, CELL_SIZE, CELL_SIZE), 1)

    pygame.draw.circle(screen, RED, (ball_x * CELL_SIZE + CELL_SIZE // 2, ball_y * CELL_SIZE + CELL_SIZE // 2), BALL_RADIUS)

Clasificador de Rostros de OpenCV

face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')

Ciclo de ejecución

while True:
    ret, frame = cap.read()
    if not ret:
        break

    # Voltear el fotograma horizontalmente para que sea como un espejo
    frame = cv2.flip(frame, 1)

    # Obtener el tamaño del fotograma
    frame_height, frame_width, _ = frame.shape

    # Dibujar la cuadrícula y la pelota en Pygame
    draw_grid_and_ball()

    # Mostrar la pantalla de Pygame
    pygame.display.flip()

    # Convertir el fotograma a escala de grises para la detección de rostros
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    # Detectar rostros en el fotograma
    faces = face_cascade.detectMultiScale(gray, scaleFactor=1.3, minNeighbors=5, minSize=(30, 30))

    if len(faces) > 0:
        # Tomar la posición del primer rostro detectado
        (x, y, w, h) = faces[0]

        # Calcular la posición del centro del rostro
        face_center_x = x + w // 2
        face_center_y = y + h // 2

        # Actualizar la posición de la pelota en función del centro del rostro
        ball_x = int((face_center_x / frame_width) * GRID_SIZE)
        ball_y = int((face_center_y / frame_height) * GRID_SIZE)

    # Mostrar el fotograma de la cámara con la detección de rostro
    cv2.imshow("Face Detection", frame)

    # Salir del bucle si se presiona la tecla 'q'
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

ihc-accesibility's People

Contributors

guada8a avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.