lundi 18 mai 2015

How to Find out Average Skin color of face from Face Detection part in android?

I need to get Average color of the skin from the face detected part ... How do i find the Average skin color?

Now i get the Average skin color by RGB pixel value ... Still i not matching with the source image.i got the Average color of face is totally different.

@Override
protected void onDraw(Canvas canvas) {
    int redBucket = 0;
    int greenBucket = 0;
    int blueBucket = 0;
    long pixelCount = 0;
    canvas.drawBitmap(myBitmap, 0, 0, null);

    Paint myPaint = new Paint();
    myPaint.setColor(Color.GREEN);
    myPaint.setStyle(Paint.Style.STROKE);
    myPaint.setStrokeWidth(3);

    for (int i = 0; i < numberOfFaceDetected; i++) {
        Face face = myFace[i];
        PointF myMidPoint = new PointF();
        face.getMidPoint(myMidPoint);
        myEyesDistance = face.eyesDistance(); 
        canvas.drawRect((int) (myMidPoint.x - myEyesDistance * 2),
        (int) (myMidPoint.y - myEyesDistance * 2),
        (int) (myMidPoint.x + myEyesDistance * 2),
        (int) (myMidPoint.y + myEyesDistance * 2), myPaint);

        resizedbitmap=Bitmap.createBitmap(myBitmap,(int) (myMidPoint.x - (myEyesDistance)*2),  
        (int) (myMidPoint.y - (myEyesDistance)*2),  
        (int) (myEyesDistance*4),  
        (int) (myEyesDistance*4));       

        for (int y = 0; y < resizedbitmap.getHeight(); y++) {
            for (int x = 0; x <resizedbitmap.getWidth();x++) {                         
                int pixel = resizedbitmap.getPixel(x,y);                
                pixelCount++;
                redBucket += Color.red(pixel);
                greenBucket += Color.green(pixel);
                blueBucket += Color.blue(pixel);              
            }
        }
        int red = (int) (redBucket/pixelCount);
        int green = (int) (greenBucket/pixelCount);
        int blue = (int) (blueBucket/pixelCount);
        View colorView = (View)findViewById(R.id.screen1);
        colorView.setBackgroundColor(Color.rgb(121,104,88));
    }     
}

Now i get the Average skin color by RGB pixel value ... Still i not matching with the source image.i got the Average color of face is totally different.

Average RGB color Apply into view and compare the source image face and Average RGB color its different one.please any one help me.it would be really help for me. Any idea about my issue... Thanks,

Aucun commentaire:

Enregistrer un commentaire