如何得到相机的方向GPS功能的手机? [英] How to get Camera direction of GPS enabled phone?

查看:135
本文介绍了如何得到相机的方向GPS功能的手机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有我发现关于GPS的是,它只是告诉了设备的位置,如何一送该设备的方向,其中摄像头指向,其角度和高度?如何使罗盘(2D,3D),带有GPS功能的手机?

All i found about GPS is that it just tells the location of the device, how do one get the direction where camera is pointing, its angle, and height of that device? How to make compass (2D, 3D) with GPS enabled phone?

有一个内置的2D,3D罗盘在手机或者是全部由刚刚GPS?

Is there a built in 2D, 3D compass in phone or it is all done by just GPS?

推荐答案

我就是这么做的:

1 - 使用加速度和磁lesteners获得的加速度和磁值

1 - Get acceleration and magnetic values using acceleration and magnetic lesteners.

2 - 将这些值的方向:

2 - Transform these values to orientation:

    private float[] rMatrix = new float[9]; 
    private float[] outR = new float[9];

    SensorManager.getRotationMatrix(rMatrix, null, accelerometerValues, magneticValues);
    SensorManager.remapCoordinateSystem(rMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Z, outR);
    SensorManager.getOrientation(outR, orientationValues);

下面accelerometerValues​​和magneticValues​​浮[3],你根据听众初始化数组

Here accelerometerValues and magneticValues float[3] arrays that you initialize in according listeners

3 - orientationValues​​ [0]和orientationValues​​ [1]的值是水平和垂直角度

3 - orientationValues[0] and orientationValues[1] values are horizontal and vertical angles.

这篇关于如何得到相机的方向GPS功能的手机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆