Metashape调用Python API实现自动图像拼接

# 载入所需库函数
import Metashape
import os

# 输入输出文件夹
input_path = ""
output_path = ""


# 寻找图片函数
def find_files(folder, types):
    return [entry.path for entry in os.scandir(folder) if (entry.is_file() and os.path.splitext(entry.name)[1].lower() in types)]


# 创建一个新项目
doc = Metashape.app.document
if not doc:
    doc = Metashape.Document()

# 检查是否已经存在Chunk,如果不存在则创建一个
if not doc.chunk:
    chunk = doc.addChunk()
else:
    chunk = doc.chunk  # 或者选择当前的chunk

# 导入图片
photos = find_files(input_path, [".jpg", ".jpeg", ".tif", ".tiff"])
chunk.addPhotos(photos)

# 图片对齐
chunk.matchPhotos(generic_preselection=True,
                  reference_preselection=False)
chunk.alignCameras()

# 建立深度图
chunk.buildDepthMaps()
# 生成密集点云
chunk.buildDenseCloud()
# 保存
doc.save(input_path + "/project.psx")

# 构建DEM
chunk = doc.chunk
chunk.buildDem(source_data=Metashape.DataSo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值