From 218bfc8f69ff41a7c59f187d39d32058cba8c3ec Mon Sep 17 00:00:00 2001 From: Prianka Liz Kariat Date: Wed, 6 Sep 2023 18:32:08 +0530 Subject: [PATCH] Added implementation of methods in MPPImage test utils --- .../vision/utils/sources/MPPImage+TestUtils.m | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/mediapipe/tasks/ios/test/vision/utils/sources/MPPImage+TestUtils.m b/mediapipe/tasks/ios/test/vision/utils/sources/MPPImage+TestUtils.m index 0b0ef9fbf..f922146fc 100644 --- a/mediapipe/tasks/ios/test/vision/utils/sources/MPPImage+TestUtils.m +++ b/mediapipe/tasks/ios/test/vision/utils/sources/MPPImage+TestUtils.m @@ -14,6 +14,7 @@ #import "mediapipe/tasks/ios/test/vision/utils/sources/MPPImage+TestUtils.h" +// TODO: Remove this category after all tests are migrated to the new methods. @interface UIImage (FileUtils) + (nullable UIImage *)imageFromBundleWithClass:(Class)classObject @@ -37,6 +38,28 @@ @implementation MPPImage (TestUtils) ++ (MPPImage *)imageWithFileInfo:(MPPFileInfo *)fileInfo { + if (!fileInfo.path) return nil; + + UIImage *image = [[UIImage alloc] initWithContentsOfFile:fileInfo.path]; + + if (!image) return nil; + + return [[MPPImage alloc] initWithUIImage:image error:nil]; +} + ++ (MPPImage *)imageWithFileInfo:(MPPFileInfo *)fileInfo + orientation:(UIImageOrientation)orientation { + if (!fileInfo.path) return nil; + + UIImage *image = [[UIImage alloc] initWithContentsOfFile:fileInfo.path]; + + if (!image) return nil; + + return [[MPPImage alloc] initWithUIImage:image orientation:orientation error:nil]; +} + +// TODO: Remove after all tests are migrated + (nullable MPPImage *)imageFromBundleWithClass:(Class)classObject fileName:(NSString *)name ofType:(NSString *)type { @@ -45,6 +68,7 @@ return [[MPPImage alloc] initWithUIImage:image error:nil]; } +// TODO: Remove after all tests are migrated + (nullable MPPImage *)imageFromBundleWithClass:(Class)classObject fileName:(NSString *)name ofType:(NSString *)type