Created
July 26, 2018 10:17
-
-
Save oidong1/96a3ca9c4fe86ee4158fc3ff0fb88e72 to your computer and use it in GitHub Desktop.
mieruka
This file contains hidden or 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.*; | |
import ddf.minim.*; | |
Minim minim; | |
AudioPlayer player; | |
PImage src, dst; | |
Capture video; | |
OpenCV opencv; | |
float waveH=50; | |
float point = 0; | |
ArrayList<Contour> contours; | |
ArrayList<Contour> polygons; | |
void setup() { | |
size(640, 480); | |
minim = new Minim(this); | |
video = new Capture(this, 640, 480); | |
opencv = new OpenCV(this, 640, 480); | |
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); | |
player = minim.loadFile("music.mp3", 512); | |
player.play(); | |
println(player.getVolume()); | |
video.start(); | |
} | |
void draw() { | |
image(video, 0, 0); | |
opencv.loadImage(video); | |
noFill(); | |
stroke(0, 255, 0); | |
strokeWeight(1); | |
Rectangle[] faces = opencv.detect(); | |
for (int i = 0; i < faces.length; i++) { | |
rect(0,faces[i].y,width,faces[i].height); | |
point = (float(faces[i].height)/height) * (float(faces[i].height)/height); | |
filter(BLUR, 10 * point*point); | |
waveH = point * 500; | |
println(point); | |
for(int j = 0; j < player.bufferSize() - 1; j++) | |
{ | |
strokeWeight(40*point); | |
float x1 = map( j, 0, player.bufferSize(), 0, width ); | |
float x2 = map( j+1, 0, player.bufferSize(), 0, width ); | |
line( x1, faces[i].y+faces[i].height/2 + player.right.get(j)*waveH, x2, faces[i].y+faces[i].height/2 + player.right.get(j+1)*waveH ); | |
} | |
} | |
} | |
void captureEvent(Capture c) { | |
c.read(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment