Hey guys,

I have a problem here, I used the facedetector tutorial provided by
Google and got it working. Once I did this I tried creating a menu
that allows a user to take a picture and then once taken, choose an
image to be recognized. The problem arises with the face detection. I
can display the image from the gallery but when I try and recognize a
face within the image it doesn't work.

The code below shows my code;

[code]

   public void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub

             canvas.drawBitmap(bitmap, 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),
                (int)(myMidPoint.y - myEyesDistance),
                (int)(myMidPoint.x + myEyesDistance),
                (int)(myMidPoint.y + myEyesDistance),
                myPaint);
             }
   }


   @Override
       public void onActivityResult(int requestCode, int resultCode,
Intent
data) {

               if (requestCode == ACTIVITY_SELECT_IMAGE && resultCode
== RESULT_OK)
{
                       try {
                               Uri currImageURI = data.getData();
                               String[] proj = { Images.Media.DATA,
Images.Media.ORIENTATION };
                               Cursor cursor =
managedQuery(currImageURI, proj, null, null,null);
                               int columnIndex =
cursor.getColumnIndex(proj[0]);
                               cursor.moveToFirst();
                               mCurrentImagePath =
cursor.getString(columnIndex);
                               BitmapFactory.Options
BitmapFactoryOptionsbfo = new
BitmapFactory.Options();
 
BitmapFactoryOptionsbfo.inPreferredConfig =
Bitmap.Config.RGB_565;
                               Bitmap bitmap =
BitmapFactory.decodeFile(mCurrentImagePath);
                               int width = bitmap.getWidth();
                               int height = bitmap.getHeight();
                               myFace = new
FaceDetector.Face[numberOfFace];
                               myFaceDetect = new FaceDetector(width,
height, numberOfFace);
                               numberOfFaceDetected =
myFaceDetect.findFaces(bitmap, myFace);

                               mImageView.setImageBitmap(bitmap);




                        catch (Exception e) {
                       }






               }

[/code]

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to