SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
ALL YOUR FACES
BELONG TO US
JORGE HIDALGO
6 DE MAYO DE 2017
OPENSOUTHCODE 2017
Reconocimiento de imágenes
con tecnologías abiertas
SOBRE MÍ
Jorge Hidalgo
@_deors
deors
https://deors.wordpress.com/
Senior Technology Architect
Global Java Lead – Accenture Technology
Custom Distributed, Architecture & DevOps Lead –
Accenture Delivery Center in Spain
Copyright © 2017 Accenture. Todos los derechos reservados. 2
• Cosas → Objetos:
• Sensores de presión en neumáticos
• Monitores de implantes coronarios
• GPS en taxis
• Termómetros en oficinas
• …
• Con un identificador único
• Conectados a Internet
• Transfieren datos sin intervención humana
• Se integran y forman parte de un sistema mayor
INTERNET DE LAS COSAS /
INTERNET OF THINGS
Copyright © 2017 Accenture. Todos los derechos reservados. 3
H
• Respuesta autónoma
• Capacidad de toma de decisiones
• Capacidad de adaptación
NECESITAMOS INTELIGENCIA
EN LAS “COSAS”
Copyright © 2017 Accenture. Todos los derechos reservados. 4Pictures from stock archive © their respective owners.
Copyright © 2017 Accenture. Todos los derechos reservados. 5
• Soluciones cerradas:
• Microsoft Computer Vision API (link)
• IBM Watson Visual Recognition (link)
• Google Cloud Vision API (link)
• Amazon Rekognition (link)
• Clarifai (link)
RECONOCIMIENTO DE IMÁGENES
• Soluciones abiertas:
• OpenCV (www.opencv.org)
• SimpleCV (simplecv.org)
• TensorFlow (www.tensorflow.org)
• AForge.Net (www.aforgenet.com)
• VLFeat.org (www.vlfeat.org)
• Point Cloud Library (PCL)
(pointclouds.org)
• Gesture Recognition Toolkit (GRT)
(www.nickgillian.com/grt)
• Desarrollada en C++
• Con interfaces para Python y Java
• Libre (licencia BSD)
• Soportada en Windows, Linux (x86 y ARM), Mac OS, iOS y Android
• Foco importante en aplicaciones de tiempo real:
• Optimizada para uso de hardware de aceleración
• Optimizada para uso de múltiples núcleos
• Última versión: 3.2.0 (diciembre de 2016)
• En GitHub: https://github.com/opencv/opencv
OPENCV LIBRARY
Copyright © 2017 Accenture. Todos los derechos reservados. 6
• Un conjunto de reglas (en formato XML)
• Se aplica a cada frame de un stream de vídeo (o a imágenes individuales)
• Detecta rasgos (features)
• Una cara humana
• Una cara de gato
• Un coche
• La forma de un árbol
• …
• OpenCV contiene un conjunto de clasificadores listos para usar
• Se pueden crear nuevos clasificadores mediante entrenamiento
CASCADE CLASSIFIER
Copyright © 2017 Accenture. Todos los derechos reservados. 7
Copyright © 2017 Accenture. Todos los derechos reservados. 8
• LBP
• Más rápido
• Cálculos sobre enteros
• La mejor opción para entornos
móviles/embebidos
CASCADE CLASSIFIER – TIPOS
• HAAR
• Más preciso
• Cálculos sobre punto flotante
• La mejor opción cuando el % de acierto
es fundamental
• Es un proceso lento
• Requiere un conjunto numeroso de imágenes con el rasgo a detectar
• Para formas rígidas (un logo), basta con unas pocas
• Para formas variables (un tipo de objeto), se necesitan cientos
• Para rasgos de seres vivos (cara, pelo, forma corporal…), se necesitan miles
• Cada imagen vendrá acompañada de las coordenadas de los rasgos
• Se enriquece la muestra de ‘positivos’ con variaciones (samples)
• Requiere un conjunto aún más numeroso de imágenes ‘negativas’
ENTRENAMIENTO EN OPENCV
Copyright © 2017 Accenture. Todos los derechos reservados. 9
• La herramienta de entrenamiento actual es opencv_traincascade
• Recibe como entradas:
• Fichero de vectores generado a partir de las imágenes ‘positivas’
• La colección de imágenes ‘negativas’
• Parámetros de configuración del algoritmo de machine learning
• Usa los positivos para formular las hipótesis y mejorarlas
• Usa los negativos para confirmar las hipótesis y mejorarlas
• El resultado final es el fichero con los datos del cascade classifier (XML)
ENTRENAMIENTO EN OPENCV
Copyright © 2017 Accenture. Todos los derechos reservados. 10
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
with PiCamera() as camera:
camera.resolution = (1920, 1080)
camera.framerate = 30
rawCapture = PiRGBArray(camera, size = (1920, 1080))
time.sleep(1)
for frame in camera.capture_continuous(rawCapture, format = "bgr", use_video_port = True):
image = frame.array
cv2.imshow("frame", image)
key = cv2.waitKey(1) & 0xFF
rawCapture.truncate(0)
if key == ord('q'):
break
OPENCV HELLO CAM! – PYTHON VERSION
Copyright © 2017 Accenture. Todos los derechos reservados. 11
org.opencv.core
• Mat
org.opencv.videoio
• VideoCapture
org.opencv.objdetect
• CascadeClassifier
OPENCV JAVA API – PRINCIPALES CLASES
org.opencv.imgproc
• Imgproc
org.opencv.imgcodecs
• Imgcodecs
DIAGRAMA DE SECUENCIA
read
VideoCapture
Mat
Imgproc
cvtColor
equalizeHist
CascadeClassifier
detectMultiScale
Imgcodecs
imwrite
new
new
rectangle
¿HECHOS UN LÍO?
Copyright © 2017 Accenture. Todos los derechos reservados. 14All pictures and clips © their respective owners.
 Bajo ancho de banda
 Bajo uso de energía
 Perfecto para IoT
 Patrón Publish / Subscribe
 Puede transportarse mediante
WebSocket
 Librerías – Eclipse IoT (link):
 Cliente – Eclipse Paho:
http://www.eclipse.org/paho/
 Broker – Eclipse Mosquitto:
http://mosquitto.org
PROTOCOLO MQTT
MQTT Broker
Topic
Device 1
publish
Device 2
Device N
subscribe
subscribe
…
ESCENARIO DE LA DEMO
…
DetectorDevices
publish
MQTT Broker Web Server
subscribe
MQTT MQTT
WS
ESCENARIO DE LA DEMO
publish subscribe
MQTT broker
DEMO TIME!
Copyright © 2017 Accenture. Todos los derechos reservados. 18Pictures from stock archive © their respective owners.
¿AUN HECHOS UN LÍO?
Copyright © 2017 Accenture. Todos los derechos reservados. 19All pictures and clips © their respective owners.
Faces Detector:
https://github.com/locoporf1/faces-detector
WebApp Monitor:
https://github.com/locoporf1/faces-detector-server
Instrucciones detalladas:
https://static.rainfocus.com/oracle/oow16/sess/1463395410
0810018DAr/ppt/JavaOne%20-%20FacesCounter.pptx
CÓDIGO FUENTE
(Kudos para Mariano Rodríguez @locoforf1)
Scala y OpenCV con Akka Streams
https://beachape.com/blog/2016/03/08/scala-and-opencv-ep-1-akka-webcam/
https://beachape.com/blog/2016/03/14/scala-and-opencv-ep-2-akka-face-detector/
Ejemplos del libro “Mastering OpenCV”
https://github.com/MasteringOpenCV/code
OTROS SITIOS INTERESANTES
PARA EMPEZAR CON OPENCV
Documentación oficial
http://docs.opencv.org/3.2.0/dc/d88/tutorial_traincascade.html
Blog de Coding Robin
http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html
Gran pregunta y mejor respuesta en el foro de OpenCV
http://answers.opencv.org/question/39160/opencv_traincascade-parameters-
explanation-image-sizes-etc/
PARA LOS VALIENTES QUE QUIERAN
ENTRENAR POKÉMON CLASIFICADORES
¿PREGUNTAS?
Copyright © 2017 Accenture. Todos los derechos reservados. 23All pictures and clips © their respective owners.
¡GRACIAS!

Más contenido relacionado

Similar a Reconocimiento facial OpenCV IoT

Commit 2018 - Integrando Microservicios y Machine Learning
Commit 2018 - Integrando Microservicios y Machine LearningCommit 2018 - Integrando Microservicios y Machine Learning
Commit 2018 - Integrando Microservicios y Machine LearningRafa Hidalgo
 
Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2Ricard Clau
 
Azure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realAzure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realSoftware Guru
 
1 la arquitectura cloud computing
1 la arquitectura cloud computing1 la arquitectura cloud computing
1 la arquitectura cloud computingOmega Peripherals
 
1 la arquitectura cloud computing
1   la arquitectura cloud computing1   la arquitectura cloud computing
1 la arquitectura cloud computingOmega Peripherals
 
Genesis Suite Server
Genesis Suite ServerGenesis Suite Server
Genesis Suite ServerLuis Lesende
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorEnrique Catala Bañuls
 
Html5 y otras yerbas
Html5 y otras yerbasHtml5 y otras yerbas
Html5 y otras yerbasPeter Concha
 
Html5 y otras yerbas
Html5 y otras yerbasHtml5 y otras yerbas
Html5 y otras yerbasAvanet
 
Aplicaciones móviles super-escalables
Aplicaciones móviles super-escalablesAplicaciones móviles super-escalables
Aplicaciones móviles super-escalablesSergio Borromei
 
Camaras Imaging Source Mexico
Camaras Imaging Source MexicoCamaras Imaging Source Mexico
Camaras Imaging Source MexicoMiguel Arias
 
GHENOVA 360 Servicios Digitales
GHENOVA 360 Servicios Digitales GHENOVA 360 Servicios Digitales
GHENOVA 360 Servicios Digitales ElenaRosalesLpez
 
Brazo Robotico de 6 grados de libertad
Brazo Robotico de 6 grados de libertadBrazo Robotico de 6 grados de libertad
Brazo Robotico de 6 grados de libertadEmerson Asto Rodriguez
 

Similar a Reconocimiento facial OpenCV IoT (20)

KeyShot Brochure
KeyShot Brochure KeyShot Brochure
KeyShot Brochure
 
Commit 2018 - Integrando Microservicios y Machine Learning
Commit 2018 - Integrando Microservicios y Machine LearningCommit 2018 - Integrando Microservicios y Machine Learning
Commit 2018 - Integrando Microservicios y Machine Learning
 
Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2Escalabilidad y alto rendimiento con Symfony2
Escalabilidad y alto rendimiento con Symfony2
 
Azure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realAzure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo real
 
1 la arquitectura cloud computing
1 la arquitectura cloud computing1 la arquitectura cloud computing
1 la arquitectura cloud computing
 
1 la arquitectura cloud computing
1   la arquitectura cloud computing1   la arquitectura cloud computing
1 la arquitectura cloud computing
 
Genesis Suite Server
Genesis Suite ServerGenesis Suite Server
Genesis Suite Server
 
Aplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidorAplicando R al análisis de rendimiento de un servidor
Aplicando R al análisis de rendimiento de un servidor
 
Arquitectura
Arquitectura Arquitectura
Arquitectura
 
Html5 y otras yerbas
Html5 y otras yerbasHtml5 y otras yerbas
Html5 y otras yerbas
 
Html5 y otras yerbas
Html5 y otras yerbasHtml5 y otras yerbas
Html5 y otras yerbas
 
Aplicaciones móviles super-escalables
Aplicaciones móviles super-escalablesAplicaciones móviles super-escalables
Aplicaciones móviles super-escalables
 
Html5 vs Flash
Html5 vs FlashHtml5 vs Flash
Html5 vs Flash
 
Camaras Imaging Source Mexico
Camaras Imaging Source MexicoCamaras Imaging Source Mexico
Camaras Imaging Source Mexico
 
NSCoder - Metal
NSCoder - MetalNSCoder - Metal
NSCoder - Metal
 
ISACA DevOps LATAM
ISACA DevOps LATAMISACA DevOps LATAM
ISACA DevOps LATAM
 
Rational software
Rational softwareRational software
Rational software
 
GHENOVA 360 Servicios Digitales
GHENOVA 360 Servicios Digitales GHENOVA 360 Servicios Digitales
GHENOVA 360 Servicios Digitales
 
Meetup Oracle Technology MAD_BCN: 6.2 DevOps y DataOps
Meetup Oracle Technology MAD_BCN: 6.2 DevOps y DataOpsMeetup Oracle Technology MAD_BCN: 6.2 DevOps y DataOps
Meetup Oracle Technology MAD_BCN: 6.2 DevOps y DataOps
 
Brazo Robotico de 6 grados de libertad
Brazo Robotico de 6 grados de libertadBrazo Robotico de 6 grados de libertad
Brazo Robotico de 6 grados de libertad
 

Más de Jorge Hidalgo

GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22Jorge Hidalgo
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18Jorge Hidalgo
 
Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Jorge Hidalgo
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28Jorge Hidalgo
 
GraalVM - MálagaJUG 2018-11-29
GraalVM - MálagaJUG 2018-11-29GraalVM - MálagaJUG 2018-11-29
GraalVM - MálagaJUG 2018-11-29Jorge Hidalgo
 
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)Jorge Hidalgo
 
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...Jorge Hidalgo
 
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...Jorge Hidalgo
 
Open Source Power Tools - Opensouthcode 2018-06-02
Open Source Power Tools - Opensouthcode 2018-06-02Open Source Power Tools - Opensouthcode 2018-06-02
Open Source Power Tools - Opensouthcode 2018-06-02Jorge Hidalgo
 
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...Jorge Hidalgo
 
JavaOne 2017 CON3276 - Selenium Testing Patterns Reloaded
JavaOne 2017 CON3276 - Selenium Testing Patterns ReloadedJavaOne 2017 CON3276 - Selenium Testing Patterns Reloaded
JavaOne 2017 CON3276 - Selenium Testing Patterns ReloadedJorge Hidalgo
 
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJorge Hidalgo
 
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)Jorge Hidalgo
 
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17Jorge Hidalgo
 
OpenSlava 2016 - Lightweight Java Architectures
OpenSlava 2016 - Lightweight Java ArchitecturesOpenSlava 2016 - Lightweight Java Architectures
OpenSlava 2016 - Lightweight Java ArchitecturesJorge Hidalgo
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJorge Hidalgo
 
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07Jorge Hidalgo
 
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost Computers
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost ComputersJavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost Computers
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost ComputersJorge Hidalgo
 
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...Jorge Hidalgo
 
Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11Jorge Hidalgo
 

Más de Jorge Hidalgo (20)

GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01Architecture 2020 - eComputing 2019-07-01
Architecture 2020 - eComputing 2019-07-01
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
GraalVM - MálagaJUG 2018-11-29
GraalVM - MálagaJUG 2018-11-29GraalVM - MálagaJUG 2018-11-29
GraalVM - MálagaJUG 2018-11-29
 
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Commit Conf 2018)
 
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...
Multilanguage Pipelines with Jenkins, Docker and Kubernetes (Oracle Code One ...
 
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...
Multilanguage pipelines with Jenkins, Docker and Kubernetes (DevOpsDays Riga ...
 
Open Source Power Tools - Opensouthcode 2018-06-02
Open Source Power Tools - Opensouthcode 2018-06-02Open Source Power Tools - Opensouthcode 2018-06-02
Open Source Power Tools - Opensouthcode 2018-06-02
 
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
JavaOne 2017 CON3282 - Code Generation with Annotation Processors: State of t...
 
JavaOne 2017 CON3276 - Selenium Testing Patterns Reloaded
JavaOne 2017 CON3276 - Selenium Testing Patterns ReloadedJavaOne 2017 CON3276 - Selenium Testing Patterns Reloaded
JavaOne 2017 CON3276 - Selenium Testing Patterns Reloaded
 
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
 
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)
Accenture Liquid Architectures (for Master EMSE UPM-FI - April 2017)
 
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17
La JVM y el Internet de las Cosas @ MálagaJUG 2016-11-17
 
OpenSlava 2016 - Lightweight Java Architectures
OpenSlava 2016 - Lightweight Java ArchitecturesOpenSlava 2016 - Lightweight Java Architectures
OpenSlava 2016 - Lightweight Java Architectures
 
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A CookbookJavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
JavaOne 2016 - CON3080 - Testing Java Web Applications with Selenium: A Cookbook
 
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
 
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost Computers
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost ComputersJavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost Computers
JavaOne 2015 - CON6489 - Smart Open Spaces Powered by Low Cost Computers
 
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
JavaOne 2014 - CON2013 - Code Generation in the Java Compiler: Annotation Pro...
 
Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11Next-gen IDE v2 - OpenSlava 2013-10-11
Next-gen IDE v2 - OpenSlava 2013-10-11
 

Reconocimiento facial OpenCV IoT

  • 1. ALL YOUR FACES BELONG TO US JORGE HIDALGO 6 DE MAYO DE 2017 OPENSOUTHCODE 2017 Reconocimiento de imágenes con tecnologías abiertas
  • 2. SOBRE MÍ Jorge Hidalgo @_deors deors https://deors.wordpress.com/ Senior Technology Architect Global Java Lead – Accenture Technology Custom Distributed, Architecture & DevOps Lead – Accenture Delivery Center in Spain Copyright © 2017 Accenture. Todos los derechos reservados. 2
  • 3. • Cosas → Objetos: • Sensores de presión en neumáticos • Monitores de implantes coronarios • GPS en taxis • Termómetros en oficinas • … • Con un identificador único • Conectados a Internet • Transfieren datos sin intervención humana • Se integran y forman parte de un sistema mayor INTERNET DE LAS COSAS / INTERNET OF THINGS Copyright © 2017 Accenture. Todos los derechos reservados. 3 H
  • 4. • Respuesta autónoma • Capacidad de toma de decisiones • Capacidad de adaptación NECESITAMOS INTELIGENCIA EN LAS “COSAS” Copyright © 2017 Accenture. Todos los derechos reservados. 4Pictures from stock archive © their respective owners.
  • 5. Copyright © 2017 Accenture. Todos los derechos reservados. 5 • Soluciones cerradas: • Microsoft Computer Vision API (link) • IBM Watson Visual Recognition (link) • Google Cloud Vision API (link) • Amazon Rekognition (link) • Clarifai (link) RECONOCIMIENTO DE IMÁGENES • Soluciones abiertas: • OpenCV (www.opencv.org) • SimpleCV (simplecv.org) • TensorFlow (www.tensorflow.org) • AForge.Net (www.aforgenet.com) • VLFeat.org (www.vlfeat.org) • Point Cloud Library (PCL) (pointclouds.org) • Gesture Recognition Toolkit (GRT) (www.nickgillian.com/grt)
  • 6. • Desarrollada en C++ • Con interfaces para Python y Java • Libre (licencia BSD) • Soportada en Windows, Linux (x86 y ARM), Mac OS, iOS y Android • Foco importante en aplicaciones de tiempo real: • Optimizada para uso de hardware de aceleración • Optimizada para uso de múltiples núcleos • Última versión: 3.2.0 (diciembre de 2016) • En GitHub: https://github.com/opencv/opencv OPENCV LIBRARY Copyright © 2017 Accenture. Todos los derechos reservados. 6
  • 7. • Un conjunto de reglas (en formato XML) • Se aplica a cada frame de un stream de vídeo (o a imágenes individuales) • Detecta rasgos (features) • Una cara humana • Una cara de gato • Un coche • La forma de un árbol • … • OpenCV contiene un conjunto de clasificadores listos para usar • Se pueden crear nuevos clasificadores mediante entrenamiento CASCADE CLASSIFIER Copyright © 2017 Accenture. Todos los derechos reservados. 7
  • 8. Copyright © 2017 Accenture. Todos los derechos reservados. 8 • LBP • Más rápido • Cálculos sobre enteros • La mejor opción para entornos móviles/embebidos CASCADE CLASSIFIER – TIPOS • HAAR • Más preciso • Cálculos sobre punto flotante • La mejor opción cuando el % de acierto es fundamental
  • 9. • Es un proceso lento • Requiere un conjunto numeroso de imágenes con el rasgo a detectar • Para formas rígidas (un logo), basta con unas pocas • Para formas variables (un tipo de objeto), se necesitan cientos • Para rasgos de seres vivos (cara, pelo, forma corporal…), se necesitan miles • Cada imagen vendrá acompañada de las coordenadas de los rasgos • Se enriquece la muestra de ‘positivos’ con variaciones (samples) • Requiere un conjunto aún más numeroso de imágenes ‘negativas’ ENTRENAMIENTO EN OPENCV Copyright © 2017 Accenture. Todos los derechos reservados. 9
  • 10. • La herramienta de entrenamiento actual es opencv_traincascade • Recibe como entradas: • Fichero de vectores generado a partir de las imágenes ‘positivas’ • La colección de imágenes ‘negativas’ • Parámetros de configuración del algoritmo de machine learning • Usa los positivos para formular las hipótesis y mejorarlas • Usa los negativos para confirmar las hipótesis y mejorarlas • El resultado final es el fichero con los datos del cascade classifier (XML) ENTRENAMIENTO EN OPENCV Copyright © 2017 Accenture. Todos los derechos reservados. 10
  • 11. from picamera.array import PiRGBArray from picamera import PiCamera import time import cv2 with PiCamera() as camera: camera.resolution = (1920, 1080) camera.framerate = 30 rawCapture = PiRGBArray(camera, size = (1920, 1080)) time.sleep(1) for frame in camera.capture_continuous(rawCapture, format = "bgr", use_video_port = True): image = frame.array cv2.imshow("frame", image) key = cv2.waitKey(1) & 0xFF rawCapture.truncate(0) if key == ord('q'): break OPENCV HELLO CAM! – PYTHON VERSION Copyright © 2017 Accenture. Todos los derechos reservados. 11
  • 12. org.opencv.core • Mat org.opencv.videoio • VideoCapture org.opencv.objdetect • CascadeClassifier OPENCV JAVA API – PRINCIPALES CLASES org.opencv.imgproc • Imgproc org.opencv.imgcodecs • Imgcodecs
  • 14. ¿HECHOS UN LÍO? Copyright © 2017 Accenture. Todos los derechos reservados. 14All pictures and clips © their respective owners.
  • 15.  Bajo ancho de banda  Bajo uso de energía  Perfecto para IoT  Patrón Publish / Subscribe  Puede transportarse mediante WebSocket  Librerías – Eclipse IoT (link):  Cliente – Eclipse Paho: http://www.eclipse.org/paho/  Broker – Eclipse Mosquitto: http://mosquitto.org PROTOCOLO MQTT MQTT Broker Topic Device 1 publish Device 2 Device N subscribe subscribe …
  • 16. ESCENARIO DE LA DEMO … DetectorDevices publish MQTT Broker Web Server subscribe MQTT MQTT WS
  • 17. ESCENARIO DE LA DEMO publish subscribe MQTT broker
  • 18. DEMO TIME! Copyright © 2017 Accenture. Todos los derechos reservados. 18Pictures from stock archive © their respective owners.
  • 19. ¿AUN HECHOS UN LÍO? Copyright © 2017 Accenture. Todos los derechos reservados. 19All pictures and clips © their respective owners.
  • 20. Faces Detector: https://github.com/locoporf1/faces-detector WebApp Monitor: https://github.com/locoporf1/faces-detector-server Instrucciones detalladas: https://static.rainfocus.com/oracle/oow16/sess/1463395410 0810018DAr/ppt/JavaOne%20-%20FacesCounter.pptx CÓDIGO FUENTE (Kudos para Mariano Rodríguez @locoforf1)
  • 21. Scala y OpenCV con Akka Streams https://beachape.com/blog/2016/03/08/scala-and-opencv-ep-1-akka-webcam/ https://beachape.com/blog/2016/03/14/scala-and-opencv-ep-2-akka-face-detector/ Ejemplos del libro “Mastering OpenCV” https://github.com/MasteringOpenCV/code OTROS SITIOS INTERESANTES PARA EMPEZAR CON OPENCV
  • 22. Documentación oficial http://docs.opencv.org/3.2.0/dc/d88/tutorial_traincascade.html Blog de Coding Robin http://coding-robin.de/2013/07/22/train-your-own-opencv-haar-classifier.html Gran pregunta y mejor respuesta en el foro de OpenCV http://answers.opencv.org/question/39160/opencv_traincascade-parameters- explanation-image-sizes-etc/ PARA LOS VALIENTES QUE QUIERAN ENTRENAR POKÉMON CLASIFICADORES
  • 23. ¿PREGUNTAS? Copyright © 2017 Accenture. Todos los derechos reservados. 23All pictures and clips © their respective owners.