1

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 !

Lazare
  • 11
  • 1

1 Answers1

1

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

Jaroslav Jerryno Novotny
  • 51,077
  • 7
  • 129
  • 218