FaceDetectorpublic class FaceDetector extends Object Identifies the faces of people in a
{@link android.graphics.Bitmap} graphic object. |
Fields Summary |
---|
private static boolean | sInitialized | private int | mFD | private int | mSDK | private int | mDCR | private int | mWidth | private int | mHeight | private int | mMaxFaces | private byte[] | mBWBuffer |
Constructors Summary |
---|
public FaceDetector(int width, int height, int maxFaces)Creates a FaceDetector, configured with the size of the images to
be analysed and the maximum number of faces that can be detected.
These parameters cannot be changed once the object is constructed.
if (!sInitialized) {
return;
}
fft_initialize(width, height, maxFaces);
mWidth = width;
mHeight = height;
mMaxFaces = maxFaces;
mBWBuffer = new byte[width * height];
|
Methods Summary |
---|
private native void | fft_destroy()
| private native int | fft_detect(android.graphics.Bitmap bitmap)
| private native void | fft_get_face(android.media.FaceDetector$Face face, int i)
| private native int | fft_initialize(int width, int height, int maxFaces)
| protected void | finalize()
fft_destroy();
| public int | findFaces(android.graphics.Bitmap bitmap, android.media.FaceDetector$Face[] faces)Finds all the faces found in a given {@link android.graphics.Bitmap}.
The supplied array is populated with {@link FaceDetector.Face}s for each
face found. The bitmap must be in 565 format (for now).
if (!sInitialized) {
return 0;
}
if (bitmap.getWidth() != mWidth || bitmap.getHeight() != mHeight) {
throw new IllegalArgumentException(
"bitmap size doesn't match initialization");
}
if (faces.length < mMaxFaces) {
throw new IllegalArgumentException(
"faces[] smaller than maxFaces");
}
int numFaces = fft_detect(bitmap);
if (numFaces >= mMaxFaces)
numFaces = mMaxFaces;
for (int i=0 ; i<numFaces ; i++) {
if (faces[i] == null)
faces[i] = new Face();
fft_get_face(faces[i], i);
}
return numFaces;
| private static native void | nativeClassInit()
|
|