Question

in my app i want to use augmented reality to find places like family restaurants etc.. What i want to do is that when i start my app camera turned on and then i want to locate the places in the direction of the camera .for example i start the app and i m facing the east and phone keypad is facing towards me i.e west,then the places which are in east direction. i have written some code which starts the camera, please suggest any api available for this task and example and tutorial to do that .thanks in advance. here is my code.

@Override
    public void onCreate(Bundle savedInstanceState) {
        // try{

        super.onCreate(savedInstanceState);


sensorMan = (SensorManager) getSystemService(Context.SENSOR_SERVICE);

        sensorMan.registerListener(this,sensorMan.getDefaultSensor(SensorManager.SENSOR_ORIENTATION),
    SensorManager.SENSOR_DELAY_FASTEST);
        //lastUpdate = System.currentTimeMillis();

sensorMan.registerListener(this, sensorMan.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), 
                SensorManager.SENSOR_DELAY_NORMAL);
    }//end of oncreate

@Override
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onSensorChanged(SensorEvent event) {
        // TODO Auto-generated method stub



        if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

Toast.makeText(this, "X-rawDirection->"+event.values[0], Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Y-rawDirection->"+event.values[1], Toast.LENGTH_SHORT).show();
Toast.makeText(this, "Z-rawDirection->"+event.values[2], Toast.LENGTH_SHORT).show();

            }

            if (event.sensor.getType() == Sensor.TYPE_ORIENTATION) {

    Toast.makeText(this, "X-rawDirection TYPE_ORIENTATION->"+event.values[0], Toast.LENGTH_SHORT).show();
    Toast.makeText(this, "Y-rawDirection TYPE_ORIENTATION->"+event.values[1], Toast.LENGTH_SHORT).show();
    Toast.makeText(this, "Z-rawDirection TYPE_ORIENTATION->"+event.values[2], Toast.LENGTH_SHORT).show();

            }

        }
}
Was it helpful?

Solution 2

Here is the important link.

http://code.google.com/apis/maps/documentation/places/

now all i need to do is the parse the xml file and get the places..

OTHER TIPS

There are three steps.

1) Determine your position and orientation using sensors.

2) Convert from GPS coordinate space to a planar coordinate space by determining the relative position and bearing of known GPS coordinates using e.g great circle distance and bearing. http://www.yourhomenow.com/house/haversine.html (your devices stays at the origin of the coordinate space with this scheme)

3) Do a perspective projection http://en.wikipedia.org/wiki/3D_projection#Perspective_projection to figure out where on the plane that is your display (ok, your camera sensor) the objects should appear, so you can augment them.

To start with, you can simplify the situation so the phone is only held in one orientation, and you don't update the display to account for orientation about the axis defined from the screen to the camera, since for a basic "finder" app, most people won't rotate in that axis. Be aware of gimbal lock http://en.wikipedia.org/wiki/Gimbal_lock - I'm not sure if the Android sensor APIs take care of that for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top