   How can I speed up my face detection algorithm?
  Let's say I'm using 20x20 windows.  My initial image is 320x240.  Even with steps of 2 pixels between each window that's something like 80,000 windows to scan.  I'm using a pyramid of images with something like the next image is 80% of the previous one.  In total it's going to be something along the lines of 200,000 windows to scan.  This is a rather large number, and it takes about 80 seconds to scan one image with my dual core processor (it's multi-threaded, albeit probably not as well as it could be).  So how can I speed this up? Obviously most of an image is going to be background clutter.  Is there anything I can do to give parts of the image... values? So it'll skip the parts that are likely to be background? Or something to that effect? I'm aware that there are algorithms that can do this in real-time so it must be possible, but I have no idea HOW they do it.If it helps, I'm using neural networks.   
Well, you might wanna do some preprocessing on the image to find areas that are likely to contain a face. Two simple ideas are sigma-shape detection (google it) and limiting yourself to areas that contains a significant amount of edges.Quote:Original post by Side WinderIf it helps, I'm using neural networks.It rarely does.;  Look into the concept of integral images in conjuction with SAD (sum of absolute difference) images, they will cut down on the number of calculations that you have to do. Also, try playing with various window sizes as it will affect your performance. Have you trained your classifier with images of faces as well? If not, you should.   ;  Thanks guys.  I found a skin segmentation algorithm that seems to work fairly well for what I want.  It's cut the time taken per image by about 80%, and the false detections by quite a bit too!   ;  What algorithm are you using? If you use integral images to evaluate features and then use cascading you should definatively be able to do it real-time. Another optimization might be to do some skin color analysis first. One thing I'm thinking about implementing myself is to have interest regions that are scanned more often than "uninteresting" regions. If there is a face in an uninteresting region that region will be promoted to a interesting region and then there will be some kind of fall-off for each region to become uninteresting again if there havent been any faces detected there for a few frames.   ;  Well I've implemented just the one pre-processing algorithm for skin implementation.  I was thinking about putting in other algorithms in as well and ANDing them all, but decided against it.  It's accurate enough for my needs, and it's cut the time taken from 80 seconds to about 8 seconds per photo.  Of course, the more skin detected, the longer the neural network will take to go through all the regions.I used a YCbCr algorithm.  Seems to be the most used on the internet from what I've seen.And yeah, I've seen something similar to that method before.  The guy did 10 pixel steps and any "interesting" areas were re-scanned more thoroughly.  And there was something to do with 30x30 windows.. I dunno, can't remember it too well, only skimmed it.   ;  20x20 is a bit large. I found that 8x8 is the most efficient, mostly due to cache efficiency.  How are you generating the sub images?  Are you creating a new array and filling it with the image data or are you simply calculating the pixel locations on the fly.  Calculating the pixel locations will be much faster than copying the image data to a new array.  Most of the slowdown in image processing is due to memory bandwidth issues.  It's an inherently I/O bound task as most of the math is fairly simple (for a processor that is).  Also don't assign multiple threads to process the same regions of the image.  e.g. have the first thread process the top half of the image and the second thread process the bottom half, this will prevent memory contention issues as both CPU's try to load the same data into multiple caches.   