Hi,
using chatgpt i'v been trying to generate a script to export orthopicture using chunklabels and the date of each chunk's photoshoot without any luck (by extracting the date of the first picture for example)
import Metashape
# get the active chunk
chunk = Metashape.app.document.chunk
# set the output path
output_path = "C:\X"
# set the projection and resolution
crs = Metashape.CoordinateSystem("EPSG::32638")
resolution = 0.002
# loop through the cameras and find a valid orthorectification region
valid_ortho = None
for camera in chunk.cameras:
if not camera.transform:
continue
region = chunk.regionForCamera(camera.transform, camera.photo.meta["sensorWidth"], camera.photo.meta["sensorHeight"], crs)
if region:
valid_ortho = region
break
# check if a valid orthorectification region was found
if valid_ortho:
# set the orthophoto file name
date = camera.photo.meta["Exif/DateTime"].strftime("%Y%m%d")
filename = "{}_ortho1_{}.tif".format(chunk.label, date)
# export the orthophoto
chunk.exportOrthophoto(
path=output_path + filename,
projection=crs,
dx=resolution,
dy=resolution,
format=Metashape.ImageFormatTIFF,
region=valid_ortho
)
else:
print("No valid orthorectification region found.")
what am I doing wrong?
Thanks a lot for your help