Getting camera parameters

Hi i am using blender 2.60. i want to write a script that will get the camera parameters from blender. take a picture and then write these parameters to a txt file. Can anybody help???


a little more details would have been helpful (what do you mean by ‘take a picture?’). Anyway, maybe this snippet helps:

import bpy

data =['Camera'].data

f = open('c:\del\camera.txt', 'w')
f.write('Sensor width: %.3f
' % data.sensor_width)
f.write('Sensor height: %.3f
' % data.sensor_height)
f.write('Focal length: %.3f
' % data.lens)

The camera must be named ‘Camera’ for the script to work. It creates a file c:\del\camera.txt.

By camera parameters i mean rotation value and the location value. I get these values render and then i go to next random position again take the parameters and render again. and it goes on

Quick example how to get rotation and location of camera at frame 10:

cam =['Camera']
mat = cam.matrix_world
print(mat.to_3x3()) # rotation matrix
print(mat.to_translation) # location