で描画するために、CGPoint
から返された結果を変換する方法を理解しようとしています。以前は、物事を簡単にするために画像を0回転に正規化していましたが、横向きモードで保持されたデバイスで撮影された画像では問題が発生します。CIFaceFeature
CALayer
私はこれにしばらく取り組んできましたが成功せず、タスクの理解が間違っているのか、アプローチが間違っているのか、あるいはその両方なのかわかりません。これが私が正しいと思うことです:
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を描画するために、CGPointを回転させようとしています。
私が行っていること(...または私が行っていると思う...)は、左目の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に基づいて回転を行う必要があります
オリエンテーション
Apple / 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
メッセージは2013年2月1日午後4時9分にskinnyTODによって編集されました