使用CIDetector
检测图像中的人脸时,需要根据文档指定恰好在TIFF和EXIF规范中指定的图像方向,这意味着它不同于UIImageOrientation
。谷歌为我找到了下面的功能,我试了一下,但发现它看起来不正确,或者我可能错过了其他的东西,因为有时方向是关闭的。任何人都知道发生了什么事?看起来,只要一张照片从iDevice导出,然后导入到另一个iDevice,方向信息就会丢失/更改,从而导致一些方向不匹配。UIImageOrientation to CIDetectorImageOrientation
- (int) metadataOrientationForUIImageOrientation:(UIImageOrientation)orientation
{
switch (orientation) {
case UIImageOrientationUp: // the picture was taken with the home button is placed right
return 1;
case UIImageOrientationRight: // bottom (portrait)
return 6;
case UIImageOrientationDown: // left
return 3;
case UIImageOrientationLeft: // top
return 8;
default:
return 1;
}
}