How can a phone photo's orientation tag affect annotations?
exif_transpose applies the EXIF orientation to the pixels and removes the applied orientation information.
Pixel experiment and interpretation
Simulate a landscape file marked orientation 6. Normalize it before measuring dimensions or boxes so viewers and training code share coordinates.
from PIL import Image, ImageOps
im=Image.new('L',(4,2))
im.getexif()[274]=6
out=ImageOps.exif_transpose(im)
(out.size,out.getexif().get(274))Result ((2, 4), None)
中文
手机照片方向标签会怎样影响标注坐标?
exif_transpose 依照 EXIF 方向对像素作变换,并清除已经应用的方向信息。
像素实验与适用边界
模拟相机写入方向 6 的横向文件。先归一化方向,再测量宽高和标注框,可避免查看器与训练程序使用两套坐标。
from PIL import Image, ImageOps
im=Image.new('L',(4,2))
im.getexif()[274]=6
out=ImageOps.exif_transpose(im)
(out.size,out.getexif().get(274))结果 ((2, 4), None)