简体   繁体   中英

Creating a VR app using DJI SDK

I'm creating a VR app using the DJI SDK.

I have two UIViews, fpvPreviewView1 and fpvPreviewView2.

How do I create two instances of the same camera? It currently only displays in a single view.

Here's the relevant code.

DJICamera *camera = [self fetchCamera];
if (camera && camera.delegate == self)
    [camera setDelegate:nil];
[self resetVideoPreview];

- (DJICamera*) fetchCamera {
    if (![DJISDKManager product]) {
        return nil;
    }

    if ([[DJISDKManager product] isKindOfClass:[DJIAircraft class]]) {
        return ((DJIAircraft*)[DJISDKManager product]).camera;
    }else if ([[DJISDKManager product] isKindOfClass:[DJIHandheld class]]){
        return ((DJIHandheld *)[DJISDKManager product]).camera;
    }

    return nil;
}

[[VideoPreviewer instance] setView:self.fpvPreviewView1];
[[VideoPreviewer instance] setView:self.fpvPreviewView2];
[[VideoPreviewer instance] setView:self.fpvPreviewView1];
[[VideoPreviewer instance] setView:self.fpvPreviewView2];

Time sensitive. Please help!

Thanks!

What you are currently doing is reset the view of the video previewer singleton every time. What you want to do is create multiple instances of VideoPreviewer and keep a reference to manage properly the resources. VideoPreviewer is heavy.

Try this instead:

self.firstVP = [[VideoPreviewer alloc] init]; 
[self.firstVP setView:self.fpvPreviewView1];
self.secondVP = [[VideoPreviewer alloc] init];
[self.secondVP setView:self.fpvPreviewView2];

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM