4
$\begingroup$

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?

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

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
| improve this answer | |
$\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.