From ec8d59fa9bd2e6ff9991b9756d97fafaaf432b9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20M=C3=BCller?= <thomas94@gmx.net>
Date: Tue, 16 Aug 2022 10:57:34 +0200
Subject: [PATCH] Fix NaNs in colmap2nerf.py

---
 scripts/colmap2nerf.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/colmap2nerf.py b/scripts/colmap2nerf.py
index b3fdfe8..b4f463e 100755
--- a/scripts/colmap2nerf.py
+++ b/scripts/colmap2nerf.py
@@ -306,10 +306,11 @@ if __name__ == "__main__":
 			for g in out["frames"]:
 				mg = g["transform_matrix"][0:3,:]
 				p, w = closest_point_2_lines(mf[:,3], mf[:,2], mg[:,3], mg[:,2])
-				if w > 0.01:
+				if w > 0.00001:
 					totp += p*w
 					totw += w
-		totp /= totw
+		if totw > 0.0:
+			totp /= totw
 		print(totp) # the cameras are looking at totp
 		for f in out["frames"]:
 			f["transform_matrix"][0:3,3] -= totp
-- 
GitLab