mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

cocos creator 构建的ios原生包 MPPHandLandmarker初始化不了

Open 1159676007 opened this issue 1 year ago • 2 comments

Have I written custom code (as opposed to using a stock example script provided in MediaPipe)

None

OS Platform and Distribution

macos 12.7.2 2.2 GHz 四核Intel Core i7 x-code14.2 cocos creator3.7.1

MediaPipe Tasks SDK version

0.10.9

Task name (e.g. Image classification, Gesture recognition etc.)

MPPHandLandmarker

Programming Language and version (e.g. C++, Python, Java)

c++ oc javascript

Describe the actual behavior

handLandmarkerd = [[MPPHandLandmarker alloc]initWithOptions:options error:&error]] ;初始化报野指针错误

Describe the expected behaviour

ios能成功接入mediapipe

Standalone code/steps you may have used to try to get what you need

#import "AppDelegate.h"
#import "ViewController.h"
#import "View.h"

#include "platform/ios/IOSPlatform.h"
#import "platform/ios/AppDelegateBridge.h"
#import "service/SDKWrapper.h"
#import <MediaPipeTasksVision/MediaPipeTasksVision.h>
//#import "SSZipArchive.h"

@implementation AppDelegate
@synthesize window;
@synthesize appDelegateBridge;

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[SDKWrapper shared] application:application didFinishLaunchingWithOptions:launchOptions];
    appDelegateBridge = [[AppDelegateBridge alloc] init];
    
    // Add the view controller's view to the window and display.
    CGRect bounds = [[UIScreen mainScreen] bounds];
    self.window   = [[UIWindow alloc] initWithFrame:bounds];

    // Should create view controller first, cc::Application will use it.
    _viewController                           = [[ViewController alloc] init];
    _viewController.view                      = [[View alloc] initWithFrame:bounds];
    _viewController.view.contentScaleFactor   = UIScreen.mainScreen.scale;
    _viewController.view.multipleTouchEnabled = true;
    [self.window setRootViewController:_viewController];

    [self.window makeKeyAndVisible];
    [self initHandLandmarker];
    [appDelegateBridge application:application didFinishLaunchingWithOptions:launchOptions];
//   
    return YES;
}
static MPPHandLandmarker *handLandmarkerd;
static MPPHandLandmarkerOptions *options;
- (void) initHandLandmarker {
    NSLog(@"initHandLandmarker");
    NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"hand_landmarker"
                                                          ofType:@"task"];

    NSData *fileData = [NSData dataWithContentsOfFile:modelPath];
    options = [[MPPHandLandmarkerOptions alloc] init];
    options.baseOptions.modelAssetPath = modelPath;
    options.runningMode = MPPRunningModeImage;
    options.minHandDetectionConfidence = 0.5f;
    options.minHandPresenceConfidence = 0.5f;
    options.minTrackingConfidence = 0.5f;
    options.numHands = 1;
//        options.handLandmarkerLiveStreamDelegate = self;
    NSLog(@"options = %@",options);
    NSError *error = nil;
    handLandmarkerd  = [[MPPHandLandmarker alloc]initWithOptions:options error:&error] ;

//        NSLog(@"hand land markerd = %@",handLandmarkerd);
//    [handLandmarkerd initWithModelPath:modelPath error:&error];
        if (error) {
            NSLog(@"Error initializing hand landmarker: %@", error);
            return NO;
        }
}

Other info / Complete Logs

#5087 #5092的没有解决方案
按照官方所给的指南进行接入的https://developers.google.com/mediapipe/solutions/vision/hand_landmarker/ios

x-code创建的项目包可以初始化,cocos creator构建的ios包无法初始化https://docs.cocos.com/creator/3.7/manual/zh/editor/publish/ios/build-example-ios.html
这样生成的ios包接入初始化出错 请问如何解决?
期待您能给出解决方案,谢谢

1159676007 avatar Feb 01 '24 01:02 1159676007

Hi @1159676007,

Could you please outline the steps you are referring from our documentation here? This will help us reproduce and better understand the issue on our end.

Thank you!!

kuaashish avatar Feb 08 '24 08:02 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Feb 16 '24 01:02 github-actions[bot]

@kuaashish 步骤没有问题,ios原生包可以接入使用,相通的步骤接入cocos creator构建的ios包不能进行初始化,希望能从你们那边获得相应的帮助

1159676007 avatar Feb 22 '24 09:02 1159676007

@kuaashish 安装了CocoaPods

pod install

Podfile.文件中添加 target 'PoetryCrush-mobile' do

Comment the next line if you don't want to use dynamic frameworks

use_frameworks! pod 'MediaPipeTasksVision', '0.10.9'

Pods for PoetryCrush-mobile

end 生成项目 在项目中编写上方代码,运行时会有野指针的报错信息

1159676007 avatar Feb 22 '24 09:02 1159676007

Hi @1159676007,

Please utilize our prebuilt Cocoapods package for the Hand Landmarker. We have not tested this scenario yet, so our assistance may be limited. You can find the documentation here for implementing it with Cocoapods.

Thank you!!

kuaashish avatar Mar 27 '24 06:03 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Apr 04 '24 01:04 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar Apr 13 '24 01:04 github-actions[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Apr 13 '24 01:04 google-ml-butler[bot]