Code example for FaceDetector

Methods: findFaces

0
	public void onPreviewFrame(byte[] data, Camera camera) {
		yuv2rgb.getFast(data, rgbBuffer);
 
		final int w = previewSize.width, h = previewSize.height;
		bitmap.setPixels(rgbBuffer, 0, w, 0, 0, w, h);
		if (detector.findFaces(bitmap, face) == 1) {
			FaceDetector.Face f = face[0];
			f.getMidPoint(point);
			float x = 2f * point.x / previewSize.width - 1f;
			float y = -2f * point.y / previewSize.height + 1f;
			float fw = 1.7f * f.eyesDistance() / previewSize.width;
			float fh = 2.2f * f.eyesDistance() / previewSize.height;
			rect[0] = x - fw; rect[1] = y - fh;
			rect[2] = x + fw; rect[3] = y - fh;
			rect[4] = x - fw; rect[5] = y + fh;
			rect[6] = x + fw; rect[7] = y + fh;
			paintView.face(rect);
		} else { 
			paintView.noface();
		}