metashape-pro python scripts render specified viewpoint

2023-05-16

官方python脚本使用文档

主函数: render=chunk.model.renderImage()

在这里插入图片描述

1. 实现特定视角的渲染需要通过脚本方式进行,原本的metashape pro中是没有这个功能的

首先在metashape pro所在的文件夹中新建 test.py ,将脚本内容写在该文件中,然后回到metashape Tools -> Run Script 运行 test.py 这样metashape界面就会出现一个新的 Scripts 选项,这个选项下,就是你所需要的通过脚本添加的功能。

注意:每一次 Run Scripts 集成的功能是固定死的… 如果代码发生修改,需要重新跑脚本添加相应功能,并且每个按钮是不覆盖的。

# Script save model renders for selected cameras (or all aligned cameras if no aligned cameras selected)
# to the same folder where the source photos are present with the "_render" suffix.
#
# This is python script for Metashape Pro. Scripts repository: https://github.com/agisoft-llc/metashape-scripts
import json
import Metashape
import os

# Checking compatibility
compatible_major_version = "1.6"
found_major_version = ".".join(Metashape.app.version.split('.')[:2])
if found_major_version != compatible_major_version:
    raise Exception("Incompatible Metashape version: {} != {}".format(found_major_version, compatible_major_version))


def get_cameras(chunk):
    selected_cameras = [camera for camera in chunk.cameras if camera.transform and camera.selected and camera.type == Metashape.Camera.Type.Regular]

    if len(selected_cameras) > 0:
        return selected_cameras
    else:
        return [camera for camera in chunk.cameras if camera.transform and camera.type == Metashape.Camera.Type.Regular]


def render_cameras():
    print("Script started...")

    chunk = Metashape.app.document.chunk
    # if not chunk.model:
    #     raise Exception("No model!")

    # for camera in get_cameras(chunk):
    #     if not camera.type == Metashape.Camera.Type.Regular: #skip camera track, if any
    #         continue

    #     render = chunk.model.renderImage(camera.transform, camera.sensor.calibration)

    #     photo_dir = os.path.dirname(camera.photo.path)
    #     print("###photo dir:",photo_dir)
    #     photo_filename = os.path.basename(camera.photo.path)
    #     render_filename = os.path.splitext(photo_filename)[0] + "_render.jpg"
    #     print("render filename:",os.path.join(photo_dir, render_filename))
    #     render.save(os.path.join(photo_dir, render_filename))

    scene_json="/home/paper/Desktop/meta_100/querry_transforms.json"
    with open(scene_json) as f:
        test_transforms = json.load(f)
    
    camera=get_cameras(chunk)
    cm1=camera[0]
    testnum = len(test_transforms["frames"])
    print("test num:",testnum)
    for  idx in range(testnum):

        frame = test_transforms["frames"][idx]
        pose=frame["transform_matrix"]
        picname = frame["file_path"][9:]
        render = chunk.model.renderImage(pose, cm1.sensor.calibration)
        photo_dir="/home/paper/Desktop/meta_100/meta_render/"
        render.save(os.path.join(photo_dir, picname))
    print("Script finished!")


label = "Scripts/Render free poses"
Metashape.app.addMenuItem(label, render_cameras)
print("To execute this script press {}".format(label))

2. 相机位姿的输入

可参照该问题:render an image of a point cloud seen from a pose, with certain intrinsics

3. Agisoft Photoscan/Mateshape 相机参数XML解读

实际的光心位置为图像 0.5×width / 0.5×height + cx / cy
实际相机旋转平移矩阵为将 transform 中的十六个元素组成4×4矩阵之后取逆

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

metashape-pro python scripts render specified viewpoint 的相关文章

  • Python 的键盘中断不会中止 Rust 函数 (PyO3)

    我有一个使用 PyO3 用 Rust 编写的 Python 库 它涉及一些昂贵的计算 单个函数调用最多需要 10 分钟 从 Python 调用时如何中止执行 Ctrl C 好像只有执行结束后才会处理 所以本质上没什么用 最小可重现示例 Ca
  • Django 管理员在模型编辑时间歇性返回 404

    我们使用 Django Admin 来维护导出到我们的一些站点的一些数据 有时 当单击标准更改列表视图来获取模型编辑表单而不是路由到正确的页面时 我们会得到 Django 404 页面 模板 它是偶尔发生的 我们可以通过重新加载三次来重现它
  • SQLAlchemy 通过关联对象声明式多对多自连接

    我有一个用户表和一个朋友表 它将用户映射到其他用户 因为每个用户可以有很多朋友 这个关系显然是对称的 如果用户A是用户B的朋友 那么用户B也是用户A的朋友 我只存储这个关系一次 除了两个用户 ID 之外 Friends 表还有其他字段 因此
  • 将 saxon 与 python 结合使用

    我需要使用 python 处理 XSLT 目前我正在使用仅支持 XSLT 1 的 lxml 现在我需要处理 XSLT 2 有没有办法将 saxon XSLT 处理器与 python 一起使用 有两种可能的方法 设置一个 HTTP 服务 接受
  • 通过最小元素比较对 5 个元素进行排序

    我必须在 python 中使用元素之间的最小比较次数来建模对 5 个元素的列表进行排序的执行计划 除此之外 复杂性是无关紧要的 结果是一个对的列表 表示在另一时间对列表进行排序所需的比较 我知道有一种算法可以通过 7 次比较 总是在元素之间
  • Django:按钮链接

    我是一名 Django 新手用户 尝试创建一个按钮 单击该按钮会链接到我网站中的另一个页面 我尝试了一些不同的例子 但似乎没有一个对我有用 举个例子 为什么这不起作用
  • Flask 会话变量

    我正在用 Flask 编写一个小型网络应用程序 当两个用户 在同一网络下 尝试使用应用程序时 我遇到会话变量问题 这是代码 import os from flask import Flask request render template
  • 基于代理的模拟:性能问题:Python vs NetLogo & Repast

    我正在 Python 3 中复制一小段 Sugarscape 代理模拟模型 我发现我的代码的性能比 NetLogo 慢约 3 倍 这可能是我的代码的问题 还是Python的固有限制 显然 这只是代码的一个片段 但 Python 却花费了三分
  • Python pickle:腌制对象不等于源对象

    我认为这是预期的行为 但想检查一下 也许找出原因 因为我所做的研究结果是空白 我有一个函数可以提取数据 创建自定义类的新实例 然后将其附加到列表中 该类仅包含变量 然后 我使用协议 2 作为二进制文件将该列表腌制到文件中 稍后我重新运行脚本
  • 如何加速Python中的N维区间树?

    考虑以下问题 给定一组n间隔和一组m浮点数 对于每个浮点数 确定包含该浮点数的区间子集 这个问题已经通过构建一个解决区间树 https en wikipedia org wiki Interval tree 或称为范围树或线段树 已经针对一
  • 绘制方程

    我正在尝试创建一个函数 它将绘制我告诉它的任何公式 import numpy as np import matplotlib pyplot as plt def graph formula x range x np array x rang
  • 添加不同形状的 numpy 数组

    我想添加两个不同形状的 numpy 数组 但不进行广播 而是将 缺失 值视为零 可能最简单的例子是 1 2 3 2 gt 3 2 3 or 1 2 3 2 1 gt 3 2 3 1 0 0 我事先不知道形状 我正在弄乱每个 np shape
  • 如何使用Python创建历史时间线

    So I ve seen a few answers on here that helped a bit but my dataset is larger than the ones that have been answered prev
  • Pandas:merge_asof() 对多行求和/不重复

    我正在处理两个数据集 每个数据集具有不同的关联日期 我想合并它们 但因为日期不完全匹配 我相信merge asof 是最好的方法 然而 有两件事发生merge asof 不理想的 数字重复 数字丢失 以下代码是一个示例 df a pd Da
  • 如何在Python中对类别进行加权随机抽样

    给定一个元组列表 其中每个元组都包含一个概率和一个项目 我想根据其概率对项目进行采样 例如 给出列表 3 a 4 b 3 c 我想在 40 的时间内对 b 进行采样 在 python 中执行此操作的规范方法是什么 我查看了 random 模
  • Fabric env.roledefs 未按预期运行

    On the 面料网站 http docs fabfile org en 1 10 usage execution html 给出这个例子 from fabric api import env env roledefs web hosts
  • 如何在seaborn displot中使用hist_kws

    我想在同一图中用不同的颜色绘制直方图和 kde 线 我想为直方图设置绿色 为 kde 线设置蓝色 我设法弄清楚使用 line kws 来更改 kde 线条颜色 但 hist kws 不适用于显示 我尝试过使用 histplot 但我无法为
  • 对年龄列进行分组/分类

    我有一个数据框说df有一个柱子 Ages gt gt gt df Age 0 22 1 38 2 26 3 35 4 35 5 1 6 54 我想对这个年龄段进行分组并创建一个像这样的新专栏 If age gt 0 age lt 2 the
  • Python:如何将列表列表的元素转换为无向图?

    我有一个程序 可以检索 PubMed 出版物列表 并希望构建一个共同作者图 这意味着对于每篇文章 我想将每个作者 如果尚未存在 添加为顶点 并添加无向边 或增加每个合著者之间的权重 我设法编写了第一个程序 该程序检索每个出版物的作者列表 并
  • 发送用户注册密码,django-allauth

    我在 django 应用程序上使用 django alluth 进行身份验证 注册 我需要创建一个自定义注册表单 其中只有一个字段 电子邮件 密码将在服务器上生成 这是我创建的表格 from django import forms from

随机推荐

  • ## 在gazebo中禁用odom的tf坐标变换

    在gazebo中禁用odom的tf坐标变换 见链接https answers ros org question 229722 how to stop gazebo publishing tf
  • ROS 运行建图和导航节点时出现的警告

    ROS 运行建图和导航节点时出现的警告 出现 The goal sent to the global planner is off the global costmap Planning will always fail to this g
  • docker内使用nvidia-gpu运行rviz和gazebo

    1 本机装好docker后 xff0c 从阿里云拉取自己的image 由于本机有nvidia的显卡 xff0c 导致不能在docker内部运行rviz和gazebo可视化软件 之前的image是在cpu环境下制作的 xff0c 所以现在需要
  • 解决加载diff_drive_controller/DiffDriveController的问题

    1 出现的现象 xff1a Robot description couldn 39 t be retrieved from param server Failed to initialize the controller 2 参考资料 xf
  • 不同的docker主机,网线直连,ros分布式通讯设置

    1 参考跨宿主机 如何实现 Docker 容器的通讯 xff1f xff08 Docker Swarm xff09 大鹏的世界的博客 CSDN博客 docker swarm 跨主机容器通信 感谢大佬 2 两台主机能够相互ping 通 3 在
  • ros 已经发布topic 但是却echo不出来

    因为是用的docker镜像 xff0c 采用多机通信的方式 xff0c 一台电脑跑仿真 xff0c 一台电脑跑算法 当进入docker的时候 xff0c docker进入了一个莫名其妙的host也就是root 64 jszn arm pla
  • 英文词组

    bonehead 笨蛋 buddy 密友 blow over 经历 i give up you won off duty 下班 20080506 每天一起练口语 健康话题 Health I 39 m going to the hospita
  • openrave 生成ikfast 第一步遇到的问题

    1 rosrun collada urdf urdf to collada jszn robot description with sensor gazebo xacro jszn robot description with sensor
  • 单视图测量 (2D变换、影消点线、单视图重构)

    写在前面 xff1a 本篇Blog仅作为学习笔记 xff0c 学习内容来自于北邮CV XUEBA团队的三维重建 精简版 xff0c 鲁鹏 课程 回顾经典2D变换 等距变换 旋转矩阵 Rotate Matrix 的性质分析 证明 xff1a
  • libpng warning: iCCP: known incorrect sRGB profile 报错

    libpng warning iCCP known incorrect sRGB profile 警告 xff0c 问题解决 目录 libpng warning iCCP known incorrect sRGB profile 警告 xf
  • 卷积神经网络核心概念再复习+Pytorch一维卷积的实现

    蓝色 紫色 红色 深度学习之卷积神经网络 基本的图像分类模型架构 卷积层 xff1a 用来提取图像的底层特征 池化层 xff1a 防止过拟合 xff0c 减小数据维度 全连接层 xff1a 汇总卷积层和池化层得到的底层特征和信息 xff0c
  • Ubuntu20.04安装过程 【磁盘分区】

    前言 首先 要了解你的电脑配置 xff08 我实验室的如下 xff09 xff1a 整个安装Ubuntu系统的过程大致如下 xff1a 华硕主板按F2 F8 xff0c 这个可以百度 也可以重新启动 xff0c 在你的第一个界面上能看到 按
  • KLT光流跟踪特征点对

    前言 本篇所述为KLT光流跟踪两个视频中匹配特征点对的具体实现 61 gt 源码见Github openCV版本 xff1a 4 5 5 函数详解 1 特征提取 1 SIFT特征提取调用方式 sift span class token op
  • Ubuntu 20.04桌面文件夹图标消失及文件系统无法打开

    前言 之前遇到过服务器上桌面图标突然消失的情况 在更换系统语言之后 xff0c 桌面出现过一次这种情况 xff0c 经过重启之后就恢复了 再后来又莫名其妙出现了这么个问题 xff0c 最开始搜索的解决方案是 让你打开任务管理器 gnome
  • 【论文笔记】Deblur-NeRF == HKU ==CVPR‘2022

    蓝色 紫色 红色 Deblur NeRF Neural Radiance Fields from Blurry Images Author From Abstract 神经辐射场 xff08 NeRF xff09 由于其显著的合成质量 xf
  • Linux安装 metashape

    1 下载软件 3D三维建模软件 Agisoft Metashape Pro 2 安装 span class token comment 进入root模式 xff0c 如果之前没有设置过密码 span span class token fun
  • Information Collection

    港澳新地区 香港理工大学 杨波 助理教授 vLAR实验室 欧洲 ETH Z rich Marc Pollefeys Computer Vision and Geometry Group TU Delft 3D geoinformation
  • 804半导体物理 中科院半导体所考研经验

    本人2021考研 xff0c 半导体研究所 xff0c 物理电子学 xff0c 数一英语一 xff0c 专业课804半导体 自己之前在备考的时候就感觉专业课的资料和备考经验比较少 xff0c 现在就写一些自己总结的经验 xff0c 放一些资
  • 一些cmake error fixed

    建完虚拟环境后 运行 pip install 出现报错 xff0c 显示svox2安装出错 xff0c 然后开始进入到svox2中进行手动编译和安装 1 cmake svox2 csrc pybind11找不到 conda span cla
  • metashape-pro python scripts render specified viewpoint

    官方python脚本使用文档 主函数 xff1a render 61 chunk model renderImage 1 实现特定视角的渲染需要通过脚本方式进行 xff0c 原本的metashape pro中是没有这个功能的 首先在meta