Skip to main content

Webブラウザ上に点群を描画する python ライブラリ

Project description

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.pcdlib/以下に生成されています。

以下のようにするとテスト用のモードでクライアントページを配信することができます。

$ make serve

上のようにしてクライアントを配信するサーバを起動した後、ブラウザでクライアントを開きます(大抵の場合自動で開かれます)。 別のターミナルでライブラリ側を起動するとクライアント側に接続されます。

$ cd lib
$ poetry run python -m cumo sample_data.pcd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cumo-0.34.1.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cumo-0.34.1-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file cumo-0.34.1.tar.gz.

File metadata

  • Download URL: cumo-0.34.1.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cumo-0.34.1.tar.gz
Algorithm Hash digest
SHA256 8052accd2cae4bf2ed124714d14742ca9ed3c9f3f546faa969264bc0b5263e0d
MD5 f36496490b6104d5cda6e4ac638c2d09
BLAKE2b-256 82b60eb69dec855fc48e0895bab4b94373dc12d993c4e231cb5e679adb93f096

See more details on using hashes here.

Provenance

The following attestation bundles were made for cumo-0.34.1.tar.gz:

Publisher: deploy.yml on kurusugawa-computer/cumo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cumo-0.34.1-py3-none-any.whl.

File metadata

  • Download URL: cumo-0.34.1-py3-none-any.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cumo-0.34.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac774ab632ef5c19b4758e1c832316ad6b48cd738399b0e787032e31e9b3f6fa
MD5 ef49a1bbd8f5b3e917b629c048d56aab
BLAKE2b-256 e48b12b4d7091266e773534807aaf8ecb99655b55b7e95ec6b7fb4f50a95a684

See more details on using hashes here.

Provenance

The following attestation bundles were made for cumo-0.34.1-py3-none-any.whl:

Publisher: deploy.yml on kurusugawa-computer/cumo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page