Merge pull request #4600 from priankakariatyml:ios-orientation-fix
PiperOrigin-RevId: 546358930
This commit is contained in:
commit
df3f4167ae
|
@ -25,7 +25,7 @@
|
||||||
static NSDictionary *const kPortraitImage =
|
static NSDictionary *const kPortraitImage =
|
||||||
@{@"name" : @"portrait", @"type" : @"jpg", @"orientation" : @(UIImageOrientationUp)};
|
@{@"name" : @"portrait", @"type" : @"jpg", @"orientation" : @(UIImageOrientationUp)};
|
||||||
static NSDictionary *const kPortraitRotatedImage =
|
static NSDictionary *const kPortraitRotatedImage =
|
||||||
@{@"name" : @"portrait_rotated", @"type" : @"jpg", @"orientation" : @(UIImageOrientationRight)};
|
@{@"name" : @"portrait_rotated", @"type" : @"jpg", @"orientation" : @(UIImageOrientationLeft)};
|
||||||
static NSDictionary *const kCatImage = @{@"name" : @"cat", @"type" : @"jpg"};
|
static NSDictionary *const kCatImage = @{@"name" : @"cat", @"type" : @"jpg"};
|
||||||
static NSString *const kShortRangeBlazeFaceModel = @"face_detection_short_range";
|
static NSString *const kShortRangeBlazeFaceModel = @"face_detection_short_range";
|
||||||
static NSArray<NSArray *> *const kPortraitExpectedKeypoints = @[
|
static NSArray<NSArray *> *const kPortraitExpectedKeypoints = @[
|
||||||
|
|
|
@ -343,7 +343,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
MPPGestureRecognizer *gestureRecognizer =
|
MPPGestureRecognizer *gestureRecognizer =
|
||||||
[self createGestureRecognizerWithOptionsSucceeds:gestureRecognizerOptions];
|
[self createGestureRecognizerWithOptionsSucceeds:gestureRecognizerOptions];
|
||||||
MPPImage *mppImage = [self imageWithFileInfo:kPointingUpRotatedImage
|
MPPImage *mppImage = [self imageWithFileInfo:kPointingUpRotatedImage
|
||||||
orientation:UIImageOrientationRight];
|
orientation:UIImageOrientationLeft];
|
||||||
|
|
||||||
MPPGestureRecognizerResult *gestureRecognizerResult = [gestureRecognizer recognizeImage:mppImage
|
MPPGestureRecognizerResult *gestureRecognizerResult = [gestureRecognizer recognizeImage:mppImage
|
||||||
error:nil];
|
error:nil];
|
||||||
|
|
|
@ -402,7 +402,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
];
|
];
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kBurgerRotatedImage
|
MPPImage *image = [self imageWithFileInfo:kBurgerRotatedImage
|
||||||
orientation:UIImageOrientationRight];
|
orientation:UIImageOrientationLeft];
|
||||||
|
|
||||||
[self assertResultsOfClassifyImage:image
|
[self assertResultsOfClassifyImage:image
|
||||||
usingImageClassifier:imageClassifier
|
usingImageClassifier:imageClassifier
|
||||||
|
@ -425,7 +425,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
displayName:nil] ];
|
displayName:nil] ];
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kMultiObjectsRotatedImage
|
MPPImage *image = [self imageWithFileInfo:kMultiObjectsRotatedImage
|
||||||
orientation:UIImageOrientationRight];
|
orientation:UIImageOrientationLeft];
|
||||||
|
|
||||||
// roi around folding chair
|
// roi around folding chair
|
||||||
MPPImageClassifierResult *imageClassifierResult =
|
MPPImageClassifierResult *imageClassifierResult =
|
||||||
|
|
|
@ -438,7 +438,7 @@ static NSString *const kLiveStreamTestsDictExpectationKey = @"expectation";
|
||||||
[[MPPObjectDetectorResult alloc] initWithDetections:detections timestampInMilliseconds:0];
|
[[MPPObjectDetectorResult alloc] initWithDetections:detections timestampInMilliseconds:0];
|
||||||
|
|
||||||
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsRotatedImage
|
MPPImage *image = [self imageWithFileInfo:kCatsAndDogsRotatedImage
|
||||||
orientation:UIImageOrientationRight];
|
orientation:UIImageOrientationLeft];
|
||||||
|
|
||||||
[self assertResultsOfDetectInImage:image
|
[self assertResultsOfDetectInImage:image
|
||||||
usingObjectDetector:objectDetector
|
usingObjectDetector:objectDetector
|
||||||
|
|
|
@ -62,10 +62,10 @@ NS_SWIFT_NAME(MPImage)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes an `MPPImage` object with the given `UIImage`.
|
* Initializes an `MPPImage` object with the given `UIImage`.
|
||||||
* The orientation of the newly created `MPPImage` will be `UIImageOrientationUp`.
|
* The orientation of the newly created `MPPImage` will be equal to the `imageOrientation` of
|
||||||
* Hence, if this image is used as input for any MediaPipe vision tasks, inference will be
|
* `UIImage` and when sent to the vision tasks for inference, rotation will be applied accordingly.
|
||||||
* performed on the it without any rotation. To create an `MPPImage` with a different orientation,
|
* To create an `MPPImage` with an orientation different from its `imageOrientation`, please use
|
||||||
* please use `[MPPImage initWithImage:orientation:error:]`.
|
* `[MPPImage initWithImage:orientation:error:]`.
|
||||||
*
|
*
|
||||||
* @param image The image to use as the source. Its `CGImage` property must not be `NULL`.
|
* @param image The image to use as the source. Its `CGImage` property must not be `NULL`.
|
||||||
* @param error An optional error parameter populated when there is an error in initializing the
|
* @param error An optional error parameter populated when there is an error in initializing the
|
||||||
|
@ -77,14 +77,19 @@ NS_SWIFT_NAME(MPImage)
|
||||||
- (nullable instancetype)initWithUIImage:(UIImage *)image error:(NSError **)error;
|
- (nullable instancetype)initWithUIImage:(UIImage *)image error:(NSError **)error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes an `MPPImage` object with the given `UIImabe` and orientation.
|
* Initializes an `MPPImage` object with the given `UIImage` and orientation. The given orientation
|
||||||
|
* will be used to calculate the rotation to be applied to the `UIImage` before inference is
|
||||||
|
* performed on it by the vision tasks. The `imageOrientation` stored in the `UIImage` is ignored
|
||||||
|
* when `MPImage` objects created by this method are sent to the vision tasks for inference. Use
|
||||||
|
* `[MPPImage initWithImage:orientation:error:]` to initialize images with the `imageOrientation` of
|
||||||
|
* `UIImage`.
|
||||||
*
|
*
|
||||||
* If the newly created `MPPImage` is used as input for any MediaPipe vision tasks, inference
|
* If the newly created `MPPImage` is used as input for any MediaPipe vision tasks, inference
|
||||||
* will be performed on a copy of the image rotated according to the orientation.
|
* will be performed on a copy of the image rotated according to the orientation.
|
||||||
*
|
*
|
||||||
* @param image The image to use as the source. Its `CGImage` property must not be `NULL`.
|
* @param image The image to use as the source. Its `CGImage` property must not be `NULL`.
|
||||||
* @param orientation The display orientation of the image. This will be stored in the property
|
* @param orientation The display orientation of the image. This will be stored in the property
|
||||||
* `orientation`. `MPPImage`.
|
* `orientation` `MPPImage` and will override the `imageOrientation` of the passed in `UIImage`.
|
||||||
* @param error An optional error parameter populated when there is an error in initializing the
|
* @param error An optional error parameter populated when there is an error in initializing the
|
||||||
* `MPPImage`.
|
* `MPPImage`.
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,13 +30,13 @@ using ::mediapipe::tasks::core::PacketsCallback;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/** Rotation degrees for a 90 degree rotation to the right. */
|
/** Rotation degrees for a 90 degree rotation to the right. */
|
||||||
static const NSInteger kMPPOrientationDegreesRight = -90;
|
static const NSInteger kMPPOrientationDegreesRight = -270;
|
||||||
|
|
||||||
/** Rotation degrees for a 180 degree rotation. */
|
/** Rotation degrees for a 180 degree rotation. */
|
||||||
static const NSInteger kMPPOrientationDegreesDown = -180;
|
static const NSInteger kMPPOrientationDegreesDown = -180;
|
||||||
|
|
||||||
/** Rotation degrees for a 90 degree rotation to the left. */
|
/** Rotation degrees for a 90 degree rotation to the left. */
|
||||||
static const NSInteger kMPPOrientationDegreesLeft = -270;
|
static const NSInteger kMPPOrientationDegreesLeft = -90;
|
||||||
|
|
||||||
static NSString *const kTaskPrefix = @"com.mediapipe.tasks.vision";
|
static NSString *const kTaskPrefix = @"com.mediapipe.tasks.vision";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user