Java Android增强现实应用程序图像坐标

时间:2022-01-09 17:06:38

i am currently new to augmented reality programming and i would like to ask a question regarding the cameraView. My objective is to display an clickable imageButton at a specific real-life coordinate and display it in a cameraView. In this case, the thing that i want to display inside my cameraView(Which is a world) is my button. I tried using Wikitude/ AndAR/ Layar API before i decided that it was a hassle to call its permission for usage and I am currently using DroidAR as a library and reference. However i can't seem to find a way to display what i want correctly. I would like to seek help regarding this issue. Please advise me or guide me the correct way to achieve it. Thank you very much ! Below are my current codes using the droidAR library SDK.

我目前不熟悉增强现实编程,我想问一个关于cameraView的问题。我的目标是在特定的真实坐标上显示可点击的imageButton并将其显​​示在cameraView中。在这种情况下,我想在我的cameraView(这是一个世界)内显示的东西是我的按钮。我尝试使用Wikitude / AndAR / Layar API之前我决定调用其使用权限是一件麻烦事,我目前正在使用DroidAR作为库和参考。但是,我似乎无法找到一种方法来显示我想要的正确。我想就这个问题寻求帮助。请告诉我或指导我实现它的正确方法。非常感谢你 !以下是使用droidAR库SDK的当前代码。

public class DisplayAR extends Setup {
private static final float MIN_DIST = 15f;
private static final float MAX_DIST = 55f;

private Button b = null;
protected static final String LOG_TAG = "StaticDemoSetup";

World world;
GLCamera camera;

private TimeModifier timeModifier;


@Override
public void _a_initFieldsIfNecessary() {

    // allow the user to send error reports to the developer:
}


@Override
public void _b_addWorldsToRenderer(GL1Renderer renderer,
        GLFactory objectFactory, GeoObj currentPosition) {

    camera = new GLCamera(new Vec(0, 0, 1));
    world = new World(camera);

    timeModifier = new TimeModifier(1);
    RenderList l = new RenderList();
    timeModifier.setChild(l);
    world.add(timeModifier);

    initI9Tests(world);

    addTestGeoObj(world, camera);

    renderer.addRenderElement(world);

}

private void addTestGeoObj(World w, GLCamera c) {
    GeoObj o = new GeoObj();
    w.add(o);
}

private void initI9Tests(World w) {

    {
        // transform android ui elements into opengl models:
        b = new Button(getActivity());
        b.setText("L.311");

        MeshComponent button = GLFactory.getInstance().newTexturedSquare("buttonId", IO.loadBitmapFromView(b));
        button.addChild(new AnimationFaceToCamera(camera, 0.5f));
        button.setScale(new Vec(10, 10, 10));
        button.setColor(Color.red());
        button.setOnClickCommand(new CommandShowToast(getActivity(), "THIS IS L.311"));
        GeoObj treangleGeo = new GeoObj();
        treangleGeo.setVirtualPosition(new Vec(MIN_DIST, MAX_DIST, 0.0f));
        treangleGeo.setComp(button);
        w.add(treangleGeo);
    }
}

@Override
public void _c_addActionsToEvents(EventManager eventManager,
        CustomGLSurfaceView arView, SystemUpdater updater) {

    ActionWASDMovement wasdAction = new ActionWASDMovement(camera, 25f,
            50f, 20f);
    ActionRotateCameraBuffered rotateAction = new ActionRotateCameraBuffered(
            camera);

    eventManager.addOnLocationChangedAction(new ActionCalcRelativePos(
            world, camera));

    updater.addObjectToUpdateCycle(wasdAction);
    updater.addObjectToUpdateCycle(rotateAction);

    arView.addOnTouchMoveAction(wasdAction);
    eventManager.addOnOrientationChangedAction(rotateAction);

    eventManager.addOnTrackballAction(new ActionMoveCameraBuffered(camera,
            5, 25));

}

@Override
public void _d_addElementsToUpdateThread(SystemUpdater worldUpdater) {
    // add the created world to be updated:
    worldUpdater.addObjectToUpdateCycle(world);

}

@Override
public void _e2_addElementsToGuiSetup(GuiSetup guiSetup, Activity activity) {

    guiSetup.setBottomMinimumHeight(50);
    guiSetup.setBottomViewCentered();

}

}

}

1 个解决方案

#1


1  

try to use wikitude library for augmented reality at www.wikitude.com it has sample example simpleArbrowser is what u wanted

尝试在www.wikitude.com上使用wikitude库来增强现实它有示例simpleArbrowser是你想要的

#1


1  

try to use wikitude library for augmented reality at www.wikitude.com it has sample example simpleArbrowser is what u wanted

尝试在www.wikitude.com上使用wikitude库来增强现实它有示例simpleArbrowser是你想要的