Black and white video stream background in ARCore app

元气小坏坏 提交于 2020-01-06 03:36:24

问题


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?


回答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.

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.

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);

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.

Hope this helps.



来源:https://stackoverflow.com/questions/52868954/black-and-white-video-stream-background-in-arcore-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!