这是我编写的用于运行android脸部检测器的代码。不幸的是,它没有找到任何。我已经把它放在onPreviewFrame(数据,相机)中。Android FaceDetector.findFaces找不到任何脸部
Camera.Parameters parameters = camera.getParameters();
Camera.Size size = parameters.getPreviewSize();
YuvImage image = new YuvImage(data, ImageFormat.NV21, size.width, size.height, null);
Rect rectangle = new Rect(0, 0, size.width, size.height);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
int quality = 100;
image.compressToJpeg(rectangle, quality, stream);
Bitmap bitmap = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
FaceDetector detector = new FaceDetector(size.width, size.height, 5);
FaceDetector.Face[] faces = new FaceDetector.Face[5];
int numFaces = detector.findFaces(bitmap, faces);
textView.setText(“numFaces = ” + numFaces);
任何想法?修复?
+0
你有没有倾销过你的位图并检查它是否正确? –
+0
是的,我已经做到了。 –