나는 CALayer
에 그리기 위해 CIFaceFeature
에서 반환 된 CGPoint
결과를 변환하는 방법을 알아 내려고하고 있습니다. 이전에는 물건을 더 쉽게 만들기 위해 이미지를 0으로 정규화했지만 가로 모드로 고정 된 장치로 촬영 한 이미지에는 문제가 발생합니다.CGFP 결과가 CIFaceFeature에서 반환 됨
나는이 작업을 잠시 동안 성공하지 못했고 작업에 대한 내 이해가 잘못되었거나 내 접근 방식이 올바르지 않거나 둘 다 맞는지 잘 모르겠습니다. 내가있는 CGPoint 회전하려고 아래의 코드에서 CIDetector
featuresInImage:options:
방법
A dictionary that specifies the orientation of the image. The detection is
adjusted to account for the image orientation but the coordinates in the
returned feature objects are based on those of the image.
에 대한 설명서에 따르면
: 여기에 내가 생각하는 것은 정확 UIImageView를 오버레이하는 CAShape 레이어를 통해 그릴 수 있습니다.
내가하고있는 것 (... 또는 내가하고있는 것 같아요 ...)은 왼쪽 눈 CGPoint를보기의 중심으로 90도 회전 한 다음 원래 위치로 되돌려 번역하는 것입니다. 이것은 정확하지 않지만 내가 어디로 잘못 가고 있는지 알지 못합니다. 내 방식이 잘못되었거나 구현하는 방식입니까? -
#define DEGREES_TO_RADIANS(angle) ((angle)/180.0 * M_PI)
이 leftEyePosition가 CGPoint이 게시물에서
CGAffineTransform transRot = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));
float x = self.center.x;
float y = self.center.y;
CGAffineTransform tCenter = CGAffineTransformMakeTranslation(-x, -y);
CGAffineTransform tOffset = CGAffineTransformMakeTranslation(x, y);
leftEyePosition = CGPointApplyAffineTransform(leftEyePosition, tCenter);
leftEyePosition = CGPointApplyAffineTransform(leftEyePosition, transRot);
leftEyePosition = CGPointApplyAffineTransform(leftEyePosition, tOffset);
입니다 : https://stackoverflow.com/a/14491293/840992, 나는 imageOrientation
방향
애플 /있는 UIImage에 따라 회전을 확인해야합니다. imageOrientation Jpeg/File kCGImagePropertyOrientation
UIImageOrientationUp = 0 = Landscape left = 1 UIImageOrientationDown = 1 = Landscape right = 3 UIImageOrientationLeft = 2 = Portrait down = 8 UIImageOrientationRight = 3 = Portrait up = 6
메시지가 오후 4시 9분
아니요, 작동하지 않습니다. 좌표를 회전해야합니다 (저는 믿습니다). 나는 그 작업이 무엇인지를 보여주기 위해 몇 가지 이미지를 추가했다. –
@skinnyTOD, 죄송합니다. 저는 잘못 생각했습니다.이 변형은 normalize (imageOrientation 0 방향 설정) 만하면 작동합니다. 나는 곧 업데이트를 게시 할 것이다. – foundry