Bug fixes in MPPImage
This commit is contained in:
parent
5afa815bef
commit
acba3ab26d
|
@ -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>
|
||||||
|
@ -128,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.
|
||||||
|
@ -164,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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user