From 755b26168634427bc66ee09a0f61f6f5d5d85969 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 18 Dec 2021 00:53:52 -0500 Subject: [PATCH] Handle geo.txt OPK, altitude 0 cases --- opendm/photo.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/opendm/photo.py b/opendm/photo.py index c77f6ae1..8f6c8ef6 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -695,9 +695,13 @@ class ODM_Photo: return self.omega is not None and \ self.phi is not None and \ self.kappa is not None + + def has_geo(self): + return self.latitude is not None and \ + self.longitude is not None def compute_opk(self): - if self.has_ypr(): + if self.has_ypr() and self.has_geo(): y, p, r = math.radians(self.yaw), math.radians(self.pitch), math.radians(self.roll) # Ref: New Calibration and Computing Method for Direct @@ -724,8 +728,9 @@ class ODM_Photo: delta = 1e-7 - p1 = np.array(ecef_from_lla(self.latitude + delta, self.longitude, self.altitude)) - p2 = np.array(ecef_from_lla(self.latitude - delta, self.longitude, self.altitude)) + alt = self.altitude if self.altitude is not None else 0.0 + p1 = np.array(ecef_from_lla(self.latitude + delta, self.longitude, alt)) + p2 = np.array(ecef_from_lla(self.latitude - delta, self.longitude, alt)) xnp = p1 - p2 m = np.linalg.norm(xnp)