ARCore应用中的黑白视频流背景 [英] Black and white video stream background in ARCore app

查看:112
本文介绍了ARCore应用中的黑白视频流背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AR Android应用,当我接近可渲染对象时,我想将AR视频流的颜色设为黑白,当然,除了可渲染对象之外.我搜索了文档,但发现我无法访问视频流来执行此操作,如

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转换为灰度级(红色,绿色和蓝色的平均值)的最简单方法是使用Colour Matrix且饱和度为零.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆