Skip to content

Instantly share code, notes, and snippets.

@albertochiwas
Last active October 14, 2016 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertochiwas/4c89841c737871f58fb4ab6cc6b79fa4 to your computer and use it in GitHub Desktop.
Save albertochiwas/4c89841c737871f58fb4ab6cc6b79fa4 to your computer and use it in GitHub Desktop.
OpenCV + Processing + Python: Imagen de cámara y filtro en tiempo real
# Reconoce rostro y filtra en tiempo real imagenes de video tomadas de la camara
add_library('video')
add_library('opencv_processing')
video, opencv, ancho, alto, fp = None, None, 640, 480, 12
def setup():
global opencv, video, ancho, alto, fp
size(ancho, alto)
video = Capture(this, ancho/2, alto/2)
opencv = OpenCV(this, ancho/2, alto/2)
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE)
frameRate(fp)
noFill()
stroke(0, 255, 0, 100)
strokeWeight(2)
video.start()
def draw():
global opencv, video
scale(2)
opencv.loadImage(video)
image(video, 0, 0)
faces = opencv.detect()
for face in faces:
f = face.x, face.y, face.width, face.height
rect(*f)
opencv.loadImage(video)
opencv.threshold(80)
# opencv.blur(12)
# opencv.adaptiveThreshold(591, 1)
blur = opencv.getSnapshot().get(*f)
image(blur,0,0,blur.width/2,blur.height/2)
break
def captureEvent(c): c.read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment