Skip to content

Commit

Permalink
Merge pull request #63 from open-forest-observatory/dy_separate-camer…
Browse files Browse the repository at this point in the history
…a-export

Pull cameras xml export out of align_photos
  • Loading branch information
russelldj authored Jul 26, 2024
2 parents f3280bf + d5369d2 commit 4fe1a48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 8 additions & 2 deletions config/config-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ calibrateReflectance: # (Metahsape: calibrateReflectance)
use_reflectance_panels: True
use_sun_sensor: True

alignPhotos: # (Metashape: matchPhotos, alignCameras, (optionally) exportCameras)
alignPhotos: # (Metashape: matchPhotos, alignCameras)
enabled: True
downscale: 2 # How much to coarsen the photos when searching for tie points. Higher number for blurrier photos or when there are small surfaces that may move between photos (such as leaves). Accepts numbers 2^x (and zero) (https://www.agisoft.com/forum/index.php?topic=11697.0).
adaptive_fitting: True # Should the camera lens model be fit at the same time as aligning photos?
Expand All @@ -75,7 +75,6 @@ alignPhotos: # (Metashape: matchPhotos, alignCameras, (optionally) exportCameras
generic_preselection: True # When matching photos, use a much-coarsened version of each photo to narrow down the potential neighbors to pair? Works well if the photos have high altitude above the surface and high overlap (e.g. a 120m nadir 90/90 overlap mission), but doesn't work well for low-altitude and/or highly oblique photos (e.g. a 80m 25deg pitch 80/80 overlap mission)
reference_preselection: True # When matching photos, use the camera location data to narrow down the potential neighbors to pair?
reference_preselection_mode: Metashape.ReferencePreselectionSource # When matching photos, use the camera location data to narrow down the potential neighbors to pair?
export: True # Export the camera locations

# To use GCPs, a 'gcps' folder must exist in the root of the photo folder provided in photo_path
# above (or the first folder, if a list is passed). The contents of the 'gcps' folder are created by
Expand All @@ -101,6 +100,13 @@ optimizeCameras: # (Metashape: optimizeCameras)
adaptive_fitting: True # Should the camera lens model be fit at the same time as optimizing photos?
export: True # Export the camera locations, now updated from the initial alignment

# Should an xml file specifying estimated camera locations (transform matrices) be exported? If
# enabled, it is exported once after all alignment-related steps (e.g., align, fliter points,
# optimize cameras) -- even if these steps are disabled -- and then again after aligning the
# secondary set of locations (if performed), overwriting the first file
exportCameras: # (Metashape: exportCameras)
enabled: True

buildDepthMaps: # (Metashape: buildDepthMaps)
enabled: True
downscale: 4 # How much to coarsen the photos when searching for matches to build the point cloud. For large photosets, values < 4 likely take prohibitively long. Accepts numbers 2^x (https://www.agisoft.com/forum/index.php?topic=11697.0).
Expand Down
22 changes: 8 additions & 14 deletions python/metashape_workflow_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Derek Young and Alex Mandel
# University of California, Davis
# 2021

#### Import libraries
import datetime
import glob
Expand Down Expand Up @@ -125,7 +121,7 @@ def run(self):
if self.cfg["alignPhotos"]["enabled"]:
self.align_photos()
self.reset_region()

if self.cfg["filterPointsUSGS"]["enabled"]:
self.filter_points_usgs_part1()
self.reset_region()
Expand All @@ -142,6 +138,9 @@ def run(self):
self.filter_points_usgs_part2()
self.reset_region()

if self.cfg["exportCameras"]["enabled"]:
self.export_cameras()

if self.cfg["buildDepthMaps"]["enabled"]:
self.build_depth_maps()

Expand All @@ -157,6 +156,9 @@ def run(self):
if self.cfg["photo_path_secondary"] != "":
self.add_align_secondary_photos()

if self.cfg["exportCameras"]["enabled"]:
self.export_cameras()

self.export_report()

self.finish_run()
Expand Down Expand Up @@ -573,11 +575,7 @@ def align_photos(self):
# calculate difference between end and start time to 1 decimal place
time1 = diff_time(timer1b, timer1a)

# optionally export
if self.cfg["alignPhotos"]["export"]:
self.export_cameras()

# record results to file
# record processing time to file
with open(self.log_file, "a") as file:
file.write(MetashapeWorkflow.sep.join(["Align Photos", time1]) + "\n")

Expand Down Expand Up @@ -629,10 +627,6 @@ def optimize_cameras(self):

self.doc.save()

# optionally export, note this would override the export from align_cameras
if self.cfg["optimizeCameras"]["export"]:
self.export_cameras()

return True

def filter_points_usgs_part1(self):
Expand Down

0 comments on commit 4fe1a48

Please sign in to comment.