Skip to content

Commit

Permalink
Merge pull request #1765 from pierotofy/undist
Browse files Browse the repository at this point in the history
Speed-up undistortion by 2x
  • Loading branch information
pierotofy authored Jun 11, 2024
2 parents ae6726e + 02bbf38 commit 75c3639
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion SuperBuild/cmake/External-OpenSfM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
GIT_TAG 330
GIT_TAG 352
#--Update/Patch step----------
UPDATE_COMMAND git submodule update --init --recursive
#--Configure step-------------
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.5.1
3.5.2
7 changes: 4 additions & 3 deletions opendm/shots.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def get_geojson_shots_from_opensfm(reconstruction_file, utm_srs=None, utm_offset

for filename in recon.get('shots', {}):
shot = recon['shots'][filename]
cam = shot.get('camera')
if (not cam in cameras) or (filename in added_shots):
cam_id = shot.get('camera')
if (not cam_id in cameras) or (filename in added_shots):
continue

cam = cameras[cam]
cam = cameras[cam_id]
if pseudo_geocoords is not None:
Rs, T = pseudo_geocoords[:3, :3], pseudo_geocoords[:3, 3]
Rs1 = np.linalg.inv(Rs)
Expand Down Expand Up @@ -104,6 +104,7 @@ def get_geojson_shots_from_opensfm(reconstruction_file, utm_srs=None, utm_offset
'type': 'Feature',
'properties': {
'filename': filename,
'camera': cam_id,
'focal': cam.get('focal', cam.get('focal_x')), # Focal ratio = focal length (mm) / max(sensor_width, sensor_height) (mm)
'width': cam.get('width', 0),
'height': cam.get('height', 0),
Expand Down
18 changes: 13 additions & 5 deletions opendm/video/srtparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,24 @@ def get_gps(self, timestamp):
prev_coords = None

if not self.gps_data:
i = 0
for d in self.data:
lat, lon, alt = d.get('latitude'), d.get('longitude'), d.get('altitude')
if alt is None:
alt = 0
tm = d.get('start')

if lat is not None and lon is not None:
if self.ll_to_utm is None:
self.ll_to_utm, self.utm_to_ll = location.utm_transformers_from_ll(lon, lat)

coords = self.ll_to_utm.TransformPoint(lon, lat, alt)

# First or new (in X/Y only)
add = (not len(self.gps_data)) or (coords[0], coords[1]) != (self.gps_data[-1][1][0], self.gps_data[-1][1][1])
# First or new (in X/Y only) or last
add = (not len(self.gps_data)) or (coords[0], coords[1]) != (self.gps_data[-1][1][0], self.gps_data[-1][1][1]) or i == len(self.data) - 1
if add:
self.gps_data.append((tm, coords))
i += 1

# No data available
if not len(self.gps_data) or self.gps_data[0][0] > timestamp:
Expand All @@ -94,7 +96,7 @@ def get_gps(self, timestamp):
ex, ey, ez = gd_e[1]

dt = (gd_e[0] - gd_s[0]).total_seconds()
if dt >= 10:
if dt == 0:
return None

dx = (ex - sx) / dt
Expand Down Expand Up @@ -143,6 +145,12 @@ def parse(self):
# 2023-07-15 11:55:16,320,933
# [iso : 100] [shutter : 1/400.0] [fnum : 280] [ev : 0] [ct : 5818] [color_md : default] [focal_len : 240] [latitude : 0.000000] [longtitude : 0.000000] [altitude: 0.000000] </font>

# DJI Unknown Model #2
# 1
# 00:00:00,000 --> 00:00:00,033
# No:1, F/2.8, SS 155.55, ISO 100, EV 0, M.M AE_METER_CENTER, A.T (126,109), Luma 106, Coef(1.000000, 1.000000, 1.000000), FaceDetectTag (0), FaceDetectRect (0,0,0,0,), Gain (1.000000,4096), Index (Ev:10085,Nf:0), E.M 0, AERect(n/a), AeAdvScene (GR:91.000000,GWR:1.000000,LLR:0.196683,RR:0.870551), LeCurve(64) (1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,1024,128,), AfSpd 0/0, Af Rect(X:0, Y:0, W:0, H:0), AfPos 0, AwbMode WB_AUTOMATIC, Awb Gain(R:8206, G:4096, B:7058), ColorTemp 5241, B.L (-1020, -1020, -1020, -1020), IQS (39253, 208), ToneInfo (0,16,33,51,68,85,102,119,136,152,169,185,202,218,234,250,266,282,298,314,330,346,362,378,394,410,425,441,457,473,488,500,514,532,550,567,584,602,619,637,654,671,688,705,721,738,754,770,786,801,817,832,847,862,877,892,907,922,937,951,966,981,995,1011,0,64,134,205,274,342,410,477,544,611,677,743,809,873,937,1002,1066,1130,1194,1258,1322,1385,1449,1512,1576,1640,1703,1766,1829,1893,1952,2003,2058,2130,2201,2270,2339,2410,2479,2548,2616,2685,2753,2820,2886,2952,3016,3080,3144,3207,3270,3329,3391,3451,3511,3571,3630,3688,3748,3807,3866,3924,3983,4044,), Isp Info (PIPE 1,ADJ 0,De 0) GPS (-2.5927, 52.0035, 15), D 0.61m, H 1.00m, H.S 0.00m/s, V.S 0.00m/s


with open(self.filename, 'r') as f:

iso = None
Expand Down Expand Up @@ -230,4 +238,4 @@ def parse(self):
("GPS \([\d\.\-]+,? [\d\.\-]+,? ([\d\.\-]+)\)", lambda v: float(v) if v != 0 else None),
("RTK \([-+]?\d+\.\d+, [-+]?\d+\.\d+, (-?\d+)\)", lambda v: float(v) if v != 0 else None),
("abs_alt: ([\d\.\-]+)", lambda v: float(v) if v != 0 else None),
], line)
], line)
12 changes: 12 additions & 0 deletions stages/odm_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def process(self, args, outputs):
log.ODM_WARNING("Cannot extract shots")
else:
log.ODM_WARNING('Found a valid shots file in: %s' % shots_geojson)

camera_mappings = os.path.join(tree.odm_report, "camera_mappings.npz")
if not io.file_exists(camera_mappings) or self.rerun():
src_cm = os.path.join(tree.opensfm, "camera_mappings.npz")
if io.file_exists(src_cm):
shutil.copy(src_cm, camera_mappings)
log.ODM_INFO("Copied %s --> %s" % (src_cm, camera_mappings))
else:
log.ODM_WARNING("Cannot copy camera mappings")
else:
log.ODM_WARNING("Found a valid camera mappings file in: %s" % camera_mappings)


if args.skip_report:
# Stop right here
Expand Down

0 comments on commit 75c3639

Please sign in to comment.