Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Android Augmented Reality Application Image Coordinates

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.

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

}

}

like image 543
CodeNewbie Avatar asked Jan 17 '26 21:01

CodeNewbie


1 Answers

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

like image 129
Sharad Mhaske Avatar answered Jan 20 '26 13:01

Sharad Mhaske