mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-04-23 01:26:37 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import pytest
|
||||
from h02_gsd_calculator import GSDCalculator
|
||||
from f02_1_flight_lifecycle_manager import CameraParameters
|
||||
|
||||
@pytest.fixture
|
||||
def simple_camera():
|
||||
return CameraParameters(
|
||||
focal_length_mm=10.0,
|
||||
sensor_width_mm=10.0,
|
||||
resolution={"width": 1000, "height": 1000}
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def realistic_camera():
|
||||
return CameraParameters(
|
||||
focal_length_mm=25.0,
|
||||
sensor_width_mm=23.5,
|
||||
resolution={"width": 6252, "height": 4168}
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def gsd_calc():
|
||||
return GSDCalculator()
|
||||
|
||||
class TestGSDCalculator:
|
||||
|
||||
def test_calculate_gsd_simple(self, gsd_calc, simple_camera):
|
||||
gsd = gsd_calc.compute_gsd(100.0, simple_camera)
|
||||
assert gsd == pytest.approx(0.1)
|
||||
|
||||
def test_calculate_gsd_realistic(self, gsd_calc, realistic_camera):
|
||||
gsd = gsd_calc.compute_gsd(400.0, realistic_camera)
|
||||
assert gsd == pytest.approx(0.060, abs=0.001)
|
||||
|
||||
def test_meters_per_pixel(self, gsd_calc):
|
||||
m_px = gsd_calc.meters_per_pixel(48.0, 19)
|
||||
assert m_px > 0.0
|
||||
|
||||
def test_altitude_to_scale(self, gsd_calc):
|
||||
scale = gsd_calc.altitude_to_scale(100.0, 25.0)
|
||||
assert scale == 4.0
|
||||
Reference in New Issue
Block a user