From 445876d96b852b05c6327e6979cb9fe7bc10958a Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Wed, 8 Feb 2023 21:35:15 +0530 Subject: [PATCH] Updated formatting --- mediapipe/tasks/ios/vision/core/sources/MPPImage.h | 12 ++++++------ mediapipe/tasks/ios/vision/core/sources/MPPImage.m | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/mediapipe/tasks/ios/vision/core/sources/MPPImage.h b/mediapipe/tasks/ios/vision/core/sources/MPPImage.h index 6faaa0d31..08364ad0b 100644 --- a/mediapipe/tasks/ios/vision/core/sources/MPPImage.h +++ b/mediapipe/tasks/ios/vision/core/sources/MPPImage.h @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#import + #import #import #import @@ -72,8 +74,7 @@ NS_SWIFT_NAME(MPImage) * @return A new `MPPImage` instance with the given image as the source. `nil` if the given * `image` is `nil` or invalid. */ -- (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. @@ -110,8 +111,7 @@ NS_SWIFT_NAME(MPImage) * @return A new `MPPImage` instance with the given pixel buffer as the source. `nil` if the * given pixel buffer is `nil` or invalid. */ -- (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer - error:(NSError **)error; +- (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer error:(NSError **)error; /** * Initializes an `MPPImage` object with the given pixel buffer and orientation. @@ -130,7 +130,7 @@ NS_SWIFT_NAME(MPImage) */ - (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer orientation:(UIImageOrientation)orientation - NS_DESIGNATED_INITIALIZER; + error:(NSError **)error NS_DESIGNATED_INITIALIZER; /** * Initializes an `MPPImage` object with the given sample buffer. @@ -166,7 +166,7 @@ NS_SWIFT_NAME(MPImage) */ - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer orientation:(UIImageOrientation)orientation - NS_DESIGNATED_INITIALIZER; + error:(NSError **)error NS_DESIGNATED_INITIALIZER; /** Unavailable. */ - (instancetype)init NS_UNAVAILABLE; diff --git a/mediapipe/tasks/ios/vision/core/sources/MPPImage.m b/mediapipe/tasks/ios/vision/core/sources/MPPImage.m index b8591953a..1f5104ef7 100644 --- a/mediapipe/tasks/ios/vision/core/sources/MPPImage.m +++ b/mediapipe/tasks/ios/vision/core/sources/MPPImage.m @@ -13,6 +13,7 @@ // limitations under the License. #import "mediapipe/tasks/ios/vision/core/sources/MPPImage.h" +#import "mediapipe/tasks/ios/common/sources/MPPCommon.h" #import "mediapipe/tasks/ios/common/utils/sources/MPPCommonUtils.h" NS_ASSUME_NONNULL_BEGIN @@ -20,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @implementation MPPImage - (nullable instancetype)initWithUIImage:(UIImage *)image error:(NSError **)error { - return [self initWithUIImage:image orientation:image.orientation error:error]; + return [self initWithUIImage:image orientation:image.imageOrientation error:error]; } - (nullable instancetype)initWithUIImage:(UIImage *)image @@ -30,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN [MPPCommonUtils createCustomError:error withCode:MPPTasksErrorCodeInvalidArgumentError description:@"Image cannot be nil."]; + return nil; } if (image.CGImage == NULL) { [MPPCommonUtils createCustomError:error @@ -41,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN self = [super init]; if (self) { - _imageSourceType = MPPTaskImageSourceTypeImage; + _imageSourceType = MPPImageSourceTypeImage; _orientation = orientation; _image = image; _width = image.size.width * image.scale; @@ -66,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN self = [super init]; if (self != nil) { - _imageSourceType = MPPTaskImageSourceTypePixelBuffer; + _imageSourceType = MPPImageSourceTypePixelBuffer; _orientation = orientation; CVPixelBufferRetain(pixelBuffer); _pixelBuffer = pixelBuffer; @@ -78,7 +80,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer error:(NSError **)error { - return [self initWithSampleBuffer:sampleBuffer orientation:UIImageOrientation error:error]; + return [self initWithSampleBuffer:sampleBuffer orientation:UIImageOrientationUp error:error]; } - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer @@ -99,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN self = [super init]; if (self != nil) { - _imageSourceType = MPPTaskImageSourceTypeSampleBuffer; + _imageSourceType = MPPImageSourceTypeSampleBuffer; _orientation = orientation; CFRetain(sampleBuffer); _sampleBuffer = sampleBuffer;