简体   繁体   English

将相机移离标记android(Kudan AR)时3D模型消失

[英]3D model vanishing when moving the camera away from the marker android (Kudan AR)

I am working on Augmented Reality using Kudan SDK in android. 我正在使用Android中的Kudan SDK进行增强现实。 I am trying to generate 3D model when the phone camera is pointing towards the marker. 手机摄像头指向标记时,我正在尝试生成3D模型。 I am able to achieve this. 我能够做到这一点。 But If I move the camera away from the marker the model is vanishing. 但是,如果我将相机从标记处移开,则模型将消失。 I dont want the 3D model to go away until unless the application is close or camera is closed. 我不希望3D模型消失,直到应用程序关闭或相机关闭。 I want to move the 3D model while I move the camera as well. 我也想在移动相机的同时移动3D模型。 Here is the code for inserting the marker and the 3D model. 这是用于插入标记和3D模型的代码。

private void addImageTrackable() {

    // Initialise image trackable
    trackable = new ARImageTrackable("Space");
    trackable.loadFromAsset("user_pic.jpg");

    // Get instance of image tracker manager
    ARImageTracker trackableManager = ARImageTracker.getInstance();

    // Add image trackable to image tracker manager
    trackableManager.addTrackable(trackable);
}

private void addModelNode() {
    // Import model
    ARModelImporter modelImporter = new ARModelImporter();
    modelImporter.loadFromAsset("cube.jet");
    ARModelNode modelNode = (ARModelNode) modelImporter.getNode();

    // Load model texture
    ARTexture2D texture2D = new ARTexture2D();
    texture2D.loadFromAsset("cube.png");

    // Apply model texture to model texture material
    ARLightMaterial material = new ARLightMaterial();
    material.setTexture(texture2D);
    material.setAmbient(0.8f, 0.8f, 0.8f);


    // Apply texture material to models mesh nodes
    for (ARMeshNode meshNode : modelImporter.getMeshNodes()) {
        meshNode.setMaterial(material);
    }


    modelNode.rotateByDegrees(10, 1, 0, 0);
    modelNode.scaleByUniform(3f);
    modelNode.setPosition(1, 1, 2000);
    modelNode.play();

    // Add model node to image trackable
    trackable.getWorld().addChild(modelNode);
    modelNode.setVisible(true);

}

这是标记前面的3D模型图像

But I want to keep this 3D model even if I move away my camera away from marker. 但是,即使我将相机从标记上移开,我也希望保留3D模型。

The model is vanishing since there is no marker, of course. 该模型消失了,因为没有标记。 If you wish to keep drawing the model anyway at the same place, simply save the last position of the model on each frame, and draw the model at that position when the marker detection is lost. 如果您仍然希望继续在同一位置绘制模型,则只需将模型的最后位置保存在每帧上,然后在丢失标记检测的情况下在该位置绘制模型。 If you want to try and draw it at the exact same place in the world (and not the same place on screen), you can try using the device sensors to estimate the phone's movement and update the location of the model accordingly. 如果您想在世界上完全相同的位置(而不是屏幕上的相同位置)绘制它,可以尝试使用设备传感器来估计手机的移动并相应地更新模型的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android AR 场景。 随着相机移动 3D model 移动。 3D model 应与底部对齐 - Android AR Sceneform. Moving 3D model along with Camera moving. 3D model should be align to the bottom Android Artoolkit 3D模型与标记的偏移量 - Android Artoolkit 3d model offset from marker 在 Android 中使用 AR 从 2D 图像创建 3D 图像 model - Creating 3D image model from 2D image using AR in Android Android AR应用程序中用于交互式3D模型的哪些库? - What libraries for interactive 3D model in Android AR app? 检测是否要从特定标记移到Android? - Detect whether moving away from particular marker or towards in Android? 如何将 AR 中的 3D 模型放置在屏幕中央,并相对于轴上的摄像机角度将其移近或移远? - How to place a 3D Model in AR at center of screen and move it near or far with respect to camera angle on axis? 如何使用 Unity3d 在现实世界中找到从 AR 相机到标记的距离 - How to find distance from AR camera to a marker in real world using Unity3d AR Android应用程序的3D对象识别 - 3d object recognition for AR android app 如何在Android中使用Gesture Listener旋转和拖动Kudan中的3D对象(ARNode) - How to rotate and drag 3D object(ARNode) in Kudan using Gesture Listener in Android Android-如何在真实场景上绘制3D立方体(无标记,相机处于打开状态) - Android - How to draw 3D cube on a real scene (no marker, camera is open)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM