我有MediaStore.images.media
的图像列表。有可能检测自拍照吗?我读过关于mlkit自拍分割,但我猜它是关于改变照片?
您可以尝试从图像中获取EXIF数据并比较一些参数。将以下依赖项添加到构建中。gradle如果你想使用ExifInterface:
implementation "androidx.exifinterface:exifinterface:1.3.3"
之后,您可以从下面的代码中获得EXIF数据:
Uri gfgUri; // the file uri
InputStream gfgIn;
try {
gfgIn = getContentResolver().openInputStream(gfgUri);
ExifInterface exifInterface = new ExifInterface(gfgIn);
// Extract the EXIF tag here
} catch (IOException e) {
// Handle any errors
} finally {
if (gfgIn != null) {
try {
gfgIn.close();
} catch (IOException ignored) {}
}
}
例如,您可以使用照片分辨率来比较稀有照片和正面照片。分辨率通常不同:面向用户的摄像头的分辨率低于背面的摄像头。
我从gsmarena.com上摘取的几个例子:
- Google Pixel 6 Pro:主:50 MP;自拍:11.1 MP;
- 苹果iPhone SE(2022):主:12mp;自拍:7mp;
- 三星Galaxy S22 5G:主:50 MP;自拍:10mp;