We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Just wondering if anyone has any pointers towards a library, etc. that can be used with Processing for recognizing objects within an image. Doing some initial searches came up with OpenCV, which I know Processing has a library for, but I am interested in objects as opposed to facial recognition.
I am interested in taking an image and running it through some kind of parsing and getting output that indicates any objects found in the image. I'm not concerned with the placement of the object within the image, just a list of the objects. any ideas on this are welcome.
I want to be able to make a code using my live camera, and detectiong facial features so i can expand on that and morph or manipulate facial features, anyone know anything about that? do i need to download a library?
Hi all!
I'm currently doing a project in which i ideally want to be identifying if an image contains traffic or not, and if it does then to display information. So i would be using a live stream of images from road traffic webcams and displaying data about traffic as it happens.
My main question is how to actually go about writing something that would detect a car for example - or ever the colour of it, but that would be getting ahead of myself.
Many thanks, any response will be very much appreciated!
Looking for any info about doing Facial Recognition in Processing (not to be confused with Facial Detection).
Greg Borenstein's lib here gives basic access to OpenCV (and is great BTW!):
https://github.com/atduskgreg/opencv-processing
It's mentioned in the libs introduction that " In addition to using the wrapped functionality, you can import OpenCV modules and use any of its documented functions".
OpenCV does have a FaceRecognition module, here:
http://docs.opencv.org/3.0-beta/modules/face/doc/facerec/facerec_api.html#FaceRecognizer
If anyone has gone down this path, or knows a general direction to travel, the help would be greatly appreciated.
Hope it helps!
whether it's possible to recognize faces while it is training at the same time
That's a fundamental problem for facial recognition algorithms of all kinds. If you aren't backed by some training data (whether from a web service or locally) then performance may be very poor. The best thing is to test and see how well it performs.
Hi everyone, I'm a beginner with Processing, and I am trying to make a code that involves facial capture through a webcam on my laptop. The camera feed is being fed into an image at the end of my code, but is there any way I could apply a mask to this image? Any help would be really appreciated, thanks!
import gab.opencv.*; import java.awt.Rectangle; import processing.video.*; OpenCV opencv; Rectangle[] faces; Capture video; PImage img, mask;
void setup() {
size(640, 360); background(0);
video = new Capture(this, width, height);
video.start();
noStroke();
smooth();
opencv = new OpenCV(this, width, height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
}
void draw() {
if (video.available()) {
video.read();
PImage mask = loadImage("radial1.png");
opencv.loadImage(video);
video.loadPixels();
noFill();
stroke(0, 255, 0);
strokeWeight(3);
faces = opencv.detect();
video.mask(mask); //<--Recieves NullPointerException error
for (int i = 0; i < faces.length; i++) { //facedraw
image(video, 200, 200, 150, 150, (faces[+i].x)+1, faces[+i].y+1, (faces[i].width)+faces[i].x, (faces[+i].height)+faces[i].y);
}
} }
Hello, I'm sorry if the answer is simple but I'm new to Processing and I need to program a simple sketch for an exam.
I'll explain my idea: I have a background and two simple stick men. I want to change the texture of their head with various facial expressions (drawn by me in Photoshop and saved as jpg) when the mouse is pressed on that area.
How can I do that?
I tried to create a shape for their heads but the sketch doesn't run. I tried to create a specific area (100x100 px) but nothing.
i want to make a interactive face like a simulation that will change facial expressions according to what the camera see in processing using OpenCV but im not sure how such implementation is start, any tips and or advice will be greatly appreciated
i want to make a interactive face like a simulation that will change facial expressions according to what the camera see in processing using OpenCV but im not sure how such implementation is start, any tips and or advice will be greatly appreciated
Hey everyone! I'm making an interactive 'mirror' that allows users to distort live video of their face using the leap motion. I'm not planning on using a facial recognition library to do targeted distortion of features. Instead I'd like to alter regions of the screen depending on different gestures.
Does anyone know the best way to go about this? This is the pseudo code I have so far:
*loadPixels from camera
*Use nested for loop to iterate thru pixels and alter certain regions of the screen
*Call function that detects leap motion gestures/ changes the vars that control distortion
*updatePixels
Any advice or examples are appreciated. Thanks!
hello!! I am not very good with processing, but I really like it, now I was trying to do a facial recognition. but I do not know and i haven't any idea of how to take and compare the image captured by the webcam with an other image with my face. to recognition face i use opencv library on processing, so somebody have any idea???. thanks!!!!! thanks for any help!!!
Hi Omerjerk,
I'm not very well qualified, so this is "user experience", not peer review!
Processing Android could really use some fixing around OpenGL! It would be great to be able to create Google Cardboard apps in Processing Android mode - but right now the OpenGL compatability problems the make it very hard: here's an example of the hoops you need to jump through to do it now:
http://www.antonbastov.com/processing-for-google-cardboard/
In my opinion, The Ketai Library already covers sensors pretty well. It would be great if someone could expand on the facial recognition areas of this library to allow more of the Android facial recognition features to be available in processing.
Related: If you have not tried it, check out APDE, which is a fully functional Processing Android mode IDE that runs on the android platform:
https://play.google.com/store/apps/details?id=com.calsignlabs.apde&hl=en
All the best.
I am trying to make Luigi flee from mario once mario gets to close to him. Do I just a boolean or float distance?
My code so far with missing pieces:
float marioX = 100;
float marioY = 425;
float luigiX = 400;
float luigiY = 425;
boolean flee;
void setup() {
size (600, 600);
smooth();
flee = false;
}
void draw(){
background(41, 194, 252);
fill(54, 252, 41);
stroke(54, 252, 41);
rect(0,500, 600, 100);
fill(254, 255, 36);
stroke(245, 255, 36);
ellipse(475, 100, 120, 120);
if (keyPressed && key == 'z') {
marioX-=5;
} else if (keyPressed && key == 'x') {
marioX+=5;
}
if (keyPressed && key == CODED) {
if (keyCode == LEFT) {
luigiX-=5;
} else if (keyPressed && keyCode == RIGHT) {
luigiX+=5;
}
}
mario(marioX, marioY, 1.5);
luigiLeft(luigiX, luigiY, 1.5);
if( flee == false){
}
if( flee == true){
}
if( dist(x1,y1,x2,y2)<50)
flee == true;
}
void mario(float x, float y, float s) {
pushMatrix();
translate(x-s*.75*50, y-s*50);
scale(s*100/16);
strokeWeight(.1);
stroke(159, 89, 39); // Light brown color
fill(159, 89, 39); // Light brown color
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(139, 69, 19); // Dark brown color
fill(139, 69, 19); // Dark brown color
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
void luigiLeft(float x, float y, float s) {
pushMatrix();
translate(x+s*.75*50, y-s*50);
scale(-s*100/16,s*100/16);
strokeWeight(.1);
stroke(46, 139, 87); // Green shirt
fill(46, 139, 87); // Green shirt
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
stroke(109, 49, 9); // Dark brown shoes
fill(109, 49, 9); // Dark brown shoes
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(45, 40, 240); // Blue overalls
fill(45, 40, 240); // Blue overalls
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(109, 49, 9); // Dark brown facial features
fill(109, 49, 9); // Dark brown facial features
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(46, 139, 87); // Green hat
fill(46, 139, 87); // Green hat
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
I have another question for this same project.
If I am trying to make luigi flee from mario once mario get to close to him how would I do that? I am trying to make him "flee" to the right.
My code right now is: float marioX = 100; float marioY = 425; float luigiX = 400; float luigiY = 425;
void setup() {
size (600, 600);
smooth();
}
void draw(){
background(41, 194, 252);
fill(54, 252, 41);
stroke(54, 252, 41);
rect(0,500, 600, 100);
fill(254, 255, 36);
stroke(245, 255, 36);
ellipse(475, 100, 120, 120);
mario(marioX, marioY, 1.5);
luigiLeft(luigiX, luigiY, 1.5);
}
void keyPressed() {
if (key == 'z') {
marioX-=5;
} else if (key == 'x') {
marioX+=5;
}
if (key == CODED) {
if (keyCode == LEFT) {
luigiX-=5;
} else if (keyCode == RIGHT) {
luigiX+=5;
}
}
}
void mario(float x, float y, float s) {
pushMatrix();
translate(x-s*.75*50, y-s*50);
scale(s*100/16);
strokeWeight(.1);
stroke(159, 89, 39); // Light brown color
fill(159, 89, 39); // Light brown color
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(139, 69, 19); // Dark brown color
fill(139, 69, 19); // Dark brown color
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
void luigiLeft(float x, float y, float s) {
pushMatrix();
translate(x+s*.75*50, y-s*50);
scale(-s*100/16,s*100/16);
strokeWeight(.1);
stroke(46, 139, 87); // Green shirt
fill(46, 139, 87); // Green shirt
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
stroke(109, 49, 9); // Dark brown shoes
fill(109, 49, 9); // Dark brown shoes
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(45, 40, 240); // Blue overalls
fill(45, 40, 240); // Blue overalls
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(109, 49, 9); // Dark brown facial features
fill(109, 49, 9); // Dark brown facial features
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(46, 139, 87); // Green hat
fill(46, 139, 87); // Green hat
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
void setup() {
size (600, 600);
smooth();
}
void draw(){
background(41, 194, 252);
fill(54, 252, 41);
stroke(54, 252, 41);
rect(0,500, 600, 100);
fill(254, 255, 36);
stroke(245, 255, 36);
ellipse(475, 100, 120, 120);
mario(100, 425, 1.5);
luigiLeft(400, 425, 1.5);
}
void mario(float x, float y, float s) {
pushMatrix();
translate(x-s*.75*50, y-s*50);
scale(s*100/16);
strokeWeight(.1);
stroke(159, 89, 39); // Light brown color
fill(159, 89, 39); // Light brown color
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(139, 69, 19); // Dark brown color
fill(139, 69, 19); // Dark brown color
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(220, 0, 0); // Red color
fill(220, 0, 0); // Red color
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
void luigiLeft(float x, float y, float s) {
pushMatrix();
translate(x+s*.75*50, y-s*50);
scale(-s*100/16,s*100/16);
strokeWeight(.1);
stroke(46, 139, 87); // Green shirt
fill(46, 139, 87); // Green shirt
rect(2, 7, 6, 1);
rect(1, 8, 10, 1);
rect(0, 9, 12, 1);
rect(2, 10, 1, 1);
rect(9, 10, 1, 1);
stroke(109, 49, 9); // Dark brown shoes
fill(109, 49, 9); // Dark brown shoes
rect(1, 14, 3, 1);
rect(8, 14, 3, 1);
rect(0, 15, 4, 1);
rect(8, 15, 4, 1);
stroke(244, 164, 96); // Peach color
fill(244, 164, 96); // Peach color
rect(5, 2, 4, 1);
rect(2, 3, 9, 1);
rect(2, 4, 10, 1);
rect(3, 5, 4, 1);
rect(3, 6, 7, 1);
rect(0, 10, 2, 1);
rect(10, 10, 2, 1);
rect(0, 11, 3, 1);
rect(9, 11, 3, 1);
rect(0, 12, 2, 1);
rect(10, 12, 2, 1);
stroke(45, 40, 240); // Blue overalls
fill(45, 40, 240); // Blue overalls
rect(4, 7, 1, 1);
rect(4, 8, 1, 1);
rect(7, 8, 1, 1);
rect(4, 9, 4, 1);
rect(3, 10, 1, 1);
rect(5, 10, 2, 1);
rect(8, 10, 1, 1);
rect(3, 11, 6, 1);
rect(2, 12, 8, 1);
rect(2, 13, 3, 1);
rect(7, 13, 3, 1);
stroke(109, 49, 9); // Dark brown facial features
fill(109, 49, 9); // Dark brown facial features
rect(2, 2, 3, 1);
rect(7, 2, 1, 1);
rect(1, 3, 1, 1);
rect(3, 3, 1, 1);
rect(7, 3, 1, 1);
rect(1, 4, 1, 1);
rect(3, 4, 2, 1);
rect(8, 4, 1, 1);
rect(1, 5, 2, 1);
rect(7, 5, 4, 1);
stroke(255, 215, 0); // Gold color
fill(255, 215, 0); // Gold color
rect(4, 10, 1, 1);
rect(7, 10, 1, 1);
stroke(46, 139, 87); // Green hat
fill(46, 139, 87); // Green hat
rect(3, 0, 5, 1);
rect(2, 1, 9, 1);
popMatrix();
}
I have just completed a program I have been working on for a few days. The program takes a list of jpegs from a folder, scans them for faces, using OpenCV and then outputs the 'faces' it finds.
However, there is one huge problem. It is extremely inaccurate.
I am using the opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
of haar cascade and I am curious to know if anyone else can provide a way to improve the accuracy? I would like to detect sides of faces, tilted faces, and frontal faces.
Thanks!
There are a ton of Java libraries out there. I'd recommend googling "java facial recognition" as a good place to start.
I understand for newbies it's hard to make a MCVE sometimes...
when they could, they wouldn't be stuck...
you have now a help screen on start-up and then the main program. This is done by states of the program. The states determine whether we see an initial help screen or the main program screen
the random shuffling of the sentences works now. The trick is to leave the array as it is and just change the index n when the mouse is pressed.
also when defining the texts you can begin a new line, but only outside "the texts" where a comma is and "a new text" begins
import ddf.minim.*;//import minim
// the states determine whether we see an initial help screen or the main program screen
final int stateNormal = 0; // consts
final int stateHelp = 1;
int state = stateHelp; // current
Minim minim;//minim object
//declare pFont variable
PFont myFont;
// A button object (that will trigger the sound)
Button button;
color baseColor = (#BFA572);
//although I want these guys to open just at the beginning then change to the other text with mouseClick.couldn't figure out how..
String intro1 = "click on the big circle above for next instruction";
String intro2 = "Retarded Instructions For People Who Would Like To Compose";
String[] Texts = {
"Record the sound of your father ageing.",
"Record a good moment of silence with a friend without letting them notice. Send it to them in their next b-day.",
"Pay attention to the sounds created by a person that is in the same room/space that you are. Notate the sounds that they make. Imitate the sounds using one or more instruments looking at your notation. The sounds you record is your material.",
"Keep your recording machine with you all day. Record 30 seconds each time you change the environmet/space. Make a soundscape diary of your day.",
"Look at your dinner, make a score. And sing it to your recording machine.",
"Make a flu fugue. Record sounds from 4 people who has a flu. Use counterpoint.",
"When you meet your friends, instead of greeting them with hello, say something that makes no sense and record their reactions. Make an IDM piece.",
"Ask your friends to hum you the first tune that comes to their head and record it. Make a compilation CD using their voices with the song they hummed and give it to them as a New Years gift.",
"Tell your mom that you are not eating well and record her voice over the phone. Make a sad piano pieces for 'worried mothers'.",
"Find a text that you like and ask random 5 people to read it back to you. Make a Quintet.",
"Go out and record some sounds made by people from different ages (babies, children, teenagers, middle aged,old) then compose a piece with the time scale of ageing. (make a piece of a growing human)",
"Attend a yoga class and secretly record it. ",
"Make portraits of family, 2 friends and yourself. Use them as scores for a vibraphone piece.",
"Get a tape machine. Go to a retirement home. Give it to one of the old people. (Smile , be kind and leave.) Record (in your memory) visually their facial expression when you give it to them. Go home and make a 2 minute piece of it.",
"When you go to your parents house, record the sound of your parent(s) sleeping.",
"4 Seasons: Jump up and down on the ground 15 times each season. The places you choose to jump should be the places that represents your image of the season. Then record 1 minute of another sound that is representative of that season. Make a dance piece.",
"Ask 4 of your friends to tap a tempo. Make a percussion piece that changes between these 4 different tempi.",
"Make baby talk with a friend, if they reply you with baby talk as well, ask to record what they just said. If they are okay with it, then make a song called 'that's the way I like to babe it'.",
"Ask friends to imitate accents of other languages speaking in english regardless of their nationality. For example: A turkish that imitates a Indian person speaking english. Have them say one sentence. Compose a canon."
};
// int n = 0;
int n = int (random(0, 18));
//float(random(0,18)); //random number between 0 & 17
void setup() {
size(600, 600);
background(baseColor);
myFont = createFont("AmericanTypewriter-48", 12); //create font
//for (int i = 0; i < 18; i++) {
// Texts[i] = Texts[i] *2;
//}
//doesn't work
/*for(int i = 0; i < 21; i++){
textArray[i] = new Text(random(int(0, 20)));
}
*/
// start up Minim
minim = new Minim(this);
// Create a new button
button = new Button(150, 100, 50, "bamboo.wav");
smooth();
ellipseMode(CENTER);
}
void draw() {
background(100, 100, 126);
switch (state) {
case stateHelp:
handleStateHelp();
break;
case stateNormal:
handleStateNormal();
break;
default:
println("big error, unknown state 93");
break;
} // switch
}
// ------------------------------------
void handleStateHelp() {
//FRAME
fill(#F5C219);
stroke(#DBA226);
strokeWeight(6);
smooth();
rect(70, 250, 460, 50);
//Text
textSize(10);
fill(#F7DAAF);
text(intro1, 145, 590);
fill(#7E4E05);
strokeWeight(0);
textSize(15);
text(intro2, 76, 270);
}
void handleStateNormal() {
// text(Texts[n], 10, 50);
text(Texts[n], 10, 50, 270, 80); // I wanted to try to wrap text displayed within text box
fill(50);
//text(Texts[n](random(0,2)), 10, 10, 70, 80); // I wanted to try to wrap text displayed within text box
// Draw the button and its jiggle function
button.display(mouseX, mouseY);
button.jiggle();
//declare Font as myFont
textFont(myFont);
//Draw random texts on screen-doesn't work
//for(int i = 0; i < 20; i++){
// textArray[i].drawToScreen(random(int(0, 21)));
//}
//Text
textSize(10);
fill(#F7DAAF);
text(intro1, 145, 590);
}
void mousePressed() {
switch (state) {
case stateHelp:
// just move on
state=stateNormal;
break;
case stateNormal:
// normal program
// click on the button, play the sound. Works
if (button.contains(mouseX, mouseY)) {
button.ring();
// n++;
n = int (random(0, 18));
if (n>Texts.length) {
n=0;
} // iff
} // if
//Why Doesn't this work? // What do you want to happen here?
// if (mousePressed) {
// open(Texts);
// }
//textArray[].Texts = random(0,20);
//create: click on the button, change text
// if (button.contains(mouseX, mouseY)) {
//texts.drawToScreen(random(0,20));
// }
break;
default:
println("big error, unknown state 102");
break;
} // switch
}
// Close the sound files
public void stop() {
// The button object must close its sound.
button.close();
super.stop();
}
// ================================================
class Button {
// Location and size
float x;
float y;
float r;
// An AudioPlayer object is used to store the sound.
AudioSnippet tadaa;
// Create the button
Button (float x_, float y_, float r_, String filename) {
x = x_;
y = y_;
r = r_;
// load "sounds" into a new AudioPlayer
tadaa = minim.loadSnippet(filename);
}
// If the button is pressed, the shape jiggles
void jiggle() {
// The doorbell only jiggles if the sound is playing.
if (tadaa.isPlaying()) {
x += random(-1, 1);
y += random(-1, 1);
r = constrain(r + random(-2, 2), 50, 200);
}
}
// The doorbell rings!
void ring() {
if (!tadaa.isPlaying()) {
// The ring() function plays the sound, as long as it is not already playing.
// rewind() ensures the sound starts from the beginning.
tadaa.rewind();
tadaa.play();
}
}
// Is a point inside the button (used for mouse rollover, etc.)
boolean contains(float mx, float my) {
if (dist(mx, my, x, y) < r) {
return true;
}
else {
return false;
}
}
// Show the button (hardcoded colors, could be improved)
void display(float mx, float my) {
if (contains(mx, my)) {
fill( 126, 114, 100);
}
else {
fill(119, 152, 202);
}
stroke(202, 175, 142);
ellipse(x, y, r, r);
}
void close() {
// The button has a close() function to close the AudioPlayer object.
tadaa.close();
}
}
//
Hi,
I'm using this code for a facial recognition sketch, but it uses my inbuilt iSight camera instead of the USB camera I want to use. I tried looking for some workarounds, but no succes. How can I use my USB camera instead of the iSight?
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
import ddf.minim.*;
Minim minim;
AudioPlayer soundtrack;
Capture video;
OpenCV opencv;
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();
// always start Minim before you do anything with it
minim = new Minim(this);
//load a file, give the AudioPlayer buffers that are 2048 samples long
soundtrack = minim.loadFile("laser.mp3");
video.settings();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(255, 255, 0);
strokeWeight(3);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
println(faces[i].x + ", FACE" + faces[i].y);
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
soundtrack.play();
delay(3000);
soundtrack.rewind();
}
}
void captureEvent(Capture c) {
c.read();
}
void stop()
{
// always close Minim audio classes when you are done with them
soundtrack.close();
minim.stop();
super.stop();
}