iOS扩展中调用崩溃,求助

58 views
Skip to first unread message

Harry

unread,
Mar 21, 2023, 5:53:47 AM3/21/23
to TensorFlow Developers

在SampleHandler.h扩展中调用

    

    // 创建TFLObjectDetectorOptions对象

            TFLObjectDetectorOptions *options = [[TFLObjectDetectorOptions alloc] initWithModelPath:modelPath];

            options.classificationOptions.scoreThreshold = 0.5;

            options.classificationOptions.maxResults  = 1;

            options.baseOptions.computeSettings.cpuSettings.numThreads = 1;

            // 创建TFLObjectDetector对象

            NSError *error;

            TFLObjectDetector *ctDetector = [TFLObjectDetector objectDetectorWithOptions:options error:&error];

            if(error != nil){

                NSLog(@"解析器创建失败:%@",error.localizedDescription);

            }

    

    其中+ (nullable instancetype)objectDetectorWithOptions:(TFLObjectDetectorOptions *)options

    error:(NSError **)error 函数报错:

        -[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0

        *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0'

        *** First throw call stack:

        (0x181047c80 0x19886cee4 0x181118708 0x180fe156c 0x180fe077c 0x104c991e4 0x104c93a5c 0x104c940fc 0x1ca77df34 0x180d07094 0x180d08094 0x180cae73c 0x180caf1f4 0x180cb8ec8 0x1dc3ace10 0x1dc3ac93c)

        libc++abi: terminating with uncaught exception of type NSException

        *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0'

        terminating with uncaught exception of type NSException

        *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0'

        terminating with uncaught exception of type NSException

        

        请帮忙协助解决一下?谢谢

        

        备注:同样的代码在主项目中运行是没问题的,在扩展程序里就报错。

Harry

unread,
Mar 21, 2023, 6:13:51 AM3/21/23
to TensorFlow Developers, Harry

Called in SampleHandler.h expansion

//Create a TFLObjectDetectorOptions object

TFLObjectDetectorOptions *options = [[TFLObjectDetectorOptions alloc] initWithModelPath:modelPath];
options.classificationOptions.scoreThreshold = 0.5;
options.classificationOptions.maxResults = 1;
options.baseOptions.computeSettings.cpuSettings.numThreads = 1;
// Create a TFLObjectDetector object

NSError *error;
TFLObjectDetector *ctDetector = [TFLObjectDetector objectDetectorWithOptions:options error:&error];
if(error != nil){
NSLog(@"Parser build failed: %@", error.localizedDescription);
}

where + (nullable instancetype)objectDetectorWithOptions:(TFLObjectDetectorOptions *)options
error:(NSError **)error function reports an error:
-[TFLClassificationOptions copyToCOptions:error:]: Unrecognized selector sent to instance 0x281157ba0
*** Terminating application due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0'

*** First throw call stack:

libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: Unrecognized selector sent to instance 0x281157ba0'
Terminates with an uncaught exception of type NSException
*** Terminating application due to uncaught exception 'NSInvalidArgumentException', reason: '-[TFLClassificationOptions copyToCOptions:error:]: unrecognized selector sent to instance 0x281157ba0'
Terminates with an uncaught exception of type NSException

Please help to solve it? Thanks

Remarks: The same code runs fine in the main project, but reports an error in the extension.
Reply all
Reply to author
Forward
0 new messages