0

我正在开发一个 Android 移动应用程序,该应用程序面向无人机摄像头视图的实时增强可视化(特别是我正在开发带有相关 SDK 的 DJI Phantom 3 Professional)。我正在为 AR 部分使用 Wikiitude 框架。每个 Wikiitude 示例都通过增强智能手机的摄像头视图来工作,因此我需要重定向输入视频流。在这个阶段,通过使用 DJI SDK 功能,我有一个 TextureView 对象,其中包含来自无人机的正确解码的流。以下是当前视图的 .xml 文件顶部的相关说明:

<TextureView
    android:id="@+id/video_previewer_surface"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/linearLayout" />

实际上,Wikitude Architect View 是由相机流的渲染和增强的渲染组成的,如下图所示: Architect View Composition

sample_cam.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal">

   <com.wikitude.architect.ArchitectView
      android:id="@+id/architectView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"/>
</LinearLayout>

有没有办法用我的TextureView的内容替换 Wikitude Architect View 的当前相机流?

或者,有没有办法让 ArchitectView 的相机流作为透明背景,以便将此层与TextureView重叠?

以下可能是 .xml 最终文件的部分代码:

<TextureView
    android:id="@+id/video_previewer_surface"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_centerHorizontal="true"
    android:layout_above="@+id/linearLayout" />
<com.wikitude.architect.ArchitectView  // with transparent background for camera
   android:id="@+id/architectView"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"/>
4

2 回答 2

1

您可以结合dji 的 Video Stream Decoding来实现您自己的Wikiitude Input Plugin。因此,您从 dji sdk 获取原始视频数据并将其传递给 wikiitude sdk。输入插件的示例代码可以在 wikiitude 示例应用程序中找到,示例名称为“自定义相机”。

于 2017-01-26T12:31:40.320 回答
0

亚历克斯的答案是正确的并且有效。以下是更多细节: Wikitude 输入插件可用于提供您自己的相机输入,您还可以应用您自己的增强功能和您自己的渲染。请参阅 Wikiitude 输入插件文档。

根据 Wikiitude 示例,可以使用自定义相机插件作为起点。您开发自己的相机扩展并在构造函数中执行以下操作:

    arVideoView = new SurfaceViewRenderer(activity);
    arVideoView.setId(R.id.local_surface_rendeer);
    LinearLayout.LayoutParams param1 = new LinearLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT,
            1.0f
    );
    arVideoView.setLayoutParams(param1);
    arVideoView.setKeepScreenOn(true);
    architectView.addView(arVideoView);

在这种情况下,我将 WebRTC 相机视图添加到 Architect 视图。

然后我为传入的帧实现了回调。

// Implementation detail: bridge the VideoRenderer.Callbacks interface to the
// VideoStreamsView implementation.
public class VideoCallbacks implements VideoRenderer.Callbacks {
    @Override
    public void renderFrame(final VideoRenderer.I420Frame i420Frame) {
        Log.v(TAG, "renderFrame ..."+i420Frame);

.. 将帧转换为 nv21 Log.v(TAG, "make byte array"); byte[] b = getNV21(0,0, bmpRotate.getWidth(), bmpRotate.getHeight(), bmpRotate);

// 并将帧传递给插件进行进一步处理 notifyNewCameraFrameN21(b);

                gotFrame = false;
            }
        });

    }
}

希望这可以帮助。快乐编码!菲尔

于 2018-06-11T19:02:13.890 回答