new method based on sensor dimensions and focal length
This commit is contained in:
		
							
								
								
									
										86
									
								
								gopro_8:7/unfish_gopro_8:7.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								gopro_8:7/unfish_gopro_8:7.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,86 @@
 | 
			
		||||
# RozK
 | 
			
		||||
 | 
			
		||||
import math
 | 
			
		||||
 | 
			
		||||
print("\n--- sensor size (millimeters) ---\n")
 | 
			
		||||
 | 
			
		||||
# https://www.sony-semicon.com/files/62/pdf/p-13_IMX677-AAPH5-J_Flyer.pdf
 | 
			
		||||
 | 
			
		||||
sensor_total_array_width    = 5700 # p
 | 
			
		||||
sensor_total_array_height   = 5160 # p
 | 
			
		||||
sensor_total_array_diagonal = math.hypot(sensor_total_array_width, sensor_total_array_height)
 | 
			
		||||
 | 
			
		||||
sensor_pixel_size = 1.12 * 0.001 # mm
 | 
			
		||||
 | 
			
		||||
sensor_total_width    = sensor_total_array_width * sensor_pixel_size
 | 
			
		||||
sensor_total_height   = sensor_total_array_height * sensor_pixel_size
 | 
			
		||||
sensor_total_diagonal = math.hypot(sensor_total_width, sensor_total_height)
 | 
			
		||||
 | 
			
		||||
# sensor_total_diagonal = 8.35 # mm
 | 
			
		||||
# sensor_total_width    = sensor_total_diagonal * (sensor_total_array_width  / sensor_total_array_diagonal)
 | 
			
		||||
# sensor_total_height   = sensor_total_diagonal * (sensor_total_array_height / sensor_total_array_diagonal)
 | 
			
		||||
 | 
			
		||||
print("sensor  total: width = %.6f, height = %.6f, diagonal = %.6f" % (
 | 
			
		||||
    sensor_total_width,
 | 
			
		||||
    sensor_total_height,
 | 
			
		||||
    sensor_total_diagonal))
 | 
			
		||||
 | 
			
		||||
sensor_active_array_width    = 5599 # p
 | 
			
		||||
sensor_active_array_height   = 4927 # p
 | 
			
		||||
sensor_active_array_diagonal = math.hypot(sensor_active_array_width, sensor_active_array_height)
 | 
			
		||||
 | 
			
		||||
sensor_active_width    = (sensor_active_array_width    / sensor_total_array_width)    * sensor_total_width
 | 
			
		||||
sensor_active_height   = (sensor_active_array_height   / sensor_total_array_height)   * sensor_total_height
 | 
			
		||||
sensor_active_diagonal = (sensor_active_array_diagonal / sensor_total_array_diagonal) * sensor_total_diagonal
 | 
			
		||||
 | 
			
		||||
print("sensor active: width = %.6f, height = %.6f, diagonal = %.6f" % (
 | 
			
		||||
    sensor_active_width,
 | 
			
		||||
    sensor_active_height,
 | 
			
		||||
    sensor_active_diagonal))
 | 
			
		||||
 | 
			
		||||
# https://community.gopro.com/s/article/HERO11-Black-Video-Settings-And-Resolutions
 | 
			
		||||
 | 
			
		||||
gopro_array_width    = 5312 # p
 | 
			
		||||
gopro_array_height   = 4648 # p
 | 
			
		||||
gopro_array_diagonal = math.hypot(gopro_array_width, gopro_array_height)
 | 
			
		||||
 | 
			
		||||
gopro_sensor_width    = (gopro_array_width    / sensor_total_array_width)    * sensor_total_width
 | 
			
		||||
gopro_sensor_height   = (gopro_array_height   / sensor_total_array_height)   * sensor_total_height
 | 
			
		||||
gopro_sensor_diagonal = (gopro_array_diagonal / sensor_total_array_diagonal) * sensor_total_diagonal
 | 
			
		||||
 | 
			
		||||
print("gopro  active: width = %.6f, height = %.6f, diagonal = %.6f" % (
 | 
			
		||||
    gopro_sensor_width,
 | 
			
		||||
    gopro_sensor_height,
 | 
			
		||||
    gopro_sensor_diagonal))
 | 
			
		||||
 | 
			
		||||
# https://thinglabs.io/gopro-focal-length-guide
 | 
			
		||||
 | 
			
		||||
gopro_focal_length = 2.92 # mm
 | 
			
		||||
 | 
			
		||||
print("\n--- fisheye field of view (degrees) ---\n")
 | 
			
		||||
 | 
			
		||||
# https://en.wikipedia.org/wiki/Fisheye_lens
 | 
			
		||||
 | 
			
		||||
equidistant_angle  = lambda length: math.degrees(length / gopro_focal_length)
 | 
			
		||||
 | 
			
		||||
gopro_fov_width    = 2.0 * equidistant_angle(gopro_sensor_width    * 0.5)
 | 
			
		||||
gopro_fov_height   = 2.0 * equidistant_angle(gopro_sensor_height   * 0.5)
 | 
			
		||||
gopro_fov_diagonal = 2.0 * equidistant_angle(gopro_sensor_diagonal * 0.5)
 | 
			
		||||
 | 
			
		||||
print("gopro fov: width = %.6f, height = %.6f, diagonal = %.6f" % (
 | 
			
		||||
    gopro_fov_width,
 | 
			
		||||
    gopro_fov_height,
 | 
			
		||||
    gopro_fov_diagonal))
 | 
			
		||||
 | 
			
		||||
print("\n--- rectilinear focal length (mm) ---\n")
 | 
			
		||||
 | 
			
		||||
rectilinear_focal_length = lambda length: length * math.tan(math.radians(90.0 - equidistant_angle(length)))
 | 
			
		||||
 | 
			
		||||
rectilinear_focal_length_width    = rectilinear_focal_length(gopro_sensor_width    * 0.5)
 | 
			
		||||
rectilinear_focal_length_height   = rectilinear_focal_length(gopro_sensor_height   * 0.5)
 | 
			
		||||
rectilinear_focal_length_diagonal = rectilinear_focal_length(gopro_sensor_diagonal * 0.5)
 | 
			
		||||
 | 
			
		||||
print("rectilinear focal length: width = %.6f, height = %.6f, diagonal = %.6f" % (
 | 
			
		||||
    rectilinear_focal_length_width,
 | 
			
		||||
    rectilinear_focal_length_height,
 | 
			
		||||
    rectilinear_focal_length_diagonal))
 | 
			
		||||
		Reference in New Issue
	
	Block a user