Jump to content

Camera parameters


Macha

Recommended Posts

I am writing a python script to convert voodoo camera tracking data to a Houdini camera. Getting the data across seems to work OK. The camera moves and wriggles in kind of the right manner.

However, I am a bit stuck with what exactly the corresponding Houdini parameters are. Voodoo gives me the following:

# f               : Focal Length [mm]
# fov             : Horizontal Field of View [degree] = (2*atan(0.5*Width*sx/f)*180/PI;

How do they relate to Houdini Focal Length and Aperture?

........................

Then, it also gives me the rotation axis.

# (Ax, Ay, Az)    : RotationAxis2  [unit vector]
# (Hx, Hy, Hz)    : RotationAxis0 [pel] (including FocalLength, PixelSizeX, and Principal Point offset) 
# (Vx, Vy, Vz)    : RotationAxis1 [pel] (including FocalLength, PixelSizeY, and Principal Point offset) 

There's probably a neat matrix way to convert this into rx ry rz rotation angles. But for now I calculated angles this way:

def getangle(vec1, vec2):
    v1 = hou.Vector3( vec1 )
    v2 = hou.Vector3( vec2 )
    angle = v1.angleTo(v2)
    return angle

So far so good. Now for the confusion: Which two vectors do I choose to calculate the angles? Like this?

camera_rotation_rx = getangle( A, world_y_axis )
camera_rotation_ry = getangle( H, world_z_axis )
camera_rotation_rz = getangle( V, world_x_axis )

Or did I muddle up things there?

Edited by Macha
Link to comment
Share on other sites

There's some info hidden in the docs about camera aperture, fov, etc:

http://www.sidefx.com/docs/houdini10.0/ref/cameralenses

Just glancing at that page, maybe

(H0x, H0y, H0z) : RotationAxis0 [unit vector]
(V0x, V0y, V0z) : RotationAxis1 [unit vector]

are more useful?

It says there that there's a python export script for blender, maybe that's worth a look if you don't mind cheating :D

Link to comment
Share on other sites

Oh, stealing from Blender. Good idea Michael B)

It appears their camera transformation matrix setMatrix(Mathutils.Matrix(stuff)) with the values of this camera model looks like this:

[HOx,   HOy,  HOz, 0]
[-VOx, -VOy, -VOz, 0]
[-Ax,   -Ay,  -Az, 0]
[ Cx,    Cy,   Cz, 1]

My matrix skills are a bit, err, basic yet, so I guess in Houdini I'd have to use:

cam_mat = hou.Matrix4((
(HOx, HOy, HOz, 0),
(VOx, VOy, VOz, 0),
(Ax,   Ay,  Az, 0),
( Cx,  Cy,  Cz, 1)))

and then

mrot = cam_mat.extractRotates()

#or this
mrot = cam_mat.explode()

to get a rotation vector.

Does that sound about right?

Edited by Macha
Link to comment
Share on other sites

Wohooo! I got it working! Well chuffed now. The camera appears to move the way it should.

Only thing is that f and fov thing that doesn't fit... Hmmm... I'll keep digging...

It looks like a trig problem. According to the docs this should be correct:

tan( fov*.5 ) = (aperture*.5)/f

so then

aperture = 2*f*tan(fov/2)

but it gives me a negative aperture...

Here's what I got so far (with manual fov)

Edited by Macha
Link to comment
Share on other sites

What happens if you just take the absolute value of aperture?

Hmm, in that case I can only see 50% of what I should see. Hmmm. Hmmm.

Oh, hold on! Maybe it's a degrees/radians issue! I'll go try that.

Edited by Macha
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...