我知道有很多问题询问你是否可以设置快门速度/ iso等等,而且似乎不可能......
但是,至少可以获得像快门速度,光圈和iso 这样的值吗? (不先拍照并扫描exif值......)
我的意思是对系统/硬件当前设置的值进行实时预览。
答案 0 :(得分:2)
使用camera2,您可以查看通过CaptureResult回调生成的onCaptureCompleted个对象。
如果设备支持READ_SENSOR_SETTINGS功能,则CaptureResult SENSOR_EXPOSURE_TIME和SENSOR_SENSITIVITY字段将具有自动曝光例程选择的曝光和增益的当前值。
否则,您需要捕获JPEG图像并查看其EXIF,如其他答案所述。
答案 1 :(得分:0)
关于iso值,请参阅此问题Android Camera API ISO Setting?,关于快门请参阅此帖https://stackoverflow.com/a/3550573/1860199
答案 2 :(得分:0)
你可以使用Camera2 Api设置快门速度和曝光时间,我想,我不太了解它。但是,可以从拍摄照片时从相机获取的byte []数据中读取exif数据。
如果有人希望获得当前,而不是使用Camera1 Api或Camera2,ISO,曝光时间和快门速度值设置的那个。对于Camera1 Api,使用ExifInterface将数据写入FileOutputStream并读取exif数据。您可以使用此方法将每个元数据写入字节。获取数据后,您可以使用Bitmap.compress();
private PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
long startTime = System.currentTimeMillis();
File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
FileOutputStream fos = null;
Bitmap bitmap = null;
if (pictureFile == null) {
return;
}
try {
fos = new FileOutputStream(pictureFile);
// TODO Writes Exif Data to image
System.out.println("************ EXIF ************");
fos.write(data);
ExifInterface exifInterface = new ExifInterface(pictureFile.getAbsolutePath());
String model = exifInterface.getAttribute(ExifInterface.TAG_MODEL);
String make = exifInterface.getAttribute(ExifInterface.TAG_MAKE);
String flash = exifInterface.getAttribute(ExifInterface.TAG_FLASH);
String exposureMode = exifInterface.getAttribute(ExifInterface.TAG_EXPOSURE_MODE);
String focalLengthString = exifInterface.getAttribute(ExifInterface.TAG_FOCAL_LENGTH);
String isoString = exifInterface.getAttribute(ExifInterface.TAG_ISO_SPEED_RATINGS);
String apertureString = exifInterface.getAttribute(ExifInterface.TAG_APERTURE_VALUE);
String exposureTimeString = exifInterface.getAttribute(ExifInterface.TAG_EXPOSURE_TIME);
String shutterSpeedString = exifInterface.getAttribute(ExifInterface.TAG_SHUTTER_SPEED_VALUE);
Double focalLength = exifInterface.getAttributeDouble(ExifInterface.TAG_FOCAL_LENGTH, 0);
Double iso = exifInterface.getAttributeDouble(ExifInterface.TAG_ISO_SPEED_RATINGS, 0);
Double aperture = exifInterface.getAttributeDouble(ExifInterface.TAG_APERTURE_VALUE, 0);
Double exposureTime = exifInterface.getAttributeDouble(ExifInterface.TAG_EXPOSURE_TIME, 0);
Double shutterSpeed = exifInterface.getAttributeDouble(ExifInterface.TAG_SHUTTER_SPEED_VALUE, 0);
System.out.println("CameraActivity model " + model);
System.out.println("CameraActivity make " + make);
System.out.println("CameraActivity flash " + flash);
System.out.println("CameraActivity exposureMode " + exposureMode);
System.out.println("CameraActivity focalLengthString " + focalLengthString + ", focalLength " + focalLength);
System.out.println("CameraActivity isoString " + isoString + ", iso " + iso);
System.out.println("CameraActivity apertureString " + apertureString + ", aperture " + aperture);
System.out.println("CameraActivity exposureTimeString " + exposureTimeString + ", exposureTime " + exposureTime);
System.out.println("CameraActivity shutterSpeedString " + shutterSpeedString + ", shutterSpeed " + shutterSpeed);
System.out.println("************ EXIF ************");
} catch (FileNotFoundException e) {
System.out.println("CameraActivity onPictureTaken() File not found: " + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(pictureFile)));
fos = null;
pictureFile = null;
}
这些是我的设备获得的结果
************ EXIF ************
CameraActivity model General Mobile 4G Dual
CameraActivity make General Mobile
CameraActivity flash 24
CameraActivity exposureMode 0
CameraActivity focalLengthString 1150/1000, focalLength 1.15
CameraActivity isoString 262, iso 262.0
CameraActivity apertureString 260/100, aperture 2.6
CameraActivity exposureTimeString 0.03333333333333333, exposureTime 0.03333333333333333
CameraActivity shutterSpeedString 4906/1000, shutterSpeed 4.906