详解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利用不到一百行代码实现一个小siri
Mar 02 Python
Python 列表(List) 的三种遍历方法实例 详解
Apr 15 Python
Python基础教程之浅拷贝和深拷贝实例详解
Jul 15 Python
对python中assert、isinstance的用法详解
Nov 27 Python
关于numpy中eye和identity的区别详解
Nov 29 Python
python3用urllib抓取贴吧邮箱和QQ实例
Mar 10 Python
如何搭建pytorch环境的方法步骤
May 06 Python
Python3 socket即时通讯脚本实现代码实例(threading多线程)
Jun 01 Python
Python包资源下载路径报404解决方案
Nov 05 Python
浅析Python打包时包含静态文件处理方法
Jan 15 Python
Pycharm 设置默认解释器路径和编码格式的操作
Feb 05 Python
Python趣味挑战之用pygame实现简单的金币旋转效果
May 31 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实现ASCII码与字符串相互转换的方法
2017/04/29 PHP
laravel框架select2多选插件初始化默认选中项操作示例
2020/02/18 PHP
Mootools 1.2教程 Fx.Morph、Fx选项和Fx事件
2009/09/15 Javascript
juqery 学习之三 选择器 简单 内容
2010/11/25 Javascript
NODE.JS加密模块CRYPTO常用方法介绍
2014/06/05 Javascript
Jquery设置attr的disabled属性控制某行显示或者隐藏
2014/09/25 Javascript
基于javascript实现判断移动终端浏览器版本信息
2014/12/09 Javascript
JS中完美兼容各大浏览器的scrolltop方法
2015/04/17 Javascript
JS中字符串trim()使用示例
2015/05/26 Javascript
C++中的string类的用法小结
2015/08/07 Javascript
浅谈node.js中async异步编程
2015/10/22 Javascript
教大家轻松制作Bootstrap漂亮表格(table)
2016/12/13 Javascript
解决webpack -p压缩打包react报语法错误的方法
2017/07/03 Javascript
讲解vue-router之什么是嵌套路由
2018/05/28 Javascript
JavaScript日期工具类DateUtils定义与用法示例
2018/09/03 Javascript
layDate插件设置开始和结束时间
2018/11/15 Javascript
Django+Vue实现WebSocket连接的示例代码
2019/05/28 Javascript
JS+HTML实现自定义上传图片按钮并显示图片功能的方法分析
2020/02/12 Javascript
Sanic框架流式传输操作示例
2018/07/18 Python
python 利用文件锁单例执行脚本的方法
2019/02/19 Python
使用Python创建简单的HTTP服务器的方法步骤
2019/04/26 Python
浅谈OpenCV中的新函数connectedComponentsWithStats用法
2020/07/05 Python
英国领先的NHS批准的在线药店:Pharmacy2U
2017/01/06 全球购物
爱尔兰电子产品购物网站:Komplett.ie
2018/04/04 全球购物
美国马匹用品和马钉购物网站:State Line Tack
2018/08/05 全球购物
通信工程毕业生求职信
2013/11/16 职场文书
机械制造与自动化应届生求职信
2013/11/16 职场文书
2014年银行员工年终自我评价
2014/09/19 职场文书
认错检讨书
2014/10/02 职场文书
银行自荐信范文
2015/03/25 职场文书
民事二审代理词
2015/05/25 职场文书
家访教师心得体会
2016/01/23 职场文书
诺贝尔奖获得者名言100句:句句启人心智,值永久收藏
2019/08/09 职场文书
详解nodejs内置模块
2021/05/06 NodeJs
配置Kubernetes外网访问集群
2022/03/31 Servers
pytorch分类模型绘制混淆矩阵以及可视化详解
2022/04/07 Python