Hi,
I am having a problem on mosaic and generating models when the cameras position is fix and object is paced on turn table. With the metashape gui i am able to see result. But I follow exact same process with python script. I am getting wired result. All cameras are not aligned. Not sure what am I missing in script. Any help Below is my script
import Metashape
import os
import glob
Metashape.app.console.clear()
# construct the document class
doc = Metashape.app.document
# doc = Metashape.Document()
output_file_path = './mosaic_result'
project_name = 'object.psx'
output_name = 'object.laz'
file_path = './image/'
psxfile = os.path.join(output_file_path, project_name)
doc.save(psxfile)
chunk = doc.addChunk()
doc.save()
image_path = glob.glob(file_path + '*.jpg')
dir_name = file_path + '/mask'
point_cloud_quality = Metashape.HighQuality
chunk.addPhotos(image_path)
chunk.importMasks(path=dir_name + '/' + '{filename}_mask.png', source=Metashape.MaskSourceFile,
operation=Metashape.MaskOperationReplacement)
calib_file = 'lens_calibration.xml'
calibration = Metashape.Calibration()
calibration.load(calib_file, format='xml')
for sensor in chunk.sensors:
sensor.user_calib = calibration
sensor.fixed = True
chunk.matchPhotos(accuracy=Metashape.HighAccuracy, preselection=Metashape.GenericPreselection,
generic_preselection=True, reference_preselection=False, mask_tiepoints=True,
keypoint_limit=40000, tiepoint_limit=4000)
chunk.alignCameras(adaptive_fitting=True)
aligned = list()
not_aligned = list()
for camera in chunk.cameras:
if camera.transform:
aligned.append(camera)
elif camera.enabled:
not_aligned.append(camera)
camera.transform = None
if len(not_aligned)>0:
chunk.alignCameras(cameras = not_aligned, adaptive_fitting=True)
chunk.buildDepthMaps(quality=point_cloud_quality, filter=Metashape.AggressiveFiltering, reuse_depth=True)
chunk.buildDenseCloud(point_colors=True)
pointcloud_filename = os.path.join(output_file_path, output_name)
chunk.exportPoints(pointcloud_filename, colors=True, colors_rgb_8bit=True)
doc.save()