问题描述
在我的应用程序,我想使用增强现实找到像家庭餐馆等地方..我想要做的是,当我开始我的摄像头应用程序打开,然后我想找到在摄像头的。比如我启动应用程序和IM所面临的东部和手机键盘正对着我就是向西方向的地方,那么这是在东方向的地方。我已经写了一些code这将启动摄像头,请建议可用于这个任务,例如任何API和教程做.thanks提前。这里是我的code。
@覆盖
公共无效的onCreate(包savedInstanceState){
// 尝试{
super.onCreate(savedInstanceState);
sensorMan =(的SensorManager)getSystemService(Context.SENSOR_SERVICE);
sensorMan.registerListener(这一点,sensorMan.getDefaultSensor(SensorManager.SENSOR_ORIENTATION)
SensorManager.SENSOR_DELAY_FASTEST);
// lastUpdate = System.currentTimeMillis的();
sensorMan.registerListener(这一点,sensorMan.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
SensorManager.SENSOR_DELAY_NORMAL);
在OnCreate的} //结束
@覆盖
公共无效onAccuracyChanged(传感器传感器,诠释精度){
// TODO自动生成方法存根
}
@覆盖
公共无效onSensorChanged(SensorEvent事件){
// TODO自动生成方法存根
如果(event.sensor.getType()== Sensor.TYPE_ACCELEROMETER){
Toast.makeText(此,X-rawDirection->中+ event.values [0],Toast.LENGTH_SHORT).show();
Toast.makeText(此,Y- rawDirection->中+ event.values [1],Toast.LENGTH_SHORT).show();
Toast.makeText(此,Z-rawDirection->中+ event.values [2],Toast.LENGTH_SHORT).show();
}
如果(event.sensor.getType()== Sensor.TYPE_ORIENTATION){
Toast.makeText(此,X-rawDirection TYPE_ORIENTATION->中+ event.values [0],Toast.LENGTH_SHORT).show();
Toast.makeText(此,Y- rawDirection TYPE_ORIENTATION->中+ event.values [1],Toast.LENGTH_SHORT).show();
Toast.makeText(此,Z-rawDirection TYPE_ORIENTATION->中+ event.values [2],Toast.LENGTH_SHORT).show();
}
}
}
下面是其中的重要环节。
HTTP://$c$c.google.com/apis /地图/文档/地/
现在我需要做的是在解析XML文件,并得到了地方。
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();
}
}
}
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..
这篇关于发现restaurents和旅游景点通过增强现实的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!