iOS开发用easyar中的小bug

0 投票
最新提问 6月 13, 2018 用户: grayme (150 分)

就是Demo中的一个坑啊 当你从ar界面跳转到另一个界面时 是:

- (void)stop

{

    stop();

    finalize();

}

这里调用了:

BOOL stop()

{

    bool status = true;

    for (easyar_ImageTracker * tracker in trackers) {

        status &= [tracker stop];

    }

    status &= (cloud_recognizer != nil) && [cloud_recognizer stop];

    status &= (streamer != nil) && [streamer stop];

    status &= (camera != nil) && [camera stop];

    return status;

}

void finalize()

{

    [trackers removeAllObjects];

    cloud_recognizer = nil;

    current_video_renderer=nil;

    [video_renderers removeAllObjects];

    videobg_renderer = nil;

    video=nil;

    tracked_target=0;

    active_target=0;

    streamer = nil;

    [camera close];

    camera = nil;

}

(注意加粗字体),但是当它从其他的界面跳转回来时,调用了当前ar界面的viewWillAppear函数

- (void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];

    [self->glView start];

}

我们进入它的start函数 是调用了helloar.m中的initialize和start函数:

BOOL start()

{

    bool status = true;

    status &= (camera != nil) && [camera start];

    status &= (streamer != nil) && [streamer start];

    status &= (cloud_recognizer != nil) && [cloud_recognizer start];

    [camera setFocusMode:easyar_CameraDeviceFocusMode_Continousauto];

    for (easyar_ImageTracker * tracker in trackers) {

        status &= [tracker start];

    }

    return status;

}

BOOL initialize()

{

     camera = [easyar_CameraDevice create];

    streamer = [easyar_CameraFrameStreamer create];

    [streamer attachCamera:camera];

    cloud_recognizer = [easyar_CloudRecognizer create];

    [cloud_recognizer attachStreamer:streamer];

    bool status = true;

    status &= [camera open:easyar_CameraDeviceType_Default];

    [camera setSize:[easyar_Vec2I create:@[@1280, @720]]];

    uids = [[NSMutableSet<NSString *> alloc] init];

    [cloud_recognizer open:cloud_server_address appKey:cloud_key appSecret:cloud_secret callback_open:^(easyar_CloudStatus status) {

        if (status == easyar_CloudStatus_Success ) {

            NSLog(@"CloudRecognizerInitCallBack: Success");

        } else if (status == easyar_CloudStatus_Reconnecting) {

            NSLog(@"CloudRecognizerInitCallBack: Reconnecting");

        } else if (status == easyar_CloudStatus_Fail) {

            NSLog(@"CloudRecognizerInitCallBack: Fail");

        } else {

            NSLog(@"CloudRecognizerInitCallBack: %ld", (long)status);

        }

    } callback_recognize:^(easyar_CloudStatus status, NSArray<easyar_Target *> * targets) {

        if (status == easyar_CloudStatus_Success ) {

            NSLog(@"CloudRecognizerCallBack: Success");

        } else if (status == easyar_CloudStatus_Reconnecting) {

            NSLog(@"CloudRecognizerCallBack: Reconnecting");

        } else if (status == easyar_CloudStatus_Fail) {

            NSLog(@"CloudRecognizerCallBack: Fail");

        } else {

            NSLog(@"CloudRecognizerCallBack: %ld", (long)status);

        }

        @synchronized (uids) {

            for (easyar_Target * t in targets) {

                if (![uids containsObject:[t uid]]) {

                    NSLog(@"add cloud target: %@", [t uid]);

                    [uids addObject:[t uid]];

                    [[trackers objectAtIndex:0] loadTarget:t callback:^(easyar_Target *target, bool status) {

                        NSLog(@"load target (%@): %@ (%d)", status ? @"true" : @"false", [target name], [target runtimeID]);

                    }];

                }

            }

        }

    }];

    if (!status) { return status; }

    easyar_ImageTracker * tracker = [easyar_ImageTracker create];

    [tracker attachStreamer:streamer];

    trackers = [[NSMutableArray<easyar_ImageTracker *> alloc] init];

    [trackers addObject:tracker];

    return status;}

然而initialize函数中并没有包含对video相关的变量进行初始化,若只是这样在真机上运行的话返回的时候就会出现白屏的情况

1个回答

0 投票
最新回答 6月 15, 2018 用户: Dita (2,020 分)
首先需要明白sample的含义,sample最主要的是focus 通过最简单的产品与逻辑来演示SDK 的feature,并不是去集成开发者各式各样的需求与功能(比如你说的AR页面之间的跳转),,,,
发表于 6月 15, 2018 用户: grayme (150 分)
但是在finialize函数时置空了init时要初始化不是一个很简单的逻辑么 。。。
欢迎来到 EasyAR Q&A ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。
...