I've been searching around for information on how to recognize facial expressions in Processing, and as far as I can tell, there is no previous work on the subject. It seems like there would be, but I just can't find it. Does anyone else know about a project or a library that I can start from?
My short term goal is to program a mimic that sees your face in the webcam and copies your expression to a smiley-face kind of illustration. Concurrently I'd implement a hardware version of the smiley. I hope to ultimately add some intelligence to the face, where it might attempt to interact rather than just react.
If I can't find anything Processing specific, I guess I will have to use OpenCV or something like that to detect eyes, eyebrows, mouth, etc. and write some algorithms to determine their expression. I have not yet searched for recognizing facial expressions in general, and any guidance would be appreciated (though I understand it's beyond the scope of this forum).
I am getting a NullPointerException when I use a mouseClicked() to add a new object to an array. I think it's a scope problem or perhaps the mouseClicked() event is happening in the middle of something causing confusion. My sketch models some charged particles moving around in 2 dimensions. When you click, it is supposed to add a new particle of random charge polarity where you click. I can't really see what the problem is specifically, though. Perhaps it's obvious to someone around here.
Thanks
// Global Declarations.
int backgroundColor = 200;
int noOfParticles = 0;
// Temporary value to hold the field strength.
float tempFieldStrength;
Particle[] particles;
// PVector holding a temporary field.
PVector tempFieldVector;
// Setup Function.
void setup() {
size(640, 480);
particles = new Particle[16];
particles[0] = new Particle(10, -10, 300, 200);
noOfParticles++;
particles[1] = new Particle(10, -10, 400, 400);
noOfParticles++;
particles[2] = new Particle(10, 10, 500, 300);
noOfParticles++;
particles[3] = new Particle(10, 10, 100, 100);
noOfParticles++;
}
// Main Program Loop.
void draw() {
background(backgroundColor);
// Locate particles.
for (int i = 0; i < noOfParticles; i++) {
particles[i].updateLocation(); // Here's where Processing highlights the crash...
}
// Draw particles.
for (int i = 0; i < noOfParticles; i++) {
particles[i].drawParticle();
}
// Update particle velocity.
for (int i = 0; i < noOfParticles; i++) {
particles[i].updateVelocity(i);
}
}
void mouseClicked() {
// Random charge
float polarity = random(-1, 1);
if (polarity > 0) polarity = 10;
if (polarity < 0) polarity = -10;
noOfParticles++;
particles[noOfParticles+1] = new Particle(10, int(polarity), mouseX, mouseY);
}
class Particle {
// Fields
// The particle's mass.
float mass;
// The particle's charge.
float charge;
// The particle's physical size.
int dia;
// PVector representing particle location.
PVector loc;
// PVector representing particle velocity.
PVector v;
// Constructor
Particle(float m, int c, int x, int y) {
// How the constructor is called will determine the particle mass and charge.
mass = m;
charge = c;
// The location of each new particle is chosen by the main program.
loc = new PVector(x, y);
// The velocity of all particles starts out at 0.
v = new PVector(0, 0);
tempFieldVector = new PVector(0, 0);
}
// Methods
void drawParticle() {
noStroke();
// Particle fill color will be based on the charge.
if (charge > 0) fill(255);
if (charge < 0) fill(0);
// Draw the particle at it's location vector.
ellipse(loc.x, loc.y, int(mass), int(mass));
}
void updateVelocity(int whichOne) {
// Velocity changes based on the pull of all the other particles.
for (int i = 0; i < noOfParticles; i++) {
if (whichOne != i) {
// Add to the velocity vector the force due to each particle.