# How can I get the projection matrix of a panoramic camera with a fisheye equisolid lens?

I am working on a project in which i used the panoramic camera with fisheye equisolid lens on Cycles render. For some tests, I need the projection model that uses by this camera to project a 3D point on a 2D image plane. Any help?

• It so nervous to do not get this important information. We get just a naive black box! Nov 4 '15 at 21:44
• Blender is open source, there is no black box :) Jan 10 '16 at 9:35
• @zeffii, thanks, could you tell me the link where I can find the details of panoramic camera projection model used in blender? Jan 11 '16 at 14:42
• github.com/dfelinto/blender/search?utf8=%E2%9C%93&q=fisheye ( a convenient way to browse Blender's source) Jan 11 '16 at 14:49

I needed to do this recently. I think the following code should do the trick.

p is our point in 3D space.

camera = bpy.data.cameras["Camera"]
scene = bpy.context.scene

f = camera.cycles.fisheye_lens
w = camera.sensor_width
h = (3/4) * w # Depends on aspect ratio. For some reason I don't get the correct value from camera.sensor_height

camera_ob = bpy.data.objects["Camera"]

p = camera_ob.matrix_world.inverted() * p
p.normalize()

# Calculate our angles
phi = math.atan2(p.y, p.x)
l = (p.x**2 + p.y**2)**(1/2)
theta = math.asin(l)

# Equisolid projection
r = 2.0 * f * math.sin(theta / 2)

u = r * math.cos(phi) / w + 0.5
v = r * math.sin(phi) / h + 0.5

x = u * scene.render.resolution_x
y = v * scene.render.resolution_y