Hello,

I'm trying to compute the normals (of a surface) using the imu data from the camera (accelerometer, gyroscope and quaternion vector) from what I understand the quaternion vector gives us the orientation of the camera but since I'm new to this it's hard to visualize w.r.t it's oriented and I can't find an explanatory sketch on the doc so is it possible to give me a more detailed explanation on what is the quaternion vector exactly?
For example, if I have a flat surface and my camera points towards the surface (the camera and the surface are parallel) are the normals to the surface equal to the quaternion vector ?

Thank you in advance

Hi @ferrari19

That is a long discussion so, I'm going to post the GPT response:


To understand how quaternions relate to surface normals and camera orientation, let's break down the concepts step-by-step.

Quaternions and Orientation

A quaternion is a mathematical representation used to describe rotations and orientations in three-dimensional space. It consists of four components: q = (w, x, y, z). Quaternions are particularly useful in 3D graphics and robotics because they avoid the gimbal lock problem and provide a smooth way to interpolate rotations.

The components of a quaternion can be thought of as follows:

  • w: The scalar part (related to the angle of rotation).
  • x, y, z: The vector part (related to the axis of rotation).

A quaternion can represent a rotation about a unit vector v = (x, y, z) by an angle θ:

q = ( cos(θ/2), sin(θ/2) * v )

Camera Orientation

When you use a quaternion to describe the orientation of a camera, it tells you how the camera is rotated relative to some reference orientation, usually the world coordinate system.

Surface Normals

A surface normal is a vector that is perpendicular to the surface at a given point. For a flat surface, the normal is constant and perpendicular to the plane.

Relationship Between Quaternions and Surface Normals

To determine the relationship between the quaternion and the surface normals, consider the following steps:

  1. Initial Alignment: Assume an initial alignment where the camera's optical axis (the direction the camera is facing) is aligned with one of the coordinate axes, typically the z-axis in the camera's local coordinate system.

  2. Apply Quaternion Rotation: Apply the quaternion to rotate the camera from this initial alignment to its current orientation. This quaternion transformation will rotate the camera's coordinate axes.

  3. Extract Normal from Camera Orientation: Once the camera's orientation is known, you can determine the direction of the camera's optical axis in the world coordinate system. If the camera is facing a surface, the normal to that surface can be derived by considering the transformed orientation of the camera's optical axis.

Let's use an example to clarify:

  • Suppose the camera is initially oriented such that its optical axis is along the positive z-axis (0, 0, 1).
  • A quaternion q describes the rotation of the camera.

To find the surface normal from the quaternion, you can follow these steps:

  1. Convert Quaternion to Rotation Matrix: Convert the quaternion q to a 3x3 rotation matrix R.

  2. Transform the Optical Axis: Apply the rotation matrix R to the initial optical axis vector (0, 0, 1) to get the transformed optical axis z_transformed.

  3. Surface Normal: If the camera is facing a flat surface, the transformed optical axis z_transformed will point towards the surface. The surface normal is typically the opposite of this direction (assuming the camera is looking at the surface head-on).

Thank you! I was wondering how I could find the optical axis of the oak-d camera

Thank you in advance

if the camera is parallel to the surface can I just use the inverse of the accelerometer vector to get the normals?

Thanks

    Hi @ferrari19
    Reference is magnetic north and gravity vectors, so the 0 0 0 should be when device is pointed down and away from magnetic north.

    ferrari19 if the camera is parallel to the surface can I just use the inverse of the accelerometer vector to get the normals?

    Accelerometer will always point down, unless the device is speeding up or slowing down (or spinning), so no.

    Thanks,
    Jaka