Skip to content

Commit

Permalink
add rotation to ios
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmartin8a committed Oct 13, 2023
1 parent 00ff6f1 commit b2439a5
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ - (MLKFaceDetector*)initialize:(FlutterMethodCall *)call {
}

- (void)handleDetection:(FlutterMethodCall *)call result:(FlutterResult)result {
int rotation = [call.arguments[@"imageData"][@"metadata"][@"rotation"] intValue];
UIImageOrientation imageOrientation = [self imageOrientationFromRotation:rotation];
MLKVisionImage *image = [MLKVisionImage visionImageFromData:call.arguments[@"imageData"]];
image.orientation = imageOrientation;

NSString *uid = call.arguments[@"id"];
MLKFaceDetector *detector = [instances objectForKey:uid];
Expand Down Expand Up @@ -170,6 +173,19 @@ - (void)handleDetection:(FlutterMethodCall *)call result:(FlutterResult)result {
}];
}

- (UIImageOrientation)imageOrientationFromRotation:(int)rotation {
switch (rotation) {
case 90:
return UIImageOrientationLeft; // Rotates the image 90 degrees to the left
case 180:
return UIImageOrientationDown; // Rotates the image 180 degrees
case 270:
return UIImageOrientationRight; // Rotates the image 90 degrees to the right
default:
return UIImageOrientationUp; // Default orientation (no rotation)
}
}

- (id)getLandmarkPosition:(MLKFace *)face landmark:(MLKFaceLandmarkType)landmarkType {
MLKFaceLandmark *landmark = [face landmarkOfType:landmarkType];
if (landmark) {
Expand Down

0 comments on commit b2439a5

Please sign in to comment.