详解python polyscope库的安装和例程


Posted in Python onNovember 13, 2020

安装就可以在环境配置好的情况下使用pip安装:

pip install polyscope

如果提示找不到库文件,no moudle的话可以试着把安装下来的polyscope文件夹放在和想要运行的py文件的同一目录下。
而我们安装下来的polyscope文件夹在哪里呢?它们应该位于安装目录中的"Lib/site-packages"中,我的如下图所示:

详解python polyscope库的安装和例程

但是装好之后我们运行一个网上的例程:

import polyscope as ps

# Initialize polyscope
ps.init()

### Register a point cloud
# `my_points` is a Nx3 numpy array
ps.register_point_cloud("my points", my_points)

### Register a mesh
# `verts` is a Nx3 numpy array of vertex positions
# `faces` is a Fx3 array of indices, or a nested list
ps.register_surface_mesh("my mesh", verts, faces, smooth_shade=True)

# Add a scalar function and a vector function defined on the mesh
# vertex_scalar is a length V numpy array of values
# face_vectors is an Fx3 array of vectors per face
ps.get_surface_mesh("my mesh").add_scalar_quantity("my_scalar", 
    vertex_scalar, defined_on='vertices', cmap='blues')
ps.get_surface_mesh("my mesh").add_vector_quantity("my_vector", 
    face_vectors, defined_on='faces', color=(0.2, 0.5, 0.5))

# View the point cloud and mesh we just registered in the 3D UI
ps.show()

还是有错误,找不到polyscope_bindings,我的解决办法是在这个目录下面还应该有一个这个文件:

详解python polyscope库的安装和例程

把他的名字改成polyscope_bindings.pyd就可以解决,库就可以跑通了。但是原例程因为没有给数组所有还有逻辑错误,随便给几个就可以运行了:

import polyscope as ps
import numpy as np

# Initialize polyscope
ps.init()

### Register a point cloud
# `my_points` is a Nx3 numpy array
my_points=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])
ps.register_point_cloud("my points", my_points)

### Register a mesh
# `verts` is a Nx3 numpy array of vertex positions
# `faces` is a Fx3 array of indices, or a nested list
verts=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])
faces=np.array([[1,1,1],[1,2,3],[1,2,4],[2,4,3],[2,2,2]])
ps.register_surface_mesh("my mesh", verts, faces, smooth_shade=True)

# Add a scalar function and a vector function defined on the mesh
# vertex_scalar is a length V numpy array of values
# face_vectors is an Fx3 array of vectors per face
vertex_scalar = np.array([1,2,3,4,5])
face_vectors=np.array([[1,1,1],[1,2,3],[1,2,4],[2,5,3],[2,2,2]])
ps.get_surface_mesh("my mesh").add_scalar_quantity("my_scalar", 
    vertex_scalar, defined_on='vertices', cmap='blues')
ps.get_surface_mesh("my mesh").add_vector_quantity("my_vector", 
    face_vectors, defined_on='faces', color=(0.2, 0.5, 0.5))

# View the point cloud and mesh we just registered in the 3D UI
ps.show()

这就可以成功使用了

详解python polyscope库的安装和例程

到此这篇关于python polyscope库的安装和例程的文章就介绍到这了,更多相关python polyscope库内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Python 相关文章推荐
python中合并两个文本文件并按照姓名首字母排序的例子
Apr 25 Python
Python标准库之循环器(itertools)介绍
Nov 25 Python
python嵌套函数使用外部函数变量的方法(Python2和Python3)
Jan 31 Python
浅谈五大Python Web框架
Mar 20 Python
浅谈python之新式类
Aug 12 Python
Python直接赋值、浅拷贝与深度拷贝实例分析
Jun 18 Python
解决python中导入win32com.client出错的问题
Jul 26 Python
解决django无法访问本地static文件(js,css,img)网页里js,cs都加载不了
Apr 07 Python
解决matplotlib.pyplot在Jupyter notebook中不显示图像问题
Apr 22 Python
Pytorch 卷积中的 Input Shape用法
Jun 29 Python
scrapy结合selenium解析动态页面的实现
Sep 28 Python
Python+OpenCV检测灯光亮点的实现方法
Nov 02 Python
python中的测试框架
Nov 13 #Python
Python加载数据的5种不同方式(收藏)
Nov 13 #Python
使用Python解析Chrome浏览器书签的示例
Nov 13 #Python
python 实现围棋游戏(纯tkinter gui)
Nov 13 #Python
python3从网络摄像机解析mjpeg http流的示例
Nov 13 #Python
python+flask编写一个简单的登录接口
Nov 13 #Python
jupyter notebook快速入门及使用详解
Nov 13 #Python
You might like
超人钢铁侠联手合作?美漫作家呼吁DC漫威合作联动以抵抗疫情
2020/04/09 欧美动漫
php解析xml方法实例详解
2015/05/12 PHP
php中switch语句用法详解
2015/08/17 PHP
js综合应用实例简单的表格统计
2013/09/03 Javascript
js获得当前时区夏令时发生和终止的时间代码
2014/02/23 Javascript
对 jQuery 中 data 方法的误解分析
2014/06/18 Javascript
js键盘事件的keyCode
2014/07/29 Javascript
jQuery 判断图片是否加载完成方法汇总
2015/08/10 Javascript
基于jquery插件编写countdown计时器
2016/06/12 Javascript
bootstrap模态框跳转到当前模板页面 框消失了而背景存在问题的解决方法
2020/11/30 Javascript
jQuery is not defined 错误原因与解决方法小结
2017/03/19 Javascript
微信小程序页面滑动屏幕加载数据效果
2020/11/16 Javascript
详解使用vue-cli脚手架初始化Vue项目下的项目结构
2018/03/08 Javascript
vue实现树形菜单效果
2018/03/19 Javascript
JS点击动态添加标签、删除指定标签的代码
2018/04/18 Javascript
js中事件对象和事件委托的介绍
2019/01/21 Javascript
JS实现可控制的进度条
2020/03/25 Javascript
JavaScript实现动态生成表格
2020/08/02 Javascript
swiper自定义分页器的样式
2020/09/14 Javascript
微信小程序实现加入购物车滑动轨迹
2020/11/18 Javascript
Python3交互式shell ipython3安装及使用详解
2020/07/11 Python
python爬虫爬取网页数据并解析数据
2020/09/18 Python
Python numpy大矩阵运算内存不足如何解决
2020/11/19 Python
Python Pygame实现俄罗斯方块
2021/02/19 Python
无需JS和jQuery代码实现CSS3鼠标浮动放大图片
2016/11/21 HTML / CSS
html5适合移动应用开发的12大特性
2014/03/19 HTML / CSS
社区端午节活动方案
2014/01/28 职场文书
《中国的气候》教学反思
2014/02/23 职场文书
中考标语大全
2014/06/05 职场文书
公益广告标语
2014/06/19 职场文书
2014老师三严三实对照检查材料思想汇报
2014/09/18 职场文书
物价局领导班子四风问题整改措施
2014/10/26 职场文书
2014年高数考试作弊检讨书
2014/12/14 职场文书
学校开除通知书
2015/04/25 职场文书
Python数据分析之pandas读取数据
2021/06/02 Python
asyncio异步编程之Task对象详解
2022/03/13 Python