14
« on: February 25, 2022, 05:44:15 PM »
Hi. I need to build a point cloud using 5 simultaneous sets of aerial photos (1 nadir view and 4 oblique views) with Python.
I'm stuck at the camera calibration step as I can't manage to assign the pixel_size and focal_length to the imported photos.
Below is the part of the script that should do it but when I run it and open the project in the GUI, the pixel_size and focal_length are blank. What is missing?
import Metashape
import os
data = "D:\Data"
project = Metashape.Document()
project.save(os.path.join(data, "project.psx"))
chunk = project.addChunk()
chunk.crs = Metashape.CoordinateSystem("EPSG::32616")
project.save()
views = ["nadir", "oblique1", "oblique2", "oblique3", "oblique4"]
sens = dict()
for view in views:
sens[view] = chunk.addSensor()
sens[view].label = view
sens[view].pixel_size = Metashape.Vector([0.00520, 0.00520])
if "oblique" in view:
sens[view].focal_length = 123.0
else:
sens[view].focal_length = 82.0
photos = [os.path.join(data, f) for f in os.listdir(data) if f.endswith(".tif")]
chunk.addPhotos(photos)
project.save()
for camera in chunk.cameras:
for view in views:
if view in camera.label:
camera.sensor = sens[view]
project.save()
Thanks