# Thread: Help with face detection Viola Jones Algorithm

1. Member
Join Date
Feb 2012
Posts
14
Rep Power
0

## Help with face detection Viola Jones Algorithm

I'm currently working on a face detection project. And i read the Viola Jones algorithm. Which has a requirement of converting an image to integral image and it also has some features thing. I have been superly confused with what is this feature thing and how it works. If anyone can help it will be greatly appreciated. Kindly explain what are features and how they work.

2. ## Re: Help with face detection Viola Jones Algorithm

How does your question relate to java programming?

3. Member
Join Date
Feb 2012
Posts
14
Rep Power
0

## Re: Help with face detection Viola Jones Algorithm

May be you can guide me to the best approach for face detection in java.. :/

4. ## Re: Help with face detection Viola Jones Algorithm

Can you explain the algorithm that you want to use. Given an array of pixels what do you want to do?

5. Member
Join Date
Feb 2012
Posts
14
Rep Power
0

## Re: Help with face detection Viola Jones Algorithm

Look em currently working with YCbCr color model. I have taken rgb values of a pic and converted them to YCbCr. It works fine when em in front of a black background but it is not useful in complex backgrounds. Maybe it is because of the threshold values. Em giving you the code i want your help if you can suggest me correct threshold or the most effective one or some other way of face detection in java.
Java Code:
```  int wid = img.getWidth();
int hei = img.getHeight();
int [] arr1 = new int [3];
arr1[0] = 0;
arr1[1]=0;
arr1[2]=0;
int[] arr = new int[3];
arr[0]  = 248;
arr[1] = 248;
arr[2] = 255;
int[][] pixels = new int[wid][hei];

for(int i = 0; i<wid; i++)
{
for(int j = 0;j<hei;j++)
{

pixels[i][j] = img.getRGB(i,j);

int red = (((pixels[i][j]  >> 16) & 0xff));
int green = (((pixels[i][j] >> 8) & 0xff));
int blue = ((pixels[i][j] & 0xff));

int[] y = new int[3];
y[0] =  (int) (((0.299*red)+(0.587*green)+(0.114*blue))+16);
y[1] = (int) (((-0.169*red)+(-0.331*green)+(0.5*blue))+128);
y[2] = (int) (((0.5*red)+(-0.419*green)+(-0.081*blue))+128);

if((y[1]>80)&&(y[1]<120)&&(y[2]>133)&&(y[2]<173))

img.getRaster().setPixel(i, j, arr);
else
img.getRaster().setPixel(i, j, arr1);```
Last edited by Norm; 03-24-2012 at 09:03 PM. Reason: added code tags

6. ## Re: Help with face detection Viola Jones Algorithm

can suggest me correct threshold
define what a threshhold is.
I'm not familiar with YCbCr

What is the posted code supposed to do? It has a lot of hardcoded/undefined numbers in it. Those should all be used as named variables to help explain what they are being used for.

7. Member
Join Date
Feb 2012
Posts
14
Rep Power
0

## Re: Help with face detection Viola Jones Algorithm

There is only one thing that is not properly defined here and that is img. It is an image which i capture by grabbing frame. A threshold converts image to white and black color in my case skin is marked as white and everything else is black. This code takes RGB values of given image and then convert it to Y "y[0]", Cb "y[1]", and Cr"y[2]". Ycbcr is widely used for skin detection. Is this information enough?

8. ## Re: Help with face detection Viola Jones Algorithm

What java programming questions do you have? Your discussion of threshold did not explain anything related to the code that you posted.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•