title: how to detect the number of face in an image picture
body: <p>I am creating an Android face detection app and when I run it on my device it always says:<br>
  <strong>"Sorry TakePic has suddenly stopped"</strong></p>
  
  <p>Here is my code for face detection and I believe that this is the source of the error:</p>
  
  <p>bitmap = MediaStore.Images.Media.getBitmap(cr, selectedImage);
      TextView detect = (TextView)findViewById(R.id.detect);</p>
  
  <pre><code>Bitmap maskBitmap = Bitmap.createBitmap( bitmap.getWidth(),bitmap.getHeight(), Bitmap.Config.RGB_565 );
  Canvas c = new Canvas();
  c.setBitmap(maskBitmap);
  Paint p = new Paint();
  p.setFilterBitmap(true); // possibly not nessecary as there is no scaling
  c.drawBitmap(bitmap,0,0,p);
  bitmap.recycle();
  
  detectedFaces=new FaceDetector.Face[NUMBER_OF_FACES];
  faceDetector=new FaceDetector(maskBitmap.getWidth(),maskBitmap.getHeight(),NUMBER_OF_FACES);
  NUMBER_OF_FACE_DETECTED=faceDetector.findFaces(maskBitmap, detectedFaces);
  
  k.setImageBitmap(bitmap);
  detect.setText(NUMBER_OF_FACE_DETECTED);
  Toast.makeText(MainActivity.this, selectedImage.toString(), Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>What would the mistake be with this code?</p>