Vis: Asynchronous 3D Visualization Tool

Related tags

Graphics Vis
Overview

English | 简体中文

Vis: Asynchronous 3D Visualization Tool

Vis 是一款交互式异步3D可视化工具,旨在让3D视觉和机器人应用开发更简单。

其核心功能包括:

  • 图形绘制

  • 3D模型文件导入

  • 多种交互工具

  • Gzimo

安装

  • Linux

  # 安装必要的依赖项
  sudo apt-get install build-essential python3-dev cmake git
  
  # 安装libopenscenegraph
  sudo apt install libopenscenegraph-3.4-dev
  # 如果找不到以上版本,可以安装默认版本
  sudo apt install libopenscenegraph-dev
  
  # 下载Vis源码
  git clone https://github.com/rvbust/Vis.git
  # 编译
  mkdir build
  cd build
  cmake ..
  sudo make install -j
  
  # 如果想要使用Vis的Python API,需要在文件.bashrc中加入下列指令:
  export PYTHONPATH="$PYTHONPATH:/opt/RVBUST/Vis/Python"
  • Windows

    安装Vis之前,请确定已经安装OSG。

    安装OSG
    1. 下载OSG安装包

      OpenSceneGraph-3.4.1点击下载

    2. 解压文件和设置路径

      解压7z文件和编辑系统环境变量 Add OSG_BIN_DIR to path

      OSG_ROOT = C:\OpenSceneGraph-3.4.1-VC2017-64-Release
      OSG_BIN_DIR = %OSG_ROOT%\bin
      OSG_INCLUDE_DIR = %OSG_ROOT%\include
      OSG_LIB_DIR = %OSG_ROOT%\lib
    3. 重启系统

    安装 PyVis
    python3 Setup.py install

功能说明

  • 窗口设置

  1. 在不同窗口共享相同场景.
# 共享场景表示两个视图会显示相同的场景。
from RVBUST import Vis 
v1 = Vis.View("View1", shared = True) #< Shared表示是否共享场景.
v2 = Vis.View("View2", shared = True) 

v1.Box((0,0,0), (1,1,1))
v2.Box((2,2,2), (1,1,1))
  1. 不共享场景
# 不共享场景表示两个视图会显示各自的场景。
v1 = Vis.View("View1", shared = False) #< Shared表示是否共享场景.
v2 = Vis.View("View2", shared = False)

v1.Box((0,0,0), (1,1,1))
v2.Box((2,2,2), (1,1,1))

在 Vis 中,只有一个共享场景。 因此,如果您打开共享,所有场景都将添加到同一个视图中。这样做的优点是一个场景可以有多个视图。 如果你在不共享场景的情况下创建视图,它将是唯一可以在其场景中使用的视图。

  • 图形绘制

名称 描述 image
Axes 通过输入位置,旋转姿态来绘制坐标系,可以设置坐标系轴的长度和大小,其中长度单位为米,大小尺寸单位为像素。
Point 输入一组点数据来绘制一个点或是一组点,每3个值来表达点的位置,大小尺寸单位为像素。
Line 绘制一条线段或是一组线段,其中每6个值表达一条线段,分别为线段的起点和终点位置。
Box 通过输入中心位置和尺寸来绘制一个盒子。
Sphere 通过输入中心位置和半径来绘制一个球。
Cone 通过输入形心位置,半径和高度来绘制一个圆锥。
Cylinder 通过输入中心位置,半径和高度绘制一个圆柱。
Arrow 通过输入尾部位置,头部位置和半径绘制一个箭头.
Mesh 通过输入3角面片顶点位置和3角面片索引来绘制一个Mesh.
Plane 绘制一个平面。

需要注意的是,Vis 中使用的单位都是国际标准单位制 SI,也即长度为米(m),角度单位为弧度(rad);此外,对于姿态描述,Vis中采用的是四元数形式,其中四元数的实部在最后一位,也即 (ox, oy, oz, ow) 格式。

  • 模型导入

Vis 支持常见 3D 模型文件格式,如STL,DAE,3DS等等。 Vis 暂时不支持导出模型文件。

from RVBUST import Vis
v = Vis.View("Test")
hs = v.Load(["Models/Visual/BaseLink.stl","Models/Visual/Link1.stl","Models/Visual/Link2.stl",
"Models/Visual/Link3.stl","Models/Visual/Link4.stl","Models/Visual/Link5.stl","Models/Visual/Link6.stl"],
[[0.0,0,0],[0, 0, 0],[0.05, 0, 0.33],[0.05, 0, 0.66],[0.05, 0, 0.695],[0.385, 0, 0.695],[0.385, 0, 0.615]],
[[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0,0,0,1],[0, 0.707108, 0, 0.707105],[0, 0.707108, 0, 0.707105]])

  • 交互工具

Vis提供多种交互工具。

  1. 选择工具
  • IntersectorMode_Polytope

在 IntersectorMode_Polytope 模式,可以通过左键点击场景的物体,并高亮显示选中的物体。(能选择点和线段,但是不能获取到选中点的坐标)

v.SetIntersectMode(IntersectorMode_Polytope)
picked_object_handle = v.Picked()

  • IntersectorMode_LineSegment

在 IntersectorMode_LineSegment 模式下,可以通过左键点击场景的物体,并高亮显示选中的物体(不能选择点和线段, 可以获取到选中点的坐标)。还可以通过 Ctrl + 左键点击选择多个物体表面的点,并绘制坐标系。

v.SetInterSectMode(IntersectorMode_LineSegment)
picked_object_handle = v.Picked()
postion_normal = v.PickedPlane()
axes_handles = v.GetPickedPointAxes()
hs = v.MultiPicked()

  • IntersectorMode_Point

在 IntersectorMode_Point 模式下,可以通过左键点击在一组点中选择一个点,并在选中的点的位置绘制坐标系。还可以通过 Ctrl + 左键点击选择多个点,并绘制坐标系。

v.SetIntersectMode(IntersectorMode_Point)
picked_object_handle = v.Picked()
postion_normal = v.PickedPlane()
axes_handles = v.GetPickedPointAxes()
hs = v.MultiPicked()

  • IntersectorMode_Line

在 IntersectorMode_Line 模式下,可以选中用 View.Line 绘制的线段和 View.Axes 绘制的坐标系,选中的线段会变成高亮。还可以通过 Ctrl + 左键点击选择多条线段。

v.SetInterSectMode(IntersectorMode_Line)
picked_object_handle = v.Picked()
hs = v.MultiPicked()
postion_normal = v.PickedPlane()

  1. Gzimo

Gizmo 是一个操作场景中物体的工具,可以通过拖拉改变物体的位置和姿态。

from RVBUST import Vis
v = Vis.View("Test")
box = v.Box([0,0,0],[0.5,0.5,0.5])
axes = v.Axes([0,0,0],[0,0,0,1],1,1)
v.EnableGizmo(box,4)
v.SetGizmoDisplayScale(0.6)
  • 日志功能

Vis可以设置不同日志等级来查看对应的信息,日志等级有info,debug,warn,error:

Vis.SetLogLevel("debug")

使用示例

以下是 Vis 使用的简单案例,在 Vis 窗口中展示给定尺寸的 box,用户可在窗口中对 box 进行移动。

from RVBUST import Vis
from IPython import embed

# 在Vis窗口中展示给定尺寸的box
def ShowBox():
    transparent_box = v.Box([-2, 0, 0], [0.5, 0.5, 0.5], [1, 0, 0, 0.5])
    normal_box = v.Box([0, 2, 0], [0.5, 0.5, 0.5], [1, 0, 0])

# 移动box
def MoveBox():
    transparent_box = v.Box([-2, 0, 0], [0.5, 0.5, 0.5], [1, 0, 0, 0.5])
    v.EnableGizmo(transparent_box, 4)
    v.SetGizmoDisplayScale(2)

def Basic():
    Vis.SetLogLevel("debug")
    axes1 = v.Axes([0, 0, 0], [0, 0, 0, 1], 2, 1)
    ShowBox()
    MoveBox()
    pass

if __name__ == "__main__":
    cfg = Vis.ViewConfig()
    cfg.x = 0
    cfg.y = 40
    cfg.width = 800
    cfg.height = 600
    cfg.name = "Basics"
    v = Vis.View(cfg, False)
    Basic()
    v.Home()
    from IPython.terminal import embed
    ipshell=embed.InteractiveShellEmbed(config=embed.load_default_config())(local_ns=locals())

License

MIT

Comments
  • OBJ file loading with incorrect rotation

    OBJ file loading with incorrect rotation

    Hi dear developpers of rvbust/vis,

    When loading an OBJ model file, I encounter a problem that the loaded coordinate of the model is different from the original coordinate of the model.

    incorrect-rotation original-rotation

    The left picture shows the loaded model by default, with no changing on its position and rotation, while the rotation seems incorrect. Could you please help me figure it out?

    Many thanks!

    opened by dadadadawjb 4
  • PyVis导入问题

    PyVis导入问题

    你们好,我是 Windows 用户,按照 readme 所说执行 python Setup.py install 后,跑如下例子失败。

    from RVBUST import Vis  # No module named 'RVBUST'
    v1 = Vis.View("View1", shared = True)
    

    使用如下代码是 OK 的:

    import PyVis as Vis
    v1 = Vis.View("View1", shared = True)
    
    opened by linuxsand 4
  • Support for pointcloud loading?

    Support for pointcloud loading?

    Hi dear developpers of rvbust/vis,

    Thanks for open-sourcing such a fantastic tool! It helps a lot for our research. May I ask that if it supports loading pointcloud data, or if you are planning to do so? Because many of our research will incorporate point cloud information.

    Best wishes, haoshu

    opened by Fang-Haoshu 3
  • mesh smoothing

    mesh smoothing

    add Mesh smoothing by merge adjacent faces exceeding given crease angle.

    When outlining extruded polygons, only draw a post outline if the angle between the adjoining faces exceeds this value. This has the effect of only outlining corners that are sufficiently “sharp”.

    截图_选择区域_20220419164326

    opened by xiaodaxia-2008 2
  • fix: fix bug on checking if the view window has closed

    fix: fix bug on checking if the view window has closed

    The branch is to resolve the issue that it occurs error prompt when exiting Vis (It only occurs when employing RobotVis). Here is the error prompt in RobotVis: rvis1

    opened by shenxi1994 0
  • 反复创建关闭不共享场景的两个Vis,会导致程序崩溃

    反复创建关闭不共享场景的两个Vis,会导致程序崩溃

    反复创建、关闭不共享场景的Vis,会造成程序崩溃,具体复现场景和错误信息如下:

    复现场景1

    from RVBUST import Vis
    import time
    def TestOnce():
        v1 = Vis.View("abc", shared=False)
        v1.Sphere(center=[0, 0, 0], radius=0.3)
    
        time.sleep(1)
        v1.Close()
        return True
    
    v2 = Vis.View("RobotVis")
    for i in range(100):
        TestOnce()
    

    错误信息:

    double free or corruption (out)
    Aborted
    

    复现场景2

    from RVBUST import Vis
    import time
    
    class Plotter():
        def __init__(self, name, shared=False):
            self.m_view = Vis.View(name, shared)
    
        def PlotSphere(self, radius):
            self.m_view.Sphere(center=[0, 0, 0], radius=radius)
    
        def ClearVis(self):
            self.m_view.Clear()
    
        def CloseVis(self):
            self.m_view.Close()
    
    def TestOnce(shared):
        plotter = Plotter("abc", shared)
        plotter.PlotSphere(radius=0.3)
        time.sleep(1)
        plotter.ClearVis()
        plotter.CloseVis()
        return True
    
    if __name__ == "__main__":
        v2 = Vis.View("RobotVis")
    
        for i in range(100):
            TestOnce(False)
    

    错误信息为:

    [xcb] Unknown sequence number while processing queue
    [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
    [xcb] Aborting, sorry about that.
    python3: ../../src/xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
    Aborted
    

    但是存在以下两种情况,连续运行100次,未发生崩溃:

    1. shared=True;
    2. 不在函数中构造另一个Vis,代码如下:
    from RVBUST import Vis
    import time
    
    v2 = Vis.View("RobotVis")
    for i in range(100):
        v1 = Vis.View("abc", shared=False)
        v1.Sphere(center=[0, 0, 0], radius=0.3)
    
        time.sleep(1)
        v1.Close()
    
    opened by qqfly 1
  • 加载stl模型的大小缩放问题?

    加载stl模型的大小缩放问题?

        Handle Load(const std::string &fname);
        std::vector<Handle> Load(const std::vector<std::string> &fnames);
    
        Handle Load(const std::string &fname, const std::array<float, 3> &pos,
                    const std::array<float, 4> &quat);
        std::vector<Handle> Load(const std::vector<std::string> &fnames,
                                 const std::vector<std::array<float, 3>> &trans,
                                 const std::vector<std::array<float, 4>> &quats);
    

    目前的load的函数未发现有scale类似的参数,请问如何实现加载模型的时候的尺寸缩放问题?

    opened by longwoo 0
Owner
RVBUST
Robust Robotics and Vision for Industrial Applications.
RVBUST
Lightweight and modular C++11 graphics middleware for games and data visualization

Magnum — Lightweight and modular C++11/C++14 graphics middleware for games and data visualization Looking for an open-source library that gives you gr

Vladimír Vondruš 4.3k Dec 30, 2022
RGL - 3D visualization device system for R using OpenGL

RGL - 3D visualization device system for R using OpenGL INTRODUCTION The RGL package is a visualization device system for R, using OpenGL or WebGL as

null 68 Dec 27, 2022
Powerful, easy to use, and portable visualization toolkit for mixed 3D and 2D content

Powerful, easy to use, and portable visualization toolkit for mixed 3D and 2D content

Microsoft 138 Jan 8, 2023
Mandelbrot set visualization in OpenGL

Mandelbort-Set done in OpenGL Steps to build and run ( program tested only on Linux-Ubuntu 18.04,20.04 ) install the necessary packages- glut,glfw,glm

Paleti Krishnasai 2 Feb 13, 2022
HARFANG®3D is an all-in-one 3D visualization library usable in C++, Python, Lua and Go.

HARFANG® 3D engine HARFANG®3D is an all-in-one 3D visualization library usable in C++, Python, Lua and Go. Table of contents About Features Screenshot

HARFANG® 3D 280 Jan 1, 2023
Matplot++: A C++ Graphics Library for Data Visualization 📊🗾

Matplot++ A C++ Graphics Library for Data Visualization Data visualization can help programmers and scientists identify trends in their data and effic

Alan de Freitas 3k Jan 4, 2023
C++14 network/graph visualization library / Qt node editor.

QuickQanava QuickQanava is a C++14 library designed to display graphs and relational content in a Qt/QML application. QuickQanava provide QML componen

null 883 Jan 7, 2023
Alpha Plot is a free application for Scientific Data Analysis and Visualization for Windows, Linux and Mac OS X

Alpha Plot is a free application for Scientific Data Analysis and Visualization for Windows, Linux and Mac OS X (probably BSD also). Web Link Website

Arun Narayanankutty 171 Dec 26, 2022
A C++ commandline for use in servers and chat software. Provides very simple asynchronous input/output.

commandline A C++ commandline for use in servers and terminal chat software. Provides very simple asynchronous input/output. Supports reading and writ

Lion 70 Dec 20, 2022
The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

DirectX Tool Kit for DirectX 11 http://go.microsoft.com/fwlink/?LinkId=248929 Copyright (c) Microsoft Corporation. All rights reserved. January 9, 202

Microsoft 2.2k Jan 3, 2023
CatFrida is a macOS tool for inspecting a running iOS app.

CatFrida CatFrida is a macOS tool for inspecting a running iOS app. Building with frida-swift, CatFrida provide an awesome easy way to dive into an ap

neilwu 105 Dec 6, 2022
Linux/X11 tool for intercepting mouse events and executing commands. Written in Kotlin Native.

XMG XMG (X11 Mouse Grabber) is a Linux/X11 tool for intercepting mouse button press events and triggering actions. It's a way of making use of the ext

Eduardo Fonseca 12 Sep 11, 2021
animation2gltf2 is a command line tool for generating animation glTF 2.0 content.

Generate animation glTF 2.0 content animation2gltf2 is a command line tool for generating animation glTF 2.0 content. A rotation and translation can b

UX3D GmbH 6 Dec 7, 2022
The open-source tool for creating of 3D models

The open-source tool for creating of 3D models

3D geoinformation research group at TU Delft 428 Dec 21, 2022
Monster Mash: New Sketch-Based Modeling and Animation Tool

Monster Mash is a new sketch-based modeling and animation tool that allows you to quickly sketch a character, inflate it into 3D, and promptly animate it. You can perform all interactions in the sketching plane. No 3D manipulation is required.

Google 1.2k Dec 27, 2022
Ksnip is a Qt-based cross-platform screenshot tool that provides many annotation features for your screenshots.

Ksnip is a Qt-based cross-platform screenshot tool that provides many annotation features for your screenshots.

ksnip 1.5k Jan 4, 2023
3D Procedural Terrain Generation Tool in OpenGL/C++

TerraGen3D 3D Procedural Terrain Generation Tool in OpenGL/C++ Give your valuable feedback : https://github.com/Jaysmito101/TerraGen3D/discussions/6 T

Jaysmito Mukherjee 676 Dec 21, 2022
A tool to create funscripts

OpenFunscripter I swear this is a C++ project despite what the statistic on this repo says ?? The project is based on OpenGL, SDL2, ImGui, libmpv, & a

null 35 Dec 31, 2022
Simple console tool to get all the information from DXGI and Direct3D 12 on current system

D3d12info Simple console tool to get all the information from DXGI and Direct3D 12 (D3D12) on current system. Built and tested on Windows 10 64-bit us

Adam Sawicki 40 Dec 8, 2022