Equirectangular image (λ±μ₯λ°©ν μ΄λ―Έμ§)
Equirectangular imageλ ꡬ면 μ’νκ³λ₯Ό μ§κ° μ’νκ³λ‘ 맀νν μ΄λ―Έμ§μ
λ‘ κ΅¬λ©΄ μ’νκ³μ κ°λλ₯Ό μ§κ° μ’νκ³μ ν½μ
λ‘ μΌλμΌ λ§€ννμ¬ νννλ€.
ꡬ면 μ’νκ³μμλ μλ(latitude)μ κ²½λ(longitude)λ‘ μ΄λ―Έμ§λ₯Ό νννλλ°, μλλ ꡬμ μν λ°©ν₯μ λνλ΄λ©°, -90μμ 90λκΉμ§μ λ²μλ₯Ό κ°μ§κ³ κ²½λλ ꡬμ μμ§ λ°©ν₯μ λνλ΄λ©°, -180μμ 180λκΉμ§μ λ²μλ₯Ό κ°μ§λ€. Equirectangular μ΄λ―Έμ§λ μ΄λ¬ν ꡬ면 μ’νκ³λ₯Ό μ¬μ©νμ¬ μ΄λ―Έμ§λ₯Ό νννλ€. μ΄λ―Έμ§μ λλΉλ 360λμ κ²½λ λ²μμ 맀νλκ³ , λμ΄λ -90μμ 90λμ μλ λ²μμ 맀νλλ€. λ°λΌμ μ΄λ―Έμ§μ ν¬κΈ°λ κ²½λμ μλμ ν΄μλμ λ°λΌ κ²°μ λλ€.
μ΄λ¬ν Equirectangular μ΄λ―Έμ§λ μ£Όλ‘ 360λ λμμ, κ°μ νμ€(VR) μ΄λ―Έμ§, νμ± νλ©΄ μ΄λ―Έμ§ λ±κ³Ό κ°μ ꡬν λ°μ΄ν°λ₯Ό νννλ λ° μ¬μ©λλλ°, μ΄λ¬ν μ΄λ―Έμ§λ ꡬ면 μ’νκ³μ νΉμ±μ 보쑴νλ©΄μλ μ§κ° μ’νκ³μμμ μ΄λ―Έμ§ μ²λ¦¬ λ° λΆμμ κ°λ₯νκ² νλ€.
ꡬ면μ’νκ³ λ³ν
Equirectangular imageλ κ°λ‘(x) 360λ, μΈλ‘(y) 180λμ λ²μλ₯Ό κ°μ§κΈ° λλ¬Έμ ꡬ면 μ’νκ³λ‘ λ³νν μ μλ€.
μ΄λ―Έμ§ μ’νλ₯Ό 0~1 μ¬μ΄λ‘ μ κ·ννκ³ μλ(latitude)μ κ²½λ(longtitude)λ₯Ό μμ κ°μ΄ κ³μ°νλ©΄ λλ€.
ꡬ면 μ’νκΉμ§μ 3D 벑ν°
μΉ΄λ©λΌ μ€μ¬μμ ꡬ면 μ’ν μ§μ κΉμ§μ 3D 벑ν°λ₯Ό κ³μ°ν μ μλλ°, μμ κ°μ΄ μ§κ°μ’νκ³ μ’ν(x, y, z)λ₯Ό ꡬνκ³ λ²‘ν°λ₯Ό κ³μ°ν μ μλ€.
import numpy as np
def image_to_spherical_coordinates(x_image, y_image, image_width, image_height):
# Normalize image coordinates to the range [0, 1]
x_normalized = x_image / (image_width - 1)
y_normalized = y_image / (image_height - 1)
# Calculate latitude (elevation) and longitude (azimuth) from normalized image coordinates
phi = np.pi * y_normalized
theta = 2 * np.pi * x_normalized
return phi, theta
def spherical_to_cartesian(phi, theta, r):
x = r * np.sin(phi) * np.cos(theta)
y = r * np.sin(phi) * np.sin(theta)
z = r * np.cos(phi)
return np.array([x, y, z])
def relative_vector_from_image_coordinates(x_image, y_image, image_width, image_height, camera_center, radius):
# Convert image coordinates to spherical coordinates
phi, theta = image_to_spherical_coordinates(x_image, y_image, image_width, image_height)
# Convert spherical coordinates to Cartesian coordinates
vector = spherical_to_cartesian(phi, theta, radius)
# Calculate relative vector from camera center to the point
relative_vector = vector - camera_center
return relative_vector
# Example inputs
x_image = 100 # Example image x-coordinate
y_image = 50 # Example image y-coordinate
image_width = 800 # Example image width
image_height = 600 # Example image height
camera_center = np.array([0, 0, 0]) # Example camera center
radius = 1 # Example radius
# Calculate the relative vector
relative_vector = relative_vector_from_image_coordinates(x_image, y_image, image_width, image_height, camera_center, radius)
print("Relative vector:", relative_vector)
μΉ΄λ©λΌ roll & pitch & yawλ₯Ό μ΄μ©ν μ λ μ’ν λ²‘ν° λ³ν
νμ¬κΉμ§ κ³μ°ν 벑ν°λ μ΄λ―Έμ§ κΈ°μ€μΌλ‘ κ³μ°ν μλ μ’ν 벑ν°μ΄λ€. λλ¬Έμ μ λ μ’ν 벑ν°λ₯Ό μ»κΈ° μν΄μλ μΉ΄λ©λΌ νμ κ°λμΈ roll, pitch, yawλ₯Ό μ΄μ©νμ¬ κ΅¬λ©΄ μ’νμμ 벑ν°λ₯Ό νμ ν΄μΌ νλ€.
import numpy as np
from scipy.spatial.transform import Rotation
def spherical_to_cartesian(phi, theta, r):
x = r * np.sin(phi) * np.cos(theta)
y = r * np.sin(phi) * np.sin(theta)
z = r * np.cos(phi)
return np.array([x, y, z])
def absolute_vector_from_spherical(phi, theta, r, camera_center, roll, pitch, yaw):
# Convert spherical coordinates to Cartesian coordinates
vector = spherical_to_cartesian(phi, theta, r)
# Create a rotation object using Euler angles (roll, pitch, yaw)
r = Rotation.from_euler('xyz', [roll, pitch, yaw], degrees=True)
# Rotate the vector
rotated_vector = r.apply(vector)
# Translate the rotated vector to the camera center
absolute_vector = rotated_vector + camera_center
return absolute_vector
# Example inputs
phi = np.pi/4 # Example elevation
theta = np.pi/4 # Example azimuth
r = 1 # Example radius
camera_center = np.array([0, 0, 0]) # Example camera center
roll = 30 # Example roll angle in degrees
pitch = 45 # Example pitch angle in degrees
yaw = 60 # Example yaw angle in degrees
# Calculate the absolute vector
absolute_vector = absolute_vector_from_spherical(phi, theta, r, camera_center, roll, pitch, yaw)
print("Absolute vector:", absolute_vector)