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 的相关文章

随机推荐

  • ## 在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