Camera/sensor poses. How do you set them in CC?

Feel free to ask any question here
Post Reply
pushrbx
Posts: 4
Joined: Wed Apr 06, 2016 10:12 am
Location: UK
Contact:

Camera/sensor poses. How do you set them in CC?

Post by pushrbx »

Hi,

I'd like to use CC to create a fly through animation on a point cloud based on a text file which has rows in the following format:
Timestamp x y z roll pitch yaw

Example:

Code: Select all

1448534152426583, 0.000016373800, 0.000000496031, -0.000051859500, 0.000006510990, -0.000002266520, -0.000000595645
1448534152476580, 0.000002952982, 0.000008420957, -0.000129863979, 0.000010835746, -0.000003999963, 0.000001385994
1448534152526579, -0.000012847086, -0.000019797941, -0.000178220648, 0.000006050605, -0.000007709890, 0.000003889104
1448534152576577, 0.000055242237, -0.000024177319, -0.000153043349, 0.000001814640, -0.000015749586, 0.000009759885
1448534152626574, -0.000150767281, -0.000008456334, -0.000701345565, 0.000004704640, -0.000109008891, 0.000012938696
1448534152676572, -0.000142334592, 0.000007828226, -0.000690973969, 0.000011021827, -0.000116716296, 0.000013978659
1448534152726570, -0.000012580036, 0.000089568445, -0.000791200925, 0.000033929342, -0.000148412948, 0.000009564050
1448534152776568, -0.000035494673, 0.000095962351, -0.000772499808, 0.000031521704, -0.000143479440, 0.000008744500
I already know that if I'd like to accomplish such a functionality I have to write a plugin. But before I do that I'd like to test these values. To test them I assumed I have to use the "Edit -> Sensors -> TLS/GBL -> Create" menu poiint, but I don't know how to input these values in the Sensor parameters window. How does this data fit in that form?
Do I have to transpose/transform these values into a 4x4 matrix?

Image
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Camera/sensor poses. How do you set them in CC?

Post by daniel »

If you really want to create an animation then you should create either 'projective camera' entities or 'viewport' entities.

The later will even let you use the qAnimation plugin. In which case you would only need to create a bunch of 'cc2DViewportObject' objects when loading your file. This could even be done quite easily in a 'I/O' plugin (look at the 'qCSVMatrixIO' plugin for an example - you don't even need a dialog in your case, or maybe just one to set the missing parameters such as the field of view).

You can leave some parameters of the viewport objects (see ccViewportParameters) to their default values, but be sure to force:

Code: Select all

perspectiveView = true
objectCenteredView = false
cameraCenter = (x y z)
And last but not least, to create the viewing matrix (viewMat) from the 'roll pitch yaw' parameters, you can follow these guidelines:
http://www.songho.ca/opengl/gl_anglestoaxes.html

The rotation matrix (3 x 3) is the upper left part of the (4 x 4) viewMat matrix. Leave the other values to their default (i.e. zeros everywhere but the last diagonal element which should be 1).

Don't hesitate to ask for more directions.
Daniel, CloudCompare admin
pushrbx
Posts: 4
Joined: Wed Apr 06, 2016 10:12 am
Location: UK
Contact:

Re: Camera/sensor poses. How do you set them in CC?

Post by pushrbx »

Thanks for your reply daniel. This OpenGL information was really missing for me.
Please correct me if I'm wrong:
So I have to take the x y z roll pitch yaw values from a row in my text file and make it to a 4x4 matrix.
For the conversion I have a matlab function:

Code: Select all

 	function T = vector6_to_mat4x4(v)
 		T = zeros(4);
 		cr = cos(v(4)); cp = cos(v(5)); cq = cos(v(6));
 		sr = sin(v(4)); sp = sin(v(5)); sq = sin(v(6));
 		T(1,1) = cp*cq; T(1,2) = -cr*sq+sr*sp*cq; T(1,3) = sr*sq+cr*sp*cq;
 		T(2,1) = cp*sq; T(2,2) = cr*cq+sr*sp*sq; T(2,3) = -sr*cq+cr*sp*sq;
 		T(3,1) = -sp; T(3,2) = sr*cp; T(3,3) = cr*cp;
 		T(1,4) = v(1); T(2,4) = v(2); T(3,4) = v(3); T(4,4) = 1.0;
Then take this 4x4 matrix and convert it to a 3x3 matrix based on what you said and the link you have provided. Am I right?
daniel
Site Admin
Posts: 7711
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Camera/sensor poses. How do you set them in CC?

Post by daniel »

Oh, your matlab code does pretty much the same job as the link I sent you. You already have your 'viewMat' matrix here (which is a 4x4 matrix). Maybe you will have to invert it afterwards (there's an 'invert' method on the ccGLMarix class) but you'll have to actually test it to realize that ;)

And it's better to remove the translation from the 'viewMat' matrix (the 'T(1,4) = v(1); T(2,4) = v(2); T(3,4) = v(3);' part) and set it as 'cameraCenter' (if you use a viewport object). But that's not mandatory.
Daniel, CloudCompare admin
Post Reply