Knowledge Base: Registration export and camera orientations

Registration export and camera orientations
In RealityCapture we define camera orientations this way:

Yaw - prior rotation angle Yaw (around Z axis)
Pitch - prior rotation angle Pitch (around Y axis)
Roll - prior rotat…

https://dev.epicgames.com/community/learning/knowledge-base/7yvm/capturing-reality-registration-export-and-camera-orientations

Been trying to get my head around this for a while so may as well just ask:

How do I export camera locations from RC which uses Z-up so that camera locations are in Y up orientation (Y up, X Right, Z Forward)?

I just need what is shown here:

(#) Cameras
(#) PhotoID, X, Y, Z, Omega, Phi, Kappa

No matter what I try the imported positions are wrong, any help greatly appreciated

Hi MrJR,
to do so you will need to change the calibration.xml file. The file can be found in C:\Program Files\Capturing Reality\RealityCapture.
There you can find the wanted option or create your own which will have replaced Y and Z values.
Like:

<format id="{B3EE1544-1D64-4C22-A47D-FC9F78C107B7}" mask="*.csv" descID="8367" desc="Comma separated, Name, X, Z, Y, Omega, Phi, Kappa" writer="cvs" requires="component">
        <body EulerFormat="xyz">#cameras $(cameraCount)
#name,x,z,y,omega,phi,kappa
$ExportCameras($(imageName)$(imageExt),$(x),$(z),$(y),$(omega),$(phi),$(kappa)
)</body>
    </format>

But there could be also issues with omega, phi, kappa, probably those values will be needed to be changed accordingly. Also, there could be bug for exported OPK values.

Where are you trying to import camera positions?

To do so you can export Registration as Internal/External camera parameters
image
and there you can set the rotations:
image

The main problem however is the X,Y,Z values bring in the cameras at the correct locations but the omega,phi, kappa are the wrong rotations

were you able to solve this problem? I am also facing it

I’ve not been able to get this to work, the Omega Phi Kappa just seem broken and thus have given up for now

hey, can you help us here maybe?

I have the same problem, I try to import the cameras and a mesh in open3d (python). The mesh and the cameras positions work fine, but I can’t get the camera orientation right.

Hi Thomas_Gorski,
I see you also created a ticket regarding this issue. It will be answered.
Also, which option are you exporting?

Thank you. We export a camera registration csv file with these settings

<Configuration id="{2D5793BC-A65D-4318-A1B9-A05044608385}">
  <entry key="calexTrans" value="1"/>
  <entry key="calexHasDisabled" value="0x0"/>
  <entry key="MvsExportScaleZ" value="1.0"/>
  <entry key="MvsExportIsGeoreferenced" value="0x1"/>
  <entry key="MvsExportIsModelCoordinates" value="0"/>
  <entry key="MvsExportScaleY" value="1.0"/>
  <entry key="MvsExportScaleX" value="1.0"/>
  <entry key="MvsExportRotationY" value="0.0"/>
  <entry key="MvsExportcoordinatesystemtype" value="0"/>
  <entry key="MvsExportNormalFlipZ" value="false"/>
  <entry key="MvsExportRotationX" value="-90.0"/>
  <entry key="hasCalexFilePath" value="1"/>
  <entry key="MvsExportNormalFlipY" value="false"/>
  <entry key="MvsExportNormalSpace" value="Mikktspace"/>
  <entry key="calexHasUndistort" value="-1"/>
  <entry key="MvsExportNormalFlipX" value="false"/>
  <entry key="MvsExportRotationZ" value="0.0"/>
  <entry key="calexFileFormat" value="Internal/External camera parameters"/>
  <entry key="MvsExportMoveZ" value="0.0"/>
  <entry key="calexFileFormatId" value="{0CA18733-1EBC-4254-9974-17197EB409BD}"/>
  <entry key="hasCalexFileName" value="1"/>
  <entry key="calexHasImageExport" value="-1"/>
  <entry key="MvsExportMoveX" value="0.0"/>
  <entry key="MvsExportNormalRange" value="ZeroToOne"/>
  <entry key="MvsExportMoveY" value="0.0"/>
</Configuration>

Then we import it into open3d which is y-up coordinate system

Have you tried this (change the Y and Z coordinates) and not rotate the model:

And also set the YPR values according to that.
When rotating a point cloud/model in the export, it is not being rotated around the “global” system, but around the model’s center, which could cause some orientation issues.
Also, in RC Yaw is around Z, Pitch around Y and Roll around X

I tried that and the same problem occurs. I honetly don’t understand how I come from the yaw, pitch and roll to the camera direction vector in the world system. This should not be so complex.

What would be the correct rotation matrix to calculate the camera direction vector from the ypr values? and what is the default camera direction?

Default camera position:


(showd is RC’s coordinate system)
Yaw = 0, image is oriented to Y (upper side of image is oriented that way)
Pitch = 0, image is looking down
Roll = 0, image is parallel with X axis

Rotation matrix computation:
inline void FromYPR( __in_ecount( 3 ) double *pYpr, __out_ecount( 9 ) double *pR, __in UINT eulerSignature = 5 )
{
// camera-plane offset
// plane cs: X-north, Y-right, Z-down
// camera is mounted looking down: X-right, Y-plane tail, Z-down
double T[ 9 ];
T[ 0 ] = 0; T[ 1 ] = -1; T[ 2 ] = 0;
T[ 3 ] = 1; T[ 4 ] = 0; T[ 5 ] = 0;
T[ 6 ] = 0; T[ 7 ] = 0; T[ 8 ] = 1;

_ASSERT( Mat33Det( T ) > 0 );

double R[ 9 ];
double intAngles[ 3 ];
intAngles[ 0 ] = pYpr[ 2 ];
intAngles[ 1 ] = pYpr[ 1 ];
intAngles[ 2 ] = pYpr[ 0 ];
MatrixEulerCompose( eulerSignature, intAngles, R );
Mat33Mul( R, T );

// our CS is X-east, Y-north, Z-up
T[ 0 ] = 0;	T[ 1 ] =  1;	T[ 2 ] =  0;
T[ 3 ] = 1;	T[ 4 ] =  0;	T[ 5 ] =  0;
T[ 6 ] = 0;	T[ 7 ] =  0;	T[ 8 ] = -1;
_ASSERT( Mat33Det( T ) > 0 );

Mat33Mul( T, R, pR );

// convert from object rotation to camera rotation (inverse)
Mat33Transpose( pR );
_ASSERT( Mat33Det( pR ) > 0 );

}

In javascript:

EulerRotation: function (y, p, r) {
	var cx = Math.cos(LA.Deg2Rad * r);
	var cy = Math.cos(LA.Deg2Rad * p);
	var cz = Math.cos(LA.Deg2Rad * y);
	var sx = Math.sin(LA.Deg2Rad * r);
	var sy = Math.sin(LA.Deg2Rad * p);
	var sz = Math.sin(LA.Deg2Rad * y);
	return [cx * cz + sx * sy * sz, -cx * sz + cz * sx * sy, -cy * sx,
	-cy * sz, -cy * cz, -sy,
	cx * sy * sz - cz * sx, cx * cz * sy + sx * sz, -cx * cy];
},

thank you, that helped me!