In OpenCV/Samples there is facedetect program. This program can detect faces on images and video. It’s very fun, but its speed leaves much to be desired =(. Of course with OpenMP, it works faster; on Intel Core Duo 2.7GHZ, it works fast; but will it work fast on ARM? I have big doubts. I compiled facedetect without OpenMP and on average it takes 600 ms for 640×480 resolution to find one face. I wanted to find out, if it’s possible to improve this time by software means or not… After some investigations, code refactoring and improvements, facedetect started to work 2.5 time faster, even on ARM. Of course, without big quality loss =)
I started investigation with profiling cvHaarDetectObjects on 640×480 image. Function cvRunHaarClassifierCascade tooks 70% of computation time. But cvRunHaarClassifierCascade is not so heavy, why it takes so much time? Scanning 20×20 window is moved on X-direction and Y-direction and Scale-direction and on each scanning window, cvRunHaarClassifierCascade is called. Totally we have 160000 calls!
So to reduce time, we need optimize this triple cycle. I know several ways:
We have researched a lot of approaches and combination of ways above and got the result (Intel Core Duo 2.7GHZ):