5

I want to better understand the camera coordinate space that In ARKit's ARCamera tranform is in. In the documentation, it says

This transform creates a local coordinate space for the camera that is constant with respect to device orientation. In camera space, the x-axis points to the right when the device is in UIDeviceOrientation.landscapeRight orientation—that is, the x-axis always points along the long axis of the device, from the front-facing camera toward the Home button. The y-axis points upward (with respect to UIDeviceOrientation.landscapeRight orientation), and the z-axis points away from the device on the screen side.

Following this, the UIDeviceOrientation.landscapeRight documentation says:

The device is in landscape mode, with the device held upright and the home button on the left side.

When I try to understand this, it seems like there is a conflict between "the x-axis points to the right when the device is in UIDeviceOrientation.landscapeRight orientation" and "that is, the x-axis always points along the long axis of the device, from the front-facing camera toward the Home button". The former has +x to the right, and the latter has +x to the left.

Here is how I picture "the x-axis points to the right when the device is in UIDeviceOrientation.landscapeRight orientation":

enter image description here

And this is how I picture "that is, the x-axis always points along the long axis of the device, from the front-facing camera toward the Home button":

enter image description here

Appreciate any help, thanks!

Update: It doesn't impact this question, but to make it more clear, the reason I am asking this is because I am interested in getting the x, y, and z geomagnetic data values from Core Location. In Core Location, if the phone is in Portrait mode, +x is right, +y is up, and +z is towards the user. So it would seem the camera coordinate system for ARKit is different than the camera coordinate system in Core Location.

bluepanda
  • 382
  • 2
  • 13

2 Answers2

4

Let's get one thing out of the way first, landscapeRight has the home button on the right and the top of the phone on the left, as opposed to what you are showing in your pictures. So in your drawings, the phone should be flipped around in 180 degrees. landscapeRight in this case is different from the device orientation

First of all, the coordinate system of your Arkit session will depend on the world alignment setting of your AR session

So you have three choices

Gravity

  • In this case, Y will point up, parallel to the gravity, no matter the orientation of your device

For the z-axis, ARKit chooses a basis vector (0,0,-1) pointing in the direction the device camera faces and perpendicular to the gravity axis

  • According to this, the z axis will point in the direction the camera faces (so for the front facing camera, the z axis will point from the screen and for the back camera, the z axis will go from the phone and away from you)

  • The X axis is then determined with the right hand rule

enter image description here

Gravity and Heading

  • The y axis will point up parallel to the gravity
  • The z axis will point towards the south (-z will point to true North)
  • The x axis will point east

enter image description here

Camera

In this case, the camera will always be at (0,0,0) in your world coordinate space the y axis will point up (or the right if your phone is in portrait mode), the x axis will point from the top of the phone towards the home button and the z axis will point away from the device

Mart10
  • 758
  • 3
  • 14
  • 1
    A few quesitons: #1 When you say "landscapeRight has the home button on the right and the top of the phone on the left, as opposed to what you are showing in your pictures". Where are you getting this? When I read the documentation for [UIDeviceOrientation.landscapeRight](https://developer.apple.com/documentation/uikit/uideviceorientation/landscaperight), it says "The device is in landscape mode, with the device held upright and the home button on the left side." – bluepanda Jan 10 '20 at 21:52
  • #2 The links you're sharing are for how the world coordinate space is oriented at the beginning of a session. In some options (i.e. Gravity and Camera), the position and orientation of the Camera impacts how the World pace is aligned. But what I am asking about is how Camera space, not World space, is aligned. – bluepanda Jan 10 '20 at 21:55
  • Forgot to tag you, @Mart10, so doing it now! Also, thanks for the comment, please do let me know if the assumptions I made in my question / comments are wrong! – bluepanda Jan 18 '20 at 00:19
4

Okay, so my initial diagrams were incorrect, as @Mart10 correctly pointed out. Landscape right in the ARKit Camera context means the phone is in landscape with the home button on the right side. This post explains this in greater detail.

This means the camera coordinate system convention is, when in landscape with the home button on the right side: +x: right, +y: up, +z: backward.

This is different from the "sensor coordinate system", which is the coordinate system that the x, y, and z geomagnetic data values from Core Location come in. The "sensor coordinate system" is, when in landscape with the home button on the right side: +x: up, +y: left, +z: backward. You can use a transform to go between them.

bluepanda
  • 382
  • 2
  • 13