Dirty but fast face recognition using only contourFinder

Hi all!

I’m doing my first OF project and need to keep track of heads and faces. haarFinder pulled down the framerate from 20 to 8 in my project. Perhaps it’s possible to make it faster? What are your experiences? I haven’t fiddled around too much with the variables…

Anyway I just finished a really dirty face recognition using only contourFinder. This way I can track faces roughly, but with virtually no frame rate loss, which is alright for this project.

in .h

  
  
// remember to place this between #include ....and... class myApp  
struct dirty_head  
{  
	float x, y, width, angle;  
};  
//  
  
// public members  
// a somewhat dirty face recognition based on contourFinder  
vector<dirty_head>	dirtyHeads;  
int					numDirtyHeads;  
  

in setup:

  
  
numDirtyHeads = 0;  
dirtyHeads.clear();  
for (int i = 0; i < contourFinder.nBlobs; i++){  
	 // hole == true means its NOT a hole for some reason  
	if(contourFinder.blobs[i].hole == true){  
		// don't allow for more than 25 deg head tilting.  
		float rotation = box[i].angle;  
		rotation = fmin(25, rotation);  
		rotation = fmax(-25, rotation);  
					  
		dirty_head new_head = { (box[i].center.x)-(box[i].size.width*.25),   
						(box[i].center.y)-(box[i].size.height*.5),   
						box[i].size.width*.5,   
						rotation};  
		dirtyHeads.push_back(new_head);  
		numDirtyHeads++;  
	}  
}  
  

in draw:

  
  
if(numDirtyHeads > 0) {	  
	for (int i = 0; i < numDirtyHeads; i++){  
		ofEnableAlphaBlending();  
		ofFill();  
		ofSetColor(255, 50, 0, 127);  
		glPushMatrix();  
		glTranslatef(dirtyHeads[i].x, dirtyHeads[i].y, 0);  
		glRotatef(dirtyHeads[i].angle, 0, 0, 1);  
		ofRect( -dirtyHeads[i].width*0.5, 0, dirtyHeads[i].width, dirtyHeads[i].width);  
		glPopMatrix();  
		ofEnableAlphaBlending();  
	}  
}  

I need to make this even better (as in more accurate), if you can help out, please post a modified version here.

All the best,

Kalle
http://www.stripdigital.com
http://www.thyseliusandwistrom.com

It would be helpful to see an example image processed by this system, I find it hard to visualize how it’s working.