Need help to make my face detection application faster

252 views
Skip to first unread message

Shishir

unread,
Jul 13, 2012, 7:34:50 AM7/13/12
to android...@googlegroups.com

I'm using the cvHaarDetectObjects C function to detect faces in my android application, but the execution time is not fast enough to process a certain number of video frames per second. So, I'm thinking of commenting out code that is unnecessary for me eg I've noticed a lot of branching conditions for the flags and memory allocation statements that can be commented out. The same thing can be done for the functions that are called from cvHaarDetectObjects.

Has anyone tried doing this sort of optimization before? Any help is much appreciated.

He Jibo

unread,
Jul 13, 2012, 9:07:40 AM7/13/12
to android...@googlegroups.com
The face detection sample runs at around 20 Hz for my HTC phone. Is 20 Hz enough? I resized the image to 320 * 240, and add eye-tracking. I can achieve around 7 hz for both face detection and eye-tracking.

Jibo
---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info

Shishir

unread,
Jul 13, 2012, 10:18:32 AM7/13/12
to android...@googlegroups.com
Unfortunately, 20 Hz is not fast enough for the application. 25 Hz is the threshold and I want faster rates for better user experience. And I'm using native code for the OpenCV. BTW, what are the hardware specs of your phone? I got rates of around 17-20 Hz with a single-core 1GHz Samsung phone and resolution of 176*144.

He Jibo

unread,
Jul 13, 2012, 10:34:21 AM7/13/12
to android...@googlegroups.com
i think if you try skin color based face detection, you can achieve even higher sampling rate. I tried skin color face detection on a pc, i can achieve around 36 hz. I will found my phone and show your the hardware specs.

---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info


Shishir

unread,
Jul 16, 2012, 2:00:02 AM7/16/12
to android...@googlegroups.com
How did you achieve skin based face detection using opencv? Is there a tutorial online?

Shervin Emami

unread,
Jul 16, 2012, 4:53:05 AM7/16/12
to android...@googlegroups.com
If you look at "www.cvpapers.com", there are about 100 different conference papers showing different ways to do skin detection, some of them are very simple RGB or HSV thresholds and some are quite complex. I also have a tutorial for very simple HSV threshold based skin detection at "http://www.shervinemami.info/blobs.html"

-Shervin.

Shishir

unread,
Jul 16, 2012, 6:23:49 AM7/16/12
to android...@googlegroups.com
@Shervin The page for HSV threshold based skin detection on your site was useful, thanks. I downloaded the source code for that application and when I try to build it, I get an error saying  "error C1083: Cannot open include file: 'cxtypes.h': ". The file cvblobslib\src\blobcontour.h includes a header file cxtypes.h. But I can't find this file in my version of OpenCV (2.4.0). Any advice?

Alexander Smorkalov

unread,
Jul 16, 2012, 7:10:11 AM7/16/12
to android...@googlegroups.com
Hello!

There is Color-Blob-Detection example, that uses HSV color space. You can try the same technique for skin detection.

Shishir

unread,
Jul 16, 2012, 11:45:06 PM7/16/12
to android...@googlegroups.com
@Alexander Thanks for the info!

He Jibo

unread,
Jul 18, 2012, 10:24:03 PM7/18/12
to android...@googlegroups.com
I have attached my skin color based face detection code in python. Please have a look. Hope this helps you. I can help you convert it to android code.
---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info


FaceDetectionSkin.py

Shishir

unread,
Jul 24, 2012, 6:46:27 AM7/24/12
to android...@googlegroups.com

Do you get any false positives with the python code? I used your algorithm using c++ and a lot of features in the background that are not faces are being detected.

He Jibo

unread,
Jul 24, 2012, 7:55:07 AM7/24/12
to android...@googlegroups.com
it looks for the largest connected area of skin color pixels. So whether there is false positives, depending on your background. 

---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info


--
 
 
 

Reply all
Reply to author
Forward
0 new messages