Hello,
Currently, I am working with UAV thermal images and I have to the following steps in python scripting.
1.Load thermal images
2.Load calibration data
3.Load GCP's
4.Select-control points
5. Do alignment
6. Get extrinsic parameters
7.Project GCP's
8. Get errors.
I think I have done till alignment but I am not sure, How to proceed after alignment. I have attached my script with this. Kindly help me.
import glob
try:
import Metashape as env
doc = Metashape.app.document
env_type = 1
except:
import PhotoScan as env
doc = PhotoScan.app.document
env_type = 2
load_images = True
load_thermal = True
# Thermal data
path_calib = 'C:\\Program Files\\Agisoft\\Metashape Pro'
path_images = 'C:\\Program Files\\Agisoft\Metashape Pro\\flir'
path_subdir = 'flir\\'
fileext = '*.tiff'
chunk_name = 'FLIR'
calib_fname = 'xt2_flir_20190206.xml'
flength = 13
psize = 0.017
ch = env.app.document.addChunk()
ch.label = chunk_name
# initiate images list
imgList = []
imgListNames = []
# construct flight directory
dir_srs = path_subdir
# reset file counter
cnt = 0
# go over all images
for filename in glob.glob(dir_srs + fileext):
# add image to list
imgList.append(filename)
fname = filename.split('\\')
# add file name
imgListNames.append(fname[-1])
#' increment counter
cnt += 1
if load_images == 1:
# add images to chunk
ch.addPhotos(imgList)
# create calibration instance
calibData = env.Calibration()
# load calibration data from file
calibData.load(calib_fname, format="xml")
# load camera calibration params
ch.sensors[0].user_calib = calibData
# assign camera focal length
ch.sensors[0].focal_length = flength
# assign camera pixel size
ch.sensors[0].pixel_size = env.Vector([psize,psize])
# do not optimise camera intrinsics
if env_type == 1:
ch.sensors[0].fixed_calibration = True
else:
ch.sensors[0].fixed = True
# ch = Metashape.app.document.chunk
path = '20191024_gcp_coordinates.txt'
ch.loadReference(path, format = Metashape.ReferenceFormatCSV, delimiter=",", columns="nxyz")
for frame in ch.frames:
frame.matchPhotos(accuracy=Metashape.HighestAccuracy, generic_preselection=True,reference_preselection=True)
# ch.matchPhotos(accuracy=Metashape.LowAccuracy, generic_preselection=True,reference_preselection=True)
ch.alignCameras()
# ch.buildDepthMaps(quality=Metashape.MediumQuality, filter=Metashape.AggressiveFiltering)
# ch.buildDenseCloud()
# ch.buildModel(surface=Metashape.Arbitrary, interpolation=Metashape.EnabledInterpolation)
# ch.buildUV(mapping=Metashape.GenericMapping)
# ch.buildTexture(blending=Metashape.MosaicBlending, size=4096)
#optimizeCameras(fit_f=True, fit_cx=True, fit_cy=True, fit_b1=True, fit_b2=True, fit_k1=True, fit_k2=True, fit_k3=True, fit_k4=False, fit_p1=True, fit_p2=True, fit_p3=False, fit_p4=False)