I could just use:
obj_camera = bpy.data.objects["Camera"]
to get the camera, but it is possible to have a scene with multiple cameras.
So if that is the case, how can I choose the active one?
The property you are looking for is 'Scene.camera'.
If you have 'python tooltips' enabled in the user preferences you can hover over the camera field in the 'Scene' tab of the 'Properties' area, to reveal the python code for this property:
The code to access this property for the current scene and assign it to a variable is:
obj_camera = bpy.context.scene.camera
"active" is a weak definition, there is the scene camera (can also be
None), but it could also mean the active object and that object being a camera. A special case is operator Set active object as camera, which makes an arbitrary object the scene camera.
cam_ob = bpy.context.scene.camera if cam_ob is None: print("no scene camera") elif cam_ob.type == 'CAMERA': print("regular scene cam") else: print("%s object as camera" % cam_ob.type) ob = bpy.context.object if ob is not None and ob.type == 'CAMERA': print("Active camera object")