stereobase.py

Created by andy-modla

Created on June 17, 2019

1.8 KB

For 3D photography, calculate the stereo base for dual left and right cameras or sequential left and right eye photos from a single camera. The calculated base (mm) gives the most comfortable viewing experience for the stereo photo. Use different formulas for normal, close-up, or macro photography. Reference: http://nzphoto.tripod.com/stereo/3dtake/fbercowitz.htm


## 3D Photography: Stereo base calculation
# For dual camera stereo configuration 
# or single camera sequential L/R base separation
# Assumes 35mm equivalent lens focal length 
# P parallax for standard 35mm film - 36mm x 24 mm
#   P = 1.2 for 1/30 of 36mm width, 3.33% deviation
#   Assumes 3.33% is maximum deviation for comfortable viewing
#  This is the standard 1/30 rule.
# F lens focal length mm
# N near subject distance mm
# L background distance mm
# B stero base mm, the cameras interaxial distance

# Reference: http://nzphoto.tripod.com/stereo/3dtake/fbercowitz.htm

# Bercovitz formula for dual camera separation
def base(F, N, L, P=1.2):
  B=P*((L*N)/(L-N))*(1/F-(L+N)/(2*L*N))
  return B

# same as base()
def b(F, N, L, P=1.2):
  B=P/(L-N)*(L*N/F-(L+N)/2)
  return B

def near(F, B, L, P=1.2):
  t=B/P
  N = (L*(t + 0.5))/(t+L/F-0.5)
  return N
  
def far(F, B, N, P=1.2):
  t=B/P
  L = N*(t-0.5)/(t-N/F+0.5)
  return L

def focal(B, N, L, P=1.2):
  F = (L*N)/(B*(L-N)/P + (L+N)/2)
  return F
  
# Davis modification of Bercovitz formula for close-up photography
# assumes background is close to the subject
def base_closeup(F, N, L, P=1.2):
    if L<2*N:
        L = 2*N
    B=P*((L*N)/(L-N))*(1/F-(L+N)/(2*L*N))
    return B

# Wattie modification of Bercovitz formula for correct roundness
# for macro photography
# V is viewing distance mm typically 600mm for 15 inch diagonal notebook
# I is Interocular distance mm, average 63mm
def base_macro(F, N, L, V, I=63, P=1.2):
  B=P*((L*N)/(L-N))*(1/F-(L+N)/(2*L*N))
  W = N*I/V
  if W < B:
    return W
  else:
    return B

def base_meindre(F, N, L, P=1.2):
  B = (P/F)*((L*N)/(L-N))
  return B

def near_meindre(F, B, L, P=1.2):
  t = F*B/P
  N = (t*L)/(t + L)
  return N

# shortcut for close-up
def bc(F, N, L, P=1.2):
  return base_closeup(F, N, L)
  

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.