currently I am developing android application. In my application I need to crop image from gallery. However, before I allow the user to crop the image, I want to check whether there is face detected in the image or not.
Here is how I allow user to crop an image from gallery:
Intent pickImageIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickImageIntent.setType("image/*");
pickImageIntent.putExtra("crop", "true");
pickImageIntent.putExtra("noFaceDetection", true);
pickImageIntent.putExtra("aspectX", size);
pickImageIntent.putExtra("aspectY", size);
pickImageIntent.putExtra("outputX", size);
pickImageIntent.putExtra("outputY", size);
pickImageIntent.putExtra("scale", true);
pickImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
pickImageIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
startActivityForResult(pickImageIntent, RESULT_LOAD_IMAGE);
Before I run above code, I want to do something like this:
imageWidth = myBitmap.getWidth();
imageHeight = myBitmap.getHeight();
myFace = new FaceDetector.Face[numberOfFace];
myFaceDetect = new FaceDetector(imageWidth, imageHeight,
numberOfFace);
numberOfFaceDetected = myFaceDetect.findFaces(myBitmap, myFace);
But I am confuse about how to do it. Anyone can help me? Thanks.