Tutorial: Simple implementation of the Android SDK's FaceDetector and FaceDetector.Face classes.
First a few things about the FaceDetector class.
- According to the documentation, Bitmaps need to use the RGB565 format. However it seems to work with bitmaps using the default constructors for that class but I used mode RGB565 just in case.
- Seems that the class uses eyes as the "facial detection" this means there is no other detail (face dimensions, mouth location, etc.) and faces that are taken from the side will not be detected. Sunglasses/glasses seem to interfere with detection.
- The bigger the image the easier it can detect images. However there is a limit to how big of an image you can load into Android's memory. The images I used were all under 1000x1000 but at least 400x300.
- Regardless of how many faces you specify in the FaceDetector constructor, it seems that it takes the same amount of time, i.e. if there are only 5 faces in the image you won't be penalized for asking for 10.
- The FaceDetector.Face class cannot be extended, all its constructors are privatized, which means you cannot change the Face class's CONFIDENCE_THRESHOLD.
- Maximum number of faces you can ask for is 64 after that it won't bother loading the face detection.
- pose() in class FaceDetector.Face does not seem to do anything.
Note you must change R.drawable.bao102 with the actual resource image you use.