cumo
cumoは、Pythonから3D点群をブラウザ上で表示するためのライブラリです。
インストール
$ pip install cumo
ドキュメント
sphinxでドキュメントの生成が可能です。
devcontainer環境を使用することで、ビルド環境を構築することができます。
その中で以下のようにすると、lib/docs/以下にドキュメントが生成されます。
$ make docs
また、serve-docsターゲットを実行するとPythonのサーバーが起動し、http://localhost:8000でドキュメントを閲覧できます。
$ make serve-docs
使用例
lib/cumo/__main__.pyは3面図を撮る例です。
lib/以下に適当なPCDファイル(以下の例ではsample_data.pcd)を用意して、以下のようにするとpcdファイルを閲覧できます。
$ cd lib
$ poetry run python -m cumo sample_data.pcd
open: http://127.0.0.1:8082
setup...
resize window and press custom control button "start"
saved: screenshot_x.png
saved: screenshot_y.png
saved: screenshot_z.png
REPLでの使用も可能です。
$ poetry run python
Python 3.8.7 (default, Apr 9 2022, 21:34:33)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cumo import PointCloudViewer
>>> viewer = PointCloudViewer()
>>> viewer.start()
>>> # open localhost:8082 on your browser
>>> with open("sample_data.pcd", "rb") as f:
>>> b = f.read()
>>> viewer.send_pointcloud_pcd(b)
cumo開発者向け
大まかな構成
cumoは以下のように、大まかに2つの要素からなります。
lib/: Pythonライブラリ。PointCloudViewerクラスを提供する。クライアントのHTMLを配信し、クライアントとWebSocket通信を行う。client/: クライアントページ。ライブラリとWebSocket通信を行い、ライブラリからの操作を受け付ける。
これら2つの通信はWebSocketを使用しています。 通信データはProtocol Buffersにより定義されており、それぞれで使われている言語のライブラリが自動で生成されます。
protobuf/server.proto: ライブラリからクライアントへ送信されるデータprotobuf/client.proto: クライアントからライブラリへ送信されるデータ
ビルド
devcontainerを使用することで、ビルド環境を構築することができます。
devcontainer環境に入り、下のようにするとlib/dist/以下にtar.gzとwhlファイルが生成されます。
クライアントのHTML等はライブラリに含まれ、tar.gzやwhlファイルの中に格納されます。
$ make
テスト
make (またはmake all)を実行していれば、サンプル用のpcdファイルsample_data.pcdがlib/以下に生成されています。
以下のようにするとテスト用のモードでクライアントページを配信することができます。
$ make serve
上のようにしてクライアントを配信するサーバを起動した後、ブラウザでクライアントを開きます(大抵の場合自動で開かれます)。 別のターミナルでライブラリ側を起動するとクライアント側に接続されます。
$ cd lib
$ poetry run python -m cumo sample_data.pcd
Metadata
Release files for cumo 0.34.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cumo-0.34.1.tar.gz | 1.3 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cumo-0.34.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.5 MB
Release files / cumo-0.34.1.tar.gz
| Download URL | cumo-0.34.1.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8052accd2cae4bf2ed124714d14742ca9ed3c9f3f546faa969264bc0b5263e0d
|
|
BLAKE2b-256 checksum How to use checksums |
82b60eb69dec855fc48e0895bab4b94373dc12d993c4e231cb5e679adb93f096
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2024.
Transparency logRelease files / cumo-0.34.1-py3-none-any.whl
| Download URL | cumo-0.34.1-py3-none-any.whl |
|---|---|
| Size | 1.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac774ab632ef5c19b4758e1c832316ad6b48cd738399b0e787032e31e9b3f6fa
|
|
BLAKE2b-256 checksum How to use checksums |
e48b12b4d7091266e773534807aaf8ecb99655b55b7e95ec6b7fb4f50a95a684
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2024.
Transparency log