Hello,
This may be related to this question, but I wasn't sure. The problem may just be that I'm fairly new to metashape in python, and I hope that the solution to this problem is obvious to someone who isn't me.
I have a model that was made in two parts on a turntable. I've generated the masks for each photo in photoshop as TIFs and saved them off in a folder called "masks". I load all the pictures into one chunk, load the masks, and I then run the "align photos" workflow step with the settings as shown in the screenshot attached. In short:
- Generic Preselection is checked
- Reset current alignment is NOT checked
- Reference preselection is Source (default)
- Accuracy is High
- Tiepoint limit is 0
- Masks applied to Key points
- Exclude Stationary Tiepoints is checked
- Guided matching is not checked
- Adaptive fitting is checked.
All my photos align, and I get a sparse cloud with a lot of points.
However, when I run the following code, which should do the same thing (I think), only about 4/100 pics align
doc = Metashape.Document()
if os.path.exists(newproject):
doc.open(path=newproject)
doc.save(path=newproject)
#add a new chunk
chunk = None
if len(doc.chunks)==0:
chunk = doc.addChunk()
else:
chunk = doc.chunks[0]
#add the photos in the specified directory to that chunk.
images = os.listdir(photodir)
for i in images:
if os.path.splitext(i)[1] in [".jpg", ".tiff",".tif"]:
chunk.addPhotos(os.path.join(photodir,i))
doc.save()
#Add Masks if needed.
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()
Any advice as to why the two methods don't produce the same results is appreciated. I've opened the doc that is created, and all the masks have loaded correctly, and all the pictures are present.