ARCore 应用中的黑白视频流背景 [英] Black and white video stream background in ARCore app
问题描述
我正在开发 AR Android 应用程序,当我接近可渲染对象时,我想将 AR 视频流的颜色设为黑白,当然可渲染对象除外.我搜索了文档,但我无法访问视频流来执行此操作,如 探索 AR 交互(Google I/O '18).
I'm working on AR Android app and when I get close to a renderable I want to make the colors of the AR video stream black-and-white, except the renderables of course. I searched the docs but it seams I cannot access the video stream to do it as shown in Exploring AR interaction (Google I/O '18).
有谁知道如何做到这一点?
Does anyone know how to accomplish this?
推荐答案
要从 ARCore 获取视频流,需要将纹理绘制到正在捕获的 OpenGL 3.1 上下文 中.你可以找到 此处如何操作.
To get a video stream from ARCore requires drawing the texture into a OpenGL 3.1 Context what is being captured. You can find here how to do it.
捕获视频流后,最简单的方法是将彩色video
/image
转换为灰度(红色的平均值)、绿色和蓝色)是使用零饱和度的 颜色矩阵
.
After you've captured a video stream, the simplest way to convert colour video
/image
into grayscale one (the average of red, green, and blue) is to use a Colour Matrix
with zero saturation.
以下是如何以编程方式执行此操作的 Java 代码摘录:
Here is an excerpt of Java code how to do it programmatically:
ColorMatrix BW_matrix = new ColorMatrix();
BW_matrix.setSaturation(0);
ColorMatrixColorFilter BW_filter = new ColorMatrixColorFilter(BW_matrix);
imageview.setColorFilter(BW_filter);
您只需要将其应用于来自手机摄像头的视频流,而不是将 Sceneform 的 3D 模型添加到场景后的渲染结果.
You need to apply it only to video stream from phone's camera, not to the rendered result after adding Sceneform's 3D models to the scene.
希望这会有所帮助.
这篇关于ARCore 应用中的黑白视频流背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!