为了检测面部,我正在考虑http://developer.android.com/reference/android/media/FaceDetector.Face.html#。我能找到眼睛差异和中点。
我使用以下代码跟踪眼睛位置:
public void trackEyes( Bitmap picture_gray){
int width = picture_gray.getWidth();
int height = picture_gray.getHeight();
// r e s i z e the Bitmap t o o b t ai n e y e s ROI.
Bitmap eyes_Bitmap = Bitmap.createScaledBitmap (
picture_gray , width , height, false ) ;
// d e f i n i t i o n o f the c o l o r o f the p u p i l s .
int pupilles_color = Color.rgb ( 15 , 15 , 15 ) ;
Point eyes_left = new Point ( ) ;
Point eyes_right = new Point ( ) ;
// b e gi n ni n g o f the t r a i l o f the r e s i z e Bitmap .
for( int i = 0 ; i < eyes_Bitmap.getHeight( ) ; i ++){
for( int j = 0 ; j < eyes_Bitmap.getWidth( ) ; j ++){
// i f the p i x e l i s under the c o l o r o f the p u pil s ,
// t h a t means an eye is found .
if ( eyes_Bitmap.getPixel( j , i ) < pupilles_color ){
// i f i t i s on the l e f t s i d e o f the Bitmap ,
// i t i s the l e f t eye .
if ( j < eyes_Bitmap.getWidth ( ) / 2 )
{
eyes_left.set ( j , i ) ;
}
// e l s e i t i s the r i g h t eye .
else if ( j > eyes_Bitmap.getWidth ( ) / 2 )
{
eyes_right.set(j ,i ) ;
}
}
}
}
// c a l c u l a t i o n s t o have the p o s i t i o n o f the e y e s i n f u n c ti o n
// o f the o r i g i n a l g r e y s c a l e Bitmap .
eyes_right.set( eyes_right.x-(int)( width *0.1)+width / 2 ,
eyes_right . y-(int) (height*0.25)+ height ) ;
eyes_left.set( eyes_left.x-(int ) ( width *0.1)+ width / 2 ,
eyes_left.y-(int ) ( height*0.25)+ height ) ;
}