google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 603 forks source link

Displaying front camera as a 2D view in AR #494

Closed Maf-Dy closed 5 years ago

Maf-Dy commented 5 years ago

SPECIFIC ISSUE ENCOUNTERED

Feature Request: putting a layout that contains w surface view for displaying the front camera and rendering them in AR using ViewRenderable doesn't render the view in AR instead the front camera is displayed over the ARSceneView

is it possible to be able to view the front camera in AR as a 2D view?

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

I edited the solar system app, made the settings node the parent node to display only the layout, then i added inside the layout a SurfaceView, and used camera.open to open the front camera after the node is added in AR

the front camera is displayed but not in AR, it is displayed above the back camera of the ArSceneView

romainguy commented 5 years ago

SurfaceView cannot be used in a ViewRenderable. What you should do instead is use the camera as an external texture: https://developers.google.com/ar/reference/java/sceneform/reference/com/google/ar/sceneform/rendering/ExternalTexture

All you have to do is give the Surface from the ExternalTexture to the camera API to have it produce camera frames in that texture. You can then use that external texture has a texture on a node. Note that external textures require the use of external samples in materials. See https://developers.google.com/ar/develop/java/sceneform/custom-material#parameters

Maf-Dy commented 5 years ago

Will give it a try, thanks a lot

Maf-Dy commented 5 years ago

yes it worked, i began working on the chromavideo sample replacing the mediaplayer with the camera object then doing as you said made it work

sorry for bothering you with this on the issues page

nbnminds commented 5 years ago

@Maf-Dy , it would be nice if you can share the sample code as i am looking for the same. Thanks