I'm automating the the photogrammetry workflow for building models of objects on turntables. I have a pot, and I've taken pictures of the top and bottom. I've put these in one chunk rather than two. When I run the align photos workflow step with the following settings, I get a nice point cloud with all pictures aligned.
When I run the following code, which to my knowledge, should do the same thing, I get four pictures aligned, and none of the cameras in the right positions. I've checked in the file, the correct masks have imported correctly. Do you have any idea what I'm doing wrong?
maskKeypoints=False
if config["mask_path"]:
mp = os.path.join(config["mask_path"])
ext = config["mask_ext"]
masktemplate = f"{mp}{os.sep}{{filename}}.{ext}"
chunk.generateMasks(masktemplate,Metashape.MaskingMode.MaskingModeFile)
maskKeypoints=True
doc.save()
#match photos/align photos
chunk.matchPhotos(downscale=consts.PhotogrammetryConsts.AlignDownscale["HIGH"],# =1
filter_stationary_points=True,
reset_matches=True,
filter_mask = maskKeypoints,
generic_preselection=True,
keypoint_limit=40000,
tiepoint_limit=0,
guided_matching=True)
chunk.alignCameras()
doc.save()
I realized a few things about this code. Firstly, Adaptive model filtering doesn't have an obvious analogue in the function parameters in the API. But, most significantly, mask_tiepoints =True
by default in the function declaration, but is disabled by default in the GUI.
Setting mask_tiepoints=False
and filter_mask=True
seems to solve my problem.