[英]How to get PointCloud and Pose using ARCore on android?
[英]How to get the real picture size in mm using Android with arcore
我想用android中的arcore將圖片的像素寬高轉換為毫米,怎么辦?
嘗試這個,
fun getImageWidthAndHeight(context: Context, uri: Uri): Pair<Float, Float> {
val exif = try {
context.contentResolver.openInputStream(uri)?.let {
ExifInterface(it)
} ?: return 0f to 0f
} catch (e: FileNotFoundException) {
return 0f to 0f
}
val width = exif.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, 0).toFloat()
val height = exif.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, 0).toFloat()
return when (
exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
) {
ExifInterface.ORIENTATION_ROTATE_90, ExifInterface.ORIENTATION_ROTATE_270 -> height to width
else -> width to height
}
}
...
val (width, height) = getImageWidthAndHeight(context, uri)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.