Hello Everyone,
I tried to run the script but I am getting this error. My calibration file is .xml format and I have done this before in the same way but now I am getting this error. Help me with this problem. I have attached the code with this.
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 = '20191220_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()