Created
June 26, 2018 15:42
-
-
Save igaln/6f099a7492686ad41c674d4e6bfdfaa2 to your computer and use it in GitHub Desktop.
Opencv Processing Camera Filter
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
import gab.opencv.*; | |
import processing.video.*; | |
import java.awt.*; | |
Capture video; | |
OpenCV opencv; | |
PImage img, thresh, blur, adaptive; | |
void setup() { | |
size(640, 480); | |
video = new Capture(this, 640/2, 480/2); | |
opencv = new OpenCV(this, 640/2, 480/2); | |
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); | |
video.start(); | |
} | |
void draw() { | |
scale(2); | |
opencv.loadImage(video); | |
opencv.adaptiveThreshold(591,10); | |
adaptive = opencv.getSnapshot(); | |
image(adaptive, 0, 0 );a | |
noFill(); | |
stroke(0, 255, 0); | |
strokeWeight(3); | |
Rectangle[] faces = opencv.detect(); | |
println(faces.length); | |
for (int i = 0; i < faces.length; i++) { | |
println(faces[i].x + "," + faces[i].y); | |
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height); | |
} | |
} | |
void captureEvent(Capture c) { | |
c.read(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment