简体   繁体   English

使用DJI SDK创建VR应用

[英]Creating a VR app using DJI SDK

I'm creating a VR app using the DJI SDK. 我正在使用DJI SDK创建一个VR应用。

I have two UIViews, fpvPreviewView1 and fpvPreviewView2. 我有两个UIView,fpvPreviewView1和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的多个实例,并保留引用以正确管理资源。 VideoPreviewer is heavy. VideoPreviewer很重。

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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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