详解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检查字符串是否是正确ISBN的方法
Jul 11 Python
python实现爬取百度图片的方法示例
Jul 06 Python
简单了解python 邮件模块的使用方法
Jul 24 Python
python定间隔取点(np.linspace)的实现
Nov 27 Python
python中利用matplotlib读取灰度图的例子
Dec 07 Python
Python Tensor FLow简单使用方法实例详解
Jan 14 Python
Pycharm debug调试时带参数过程解析
Feb 03 Python
python高阶函数map()和reduce()实例解析
Mar 16 Python
Python用5行代码实现批量抠图的示例代码
Apr 14 Python
什么是python的列表推导式
May 26 Python
Flask中sqlalchemy模块的实例用法
Aug 02 Python
Python3接口性能测试实例代码
Jun 20 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
精通php的十大要点(上)
2009/02/04 PHP
PHP制作万年历
2015/01/07 PHP
PHP中仿制 ecshop验证码实例
2017/01/06 PHP
PHP实现给定一列字符,生成指定长度的所有可能组合示例
2019/06/22 PHP
js 加载并解析XML字符串的代码
2009/12/13 Javascript
javascript 程序库的比较(一)之DOM功能
2010/04/07 Javascript
jquery插件实现鼠标经过图片右侧显示大图的效果(类似淘宝)
2013/02/04 Javascript
js日期联动示例
2014/05/02 Javascript
一个支付页面DEMO附截图
2014/07/22 Javascript
JS实现网页右侧带动画效果的伸缩窗口代码
2015/10/29 Javascript
jQuery查看选中对象HTML代码的方法
2016/06/17 Javascript
Node.js数据库操作之查询MySQL数据库(二)
2017/03/04 Javascript
Vue插槽原理与用法详解
2019/03/05 Javascript
Node配合WebSocket做多文件下载以及进度回传
2019/11/07 Javascript
零基础写python爬虫之爬虫编写全记录
2014/11/06 Python
深入解析Python中的线程同步方法
2016/06/14 Python
Pyinstaller打包.py生成.exe的方法和报错总结
2019/04/02 Python
python如何实现异步调用函数执行
2019/07/08 Python
Jupyter Notebook 文件默认目录的查看以及更改步骤
2020/04/14 Python
Python getsizeof()和getsize()区分详解
2020/11/20 Python
详解pandas中利用DataFrame对象的.loc[]、.iloc[]方法抽取数据
2020/12/13 Python
非常漂亮的CSS3百叶窗焦点图动画
2016/02/24 HTML / CSS
Dyson戴森波兰官网:Dyson.pl
2019/08/05 全球购物
大学生就业推荐信范文
2013/11/29 职场文书
八一建军节部队活动方案
2014/02/04 职场文书
建设单位项目负责人任命书
2014/06/06 职场文书
家长会标语
2014/06/24 职场文书
社团活动总结书
2014/06/27 职场文书
乡镇组织委员个人整改措施
2014/09/16 职场文书
搞笑的爱情检讨书
2014/10/01 职场文书
2014年化验员工作总结
2014/11/18 职场文书
向女朋友道歉的话
2015/01/20 职场文书
2015年幼师工作总结
2015/04/28 职场文书
高三英语教学反思
2016/03/03 职场文书
如何利用js在两个html窗口间通信
2021/04/27 Javascript
CSS 实现Chrome标签栏的技巧
2021/08/04 HTML / CSS