A simple Python -> WebGL Bridge. Batteries not included.
Send raw image data to a browser window from python over websockets.
You can use this to live debug your python code and build visualisations without having to write out frames to a file or video.
Install
pip install py-viewport
Run the examples
python examples/00_hello_world.py
Start the server as a standalone process
py-viewport start
Render an image to the viewport
from viewport import Viewport
async with Viewport() as v:
img = np.zeros([100,100,3], dtype=np.uint8)
await v.draw(img.tobytes())
Install system dependencies
brew install protobuf
Activate the python environment
pipenv install
pipenv shell
Install frontend dependencies and start the dev server
cd frontend/
npm install
Compile protobuf bindings
cd src/
./compile_protos.sh
Install the python package in editable mode
pip install -e .
Run the python server with live reload
py-viewport start --reload
Start the frontend dev server with live reload
cd frontend/
npm run start