Macha Posted March 11, 2010 Share Posted March 11, 2010 (edited) 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 March 11, 2010 by Macha Quote Link to comment Share on other sites More sharing options...
Macha Posted March 11, 2010 Author Share Posted March 11, 2010 BTW, the complete camera model specification is here, in case I missed an important piece of info: http://www.digilab.uni-hannover.de/docs/manual.html#cahvmodel Quote Link to comment Share on other sites More sharing options...
mrice Posted March 11, 2010 Share Posted March 11, 2010 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 Quote Link to comment Share on other sites More sharing options...
Macha Posted March 12, 2010 Author Share Posted March 12, 2010 (edited) Oh, stealing from Blender. Good idea Michael 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 March 12, 2010 by Macha Quote Link to comment Share on other sites More sharing options...
Macha Posted March 12, 2010 Author Share Posted March 12, 2010 (edited) 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 March 12, 2010 by Macha Quote Link to comment Share on other sites More sharing options...
edward Posted March 12, 2010 Share Posted March 12, 2010 What happens if you just take the absolute value of aperture? Quote Link to comment Share on other sites More sharing options...
Macha Posted March 12, 2010 Author Share Posted March 12, 2010 (edited) 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 March 12, 2010 by Macha Quote Link to comment Share on other sites More sharing options...
Macha Posted March 12, 2010 Author Share Posted March 12, 2010 Degrees/radians does not appear to be the problem. What does aperture actually stand for in Houdini? The helpcard says it is " Width of the visible field." In millimiters? Degrees? Is it a ratio? Quote Link to comment Share on other sites More sharing options...
edward Posted March 13, 2010 Share Posted March 13, 2010 It is a distance measure in whatever units you choose as long as it is consistent with all the other values you use in your scene. Quote Link to comment Share on other sites More sharing options...
Macha Posted March 13, 2010 Author Share Posted March 13, 2010 Oh, thanks. It also appears as if voodoo is giving me nonsense focal lengths, depending on its settings. No wonder everything I tried went wrong. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.