【发布时间】:2020-10-04 00:28:59
【问题描述】:
我想将图像流(最好是 30fps)保存到设备。我遇到了这个post。
如何使用cameraX 转储YUV_420_888 格式的图像而不用JPEG 编码?
另外,如果有人能建议任何保存突发图像的方向,我会很高兴。
到目前为止,我只是通过按钮的onclick 保存图像
findViewById(R.id.capture_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
File file = new File(getExternalFilesDir(Environment.DIRECTORY_PICTURES),
"Image_" + System.currentTimeMillis() + ".jpg");
imageCapture.takePicture(file, new ImageCapture.OnImageSavedListener() {
@Override
public void onImageSaved(@NonNull File file) {
Toast.makeText(CameraCaptureActivity.this, "Photo saved as " + file.getAbsolutePath(), Toast.LENGTH_SHORT).show();
}
@Override
public void onError(@NonNull ImageCapture.ImageCaptureError imageCaptureError, @NonNull String message, @Nullable Throwable cause) {
Toast.makeText(CameraCaptureActivity.this, "Couldn't save photo: " + message, Toast.LENGTH_SHORT).show();
if (cause != null)
cause.printStackTrace();
}
});
}
});
【问题讨论】:
-
请详细说明“保存图像流”和“突发图像”(图像数量有多大?)。您目前的方法有什么问题? (无法转储为 YUV_420_888 格式?还是只保存一张图片?)
-
@samabcde “保存图像流”我的意思主要是在磁盘上以 30fps 的速度保存图像。目前,我一次只将图像保存到磁盘,
标签: java android android-camera android-camerax