A method executed in a mobile device of using images for navigation, wherein the mobile device is mechanically coupled to a vehicle, the method comprising: acquiring a sequence of images from a camera of the mobile device; determining a gravitational vector in a body reference system, BRS, by averaging acceleration measurements in the BRS over time, wherein the BRS is set by the orientation of the mobile device; determining a Focus of Expansion, FOE, point derived from at least two of the sequence of images, thereby setting a direction of motion vector of the mobile device in the BRS; determining the gravitational vector in a platform reference system, PRS, of the vehicle by using a vertical axis of the vehicle offset by the road slope or averaged acceleration measurements over time and determining the direction of motion vector in the PRS by setting the direction of motion vector along an x-axis of the PRS defined in line with the forward direction of motion of the vehicle; determining the gravitational vector in a local reference system, LRS, by setting the gravitational vector along a vertical axis in the LRS, wherein the LRS is locally attached to the surface of the Earth; determining the direction of motion vector in the LRS based on GNSS location measurements; determining a second rotation matrix based on the gravitational vector and the direction of motion vector in the PRS and LRS, wherein the second rotation matrix is for converting between the PRS and the LRS; determining a third rotation matrix based on the direction of motion vector in the BRS, the gravitational vector in the BRS, the direction of motion vector in the LRS, and the gravitational vector in the LRS; writing the second and third rotation matrix to a memory of the mobile device; and computing a first rotation matrix based on the second and third rotation matrix, wherein the first rotation matrix is for converting between the BRS and the PRS; converting measurements, between the BRS and the PRS using the first rotation matrix. acquiring a sequence of images from a camera of the mobile device; determining a gravitational vector in a body reference system, BRS, by averaging acceleration measurements in the BRS over time, wherein the BRS is set by the orientation of the mobile device; determining a Focus of Expansion, FOE, point derived from at least two of the sequence of images, thereby setting a direction of motion vector of the mobile device in the BRS; determining the gravitational vector in a platform reference system, PRS, of the vehicle by using a vertical axis of the vehicle offset by the road slope or averaged acceleration measurements over time and determining the direction of motion vector in the PRS by setting the direction of motion vector along an x-axis of the PRS defined in line with the forward direction of motion of the vehicle; determining the gravitational vector in a local reference system, LRS, by setting the gravitational vector along a vertical axis in the LRS, wherein the LRS is locally attached to the surface of the Earth; determining the direction of motion vector in the LRS based on GNSS location measurements; determining a second rotation matrix based on the gravitational vector and the direction of motion vector in the PRS and LRS, wherein the second rotation matrix is for converting between the PRS and the LRS; determining a third rotation matrix based on the direction of motion vector in the BRS, the gravitational vector in the BRS, the direction of motion vector in the LRS, and the gravitational vector in the LRS; writing the second and third rotation matrix to a memory of the mobile device; and computing a first rotation matrix based on the second and third rotation matrix, wherein the first rotation matrix is for converting between the BRS and the PRS; converting measurements, between the BRS and the PRS using the first rotation matrix.