google-ar / sceneform-android-sdk

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

I am trying to show 2d image and mp4 video of the size of scanned image and place it on the image in arcore #716

Open Anushree278 opened 5 years ago

Anushree278 commented 5 years ago

Creating an app in which i have to show after finding target,i have to get image from internal memory and to get the size of target image and show the mp4 video or image on the target image using ARcore in android I have tried giving position to center and displayorientedpose and also get the size of augmentedimage.getextentX and passed it on vector position

private Node createVideoDisplay(final AnchorNode parent, Vector3 localPosition, String title) { // Create a node to render the video and add it to the anchor. Node videoNode = new Node(); videoNode.setParent(parent); videoNode.setLocalPosition(localPosition);

   // Set the scale of the node so that the aspect ratio of the video is correct.
   float videoWidth = mediaPlayer.getVideoWidth();
   float videoHeight = mediaPlayer.getVideoHeight();
   videoNode.setLocalScale(
           new Vector3(
                   VIDEO_HEIGHT_METERS * (videoWidth / videoHeight),
                   VIDEO_HEIGHT_METERS, 1.0f));

   // Place the text above the video
   final float videoNodeHeight = VIDEO_HEIGHT_METERS+ localPosition.y;
   ViewRenderable.builder().setView(this,R.layout.video_title)
           .build().thenAccept(viewRenderable -> {
              Node titleNode =  new Node();
              titleNode.setLocalPosition(new Vector3(0,videoNodeHeight,0));
              titleNode.setParent(parent);
              titleNode.setRenderable(viewRenderable);
       ((TextView)viewRenderable.getView().findViewById(R.id.video_text))
                      .setText(title);
   });

   return videoNode;

}

artemisia commented 5 years ago

so,what is your question?