Last active
October 14, 2016 00:15
-
-
Save albertochiwas/4c89841c737871f58fb4ab6cc6b79fa4 to your computer and use it in GitHub Desktop.
OpenCV + Processing + Python: Imagen de cámara y filtro en tiempo real
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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