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???

Hi,

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

import bpy

data = bpy.data.objects['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)
f.close()

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 = bpy.data.objects['Camera']
bpy.context.scene.frame_set(10)
mat = cam.matrix_world
print(mat.to_3x3()) # rotation matrix
print(mat.to_translation) # location