1
$\begingroup$

I'd like to know if there's a simple way to get the 3D coordinates of the 4 corners of the active camera: the goal is to export a text file with the rendered image with these coordinates in order to be able to insert the image in a CAD software like autoCAD with the correct orientation and scale, as with a Geotiff image for example. This should be possible with a python script but the most difficult for me is to get the 3D coordinates of the corners of the image... Thanks a lot !

$\endgroup$
1
$\begingroup$

This is how to get camera corners 3D positions:

import bpy

cam = bpy.context.scene.camera
frame_local = cam.data.view_frame(bpy.context.scene)

# Its in local space so transform to global
frame_global = [cam.matrix_world * corner for corner in frame_local]

# Output to System console
locations = ["TopRight   ", "BottomRight", "BottomLeft ", "TopLeft    "]
for location, corner in zip(locations, frame_global):
    print("corner {0}: {1}".format(location, corner))

Here you can find more that might interest you:

Casting rays into the scene for each pixel

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.