1
我无法使用相机拍摄照片并使其检测到任何脸部。我在屏幕上显示图片,并可以在图像上清晰地看到我的脸,但从未检测到它。我的logcat打印出“找不到脸!”无法检测到来自相机的图像中的脸部
public void takePictureNoPreview(Context context) {
camera = openFrontFacingCamera();
if (camera != null) {
try {
SurfaceTexture dummy = new SurfaceTexture(0);
camera.setPreviewTexture(dummy);
camera.startPreview();
camera.takePicture(null, null, this);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
} else {
// booo, failed!
}
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.i(LOG_TAG, "Picture taken");
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, options);
FaceDetector faceDetector = new FaceDetector(bitmap.getWidth(),
bitmap.getHeight(), 1);
Face[] faces = new Face[1];
int foundFaces = faceDetector.findFaces(bitmap, faces);
if (foundFaces > 0) {
Log.i(LOG_TAG, "Found a face!");
} else {
Log.i(LOG_TAG, "No face found!");
}
camera.release();
sendImageToActivity(bitmap);
}
你有没有找到“找不到脸!”信息?还是别的东西没有用? – Jave
它打印“找不到脸!” – Xample
你可以发布样本照片吗? – m0skit0