Updated formatting

This commit is contained in:
Prianka Liz Kariat 2023-02-08 21:35:15 +05:30
parent be829eb276
commit 445876d96b
2 changed files with 13 additions and 11 deletions

View File

@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#import <Foundation/Foundation.h>
#import <CoreMedia/CoreMedia.h> #import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h> #import <CoreVideo/CoreVideo.h>
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@ -72,8 +74,7 @@ NS_SWIFT_NAME(MPImage)
* @return A new `MPPImage` instance with the given image as the source. `nil` if the given * @return A new `MPPImage` instance with the given image as the source. `nil` if the given
* `image` is `nil` or invalid. * `image` is `nil` or invalid.
*/ */
- (nullable instancetype)initWithUIImage:(UIImage *)image - (nullable instancetype)initWithUIImage:(UIImage *)image error:(NSError **)error;
error:(NSError **)error;
/** /**
* Initializes an `MPPImage` object with the given `UIImabe` and orientation. * 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 * @return A new `MPPImage` instance with the given pixel buffer as the source. `nil` if the
* given pixel buffer is `nil` or invalid. * given pixel buffer is `nil` or invalid.
*/ */
- (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer - (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer error:(NSError **)error;
error:(NSError **)error;
/** /**
* Initializes an `MPPImage` object with the given pixel buffer and orientation. * Initializes an `MPPImage` object with the given pixel buffer and orientation.
@ -130,7 +130,7 @@ NS_SWIFT_NAME(MPImage)
*/ */
- (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer - (nullable instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer
orientation:(UIImageOrientation)orientation orientation:(UIImageOrientation)orientation
NS_DESIGNATED_INITIALIZER; error:(NSError **)error NS_DESIGNATED_INITIALIZER;
/** /**
* Initializes an `MPPImage` object with the given sample buffer. * Initializes an `MPPImage` object with the given sample buffer.
@ -166,7 +166,7 @@ NS_SWIFT_NAME(MPImage)
*/ */
- (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer
orientation:(UIImageOrientation)orientation orientation:(UIImageOrientation)orientation
NS_DESIGNATED_INITIALIZER; error:(NSError **)error NS_DESIGNATED_INITIALIZER;
/** Unavailable. */ /** Unavailable. */
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
#import "mediapipe/tasks/ios/vision/core/sources/MPPImage.h" #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" #import "mediapipe/tasks/ios/common/utils/sources/MPPCommonUtils.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -20,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation MPPImage @implementation MPPImage
- (nullable instancetype)initWithUIImage:(UIImage *)image error:(NSError **)error { - (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 - (nullable instancetype)initWithUIImage:(UIImage *)image
@ -30,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
[MPPCommonUtils createCustomError:error [MPPCommonUtils createCustomError:error
withCode:MPPTasksErrorCodeInvalidArgumentError withCode:MPPTasksErrorCodeInvalidArgumentError
description:@"Image cannot be nil."]; description:@"Image cannot be nil."];
return nil;
} }
if (image.CGImage == NULL) { if (image.CGImage == NULL) {
[MPPCommonUtils createCustomError:error [MPPCommonUtils createCustomError:error
@ -41,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init]; self = [super init];
if (self) { if (self) {
_imageSourceType = MPPTaskImageSourceTypeImage; _imageSourceType = MPPImageSourceTypeImage;
_orientation = orientation; _orientation = orientation;
_image = image; _image = image;
_width = image.size.width * image.scale; _width = image.size.width * image.scale;
@ -66,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_imageSourceType = MPPTaskImageSourceTypePixelBuffer; _imageSourceType = MPPImageSourceTypePixelBuffer;
_orientation = orientation; _orientation = orientation;
CVPixelBufferRetain(pixelBuffer); CVPixelBufferRetain(pixelBuffer);
_pixelBuffer = pixelBuffer; _pixelBuffer = pixelBuffer;
@ -78,7 +80,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer
error:(NSError **)error { error:(NSError **)error {
return [self initWithSampleBuffer:sampleBuffer orientation:UIImageOrientation error:error]; return [self initWithSampleBuffer:sampleBuffer orientation:UIImageOrientationUp error:error];
} }
- (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer - (nullable instancetype)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer
@ -99,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init]; self = [super init];
if (self != nil) { if (self != nil) {
_imageSourceType = MPPTaskImageSourceTypeSampleBuffer; _imageSourceType = MPPImageSourceTypeSampleBuffer;
_orientation = orientation; _orientation = orientation;
CFRetain(sampleBuffer); CFRetain(sampleBuffer);
_sampleBuffer = sampleBuffer; _sampleBuffer = sampleBuffer;