vuer 0.0.7rc2__py3-none-any.whl → 0.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vuer might be problematic. Click here for more details.

Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
vuer/base.py CHANGED
@@ -55,10 +55,6 @@ class Server:
55
55
  cors = Proto(help="Enable CORS", default="*")
56
56
  port = Proto(env="PORT", default=8012)
57
57
 
58
- # @abstractmethod
59
- # def __init__(self):
60
- # self.__post_init__()
61
-
62
58
  def __post_init__(self):
63
59
  self.app = web.Application()
64
60
 
@@ -73,10 +69,10 @@ class Server:
73
69
  self.cors_context = aiohttp_cors.setup(self.app, defaults=cors_config)
74
70
 
75
71
  def _route(
76
- self,
77
- path: str,
78
- handler: callable,
79
- method: str = "GET",
72
+ self,
73
+ path: str,
74
+ handler: callable,
75
+ method: str = "GET",
80
76
  ):
81
77
  route = self.app.router.add_resource(path).add_route(method, handler)
82
78
  self.cors_context.add(route)
vuer/schemas.py CHANGED
@@ -4,7 +4,7 @@ import numpy as np
4
4
  import PIL.Image as pil_image
5
5
  from numpy._typing import NDArray
6
6
 
7
- # from msgpack_numpy import pack, packb
7
+ from vuer.serdes import IMAGE_FORMATS
8
8
 
9
9
  element_count = 0
10
10
 
@@ -33,6 +33,7 @@ class Element:
33
33
  Serialize the element to a dictionary for sending over the websocket.
34
34
  :return: Dictionary representing the element.
35
35
  """
36
+
36
37
  # note: only return the non-private attributes, allow bypass.
37
38
  output = {}
38
39
  for k, v in self.__dict__.items():
@@ -212,11 +213,17 @@ class Image(Element):
212
213
  def __init__(
213
214
  self,
214
215
  data: Union[str, np.ndarray, pil_image.Image] = None,
216
+ *,
215
217
  src: str = None,
218
+ format="png",
216
219
  **kwargs,
217
220
  ):
218
221
  if src is not None:
219
222
  assert data is None, "data and src can not be truful at the same time"
223
+ if data is None:
224
+ pass
225
+ elif isinstance(data, list) and len(data) == 0:
226
+ pass
220
227
  else:
221
228
  if isinstance(data, pil_image.Image):
222
229
  data = data
@@ -224,31 +231,15 @@ class Image(Element):
224
231
  # convert back to image first from base64
225
232
  data = pil_image.open(data)
226
233
  elif isinstance(data, np.ndarray):
227
- data = (data * 255).astype(np.uint8)
234
+ if data.dtype == np.uint8:
235
+ pass
236
+ else:
237
+ data = (data * 255).astype(np.uint8)
228
238
 
229
- src = self.base64(data)
239
+ src = IMAGE_FORMATS[format](data)
230
240
 
231
241
  super().__init__(src=src, **kwargs)
232
242
 
233
- @staticmethod
234
- def base64(image_data):
235
- # if self.data is not None:
236
- from io import BytesIO
237
- import numpy as np
238
- import base64
239
-
240
- with BytesIO() as buf:
241
- # todo: specify PNG vs JPG
242
- if isinstance(image_data, np.ndarray):
243
- pil_image.fromarray(image_data).save(buf, "png")
244
- else:
245
- assert isinstance(image_data, pil_image.Image)
246
- image_data.save(buf, "png")
247
-
248
- return "data:image/png;base64," + base64.b64encode(buf.getvalue()).decode(
249
- "utf-8"
250
- )
251
-
252
243
 
253
244
  class ImageUpload(Element):
254
245
  """
@@ -301,12 +292,15 @@ class DefaultScene(Scene):
301
292
  show_helper=True,
302
293
  **kwargs,
303
294
  ):
304
- super().__init__(
305
- # Ambient Light does not have helper because it is ambient.
306
- AmbientLight(intensity=0.5, key="default_ambient_light"),
295
+ rawChildren = [
296
+ AmbientLight(intensity=1.0, key="default_ambient_light"),
307
297
  DirectionalLight(
308
298
  intensity=1, key="default_directional_light", helper=show_helper
309
299
  ),
300
+ *(rawChildren or []),
301
+ ]
302
+ super().__init__(
303
+ # Ambient Light does not have helper because it is ambient.
310
304
  *children,
311
305
  rawChildren=rawChildren,
312
306
  htmlChildren=htmlChildren,
@@ -474,6 +468,14 @@ class Wireframe(SceneElement):
474
468
  tag = "Wireframe"
475
469
 
476
470
 
471
+ class Splat(SceneElement):
472
+ tag = "Splat"
473
+
474
+
475
+ class LumaSplats(SceneElement):
476
+ tag = "Splats"
477
+
478
+
477
479
  class Pcd(SceneElement):
478
480
  tag = "Pcd"
479
481
 
@@ -482,6 +484,23 @@ class CameraView(SceneElement):
482
484
  tag = "CameraView"
483
485
 
484
486
 
487
+ class SceneBackground(Image, SceneElement):
488
+ """Sets the background of the scene to a static image. Does not work well
489
+ with high frame rates. For displaying movies, use the ImageBackground element.
490
+ """
491
+
492
+ tag = "SceneBackground"
493
+
494
+
495
+ class ImageBackground(Image, SceneElement):
496
+ """Sets the background of the scene to an image, Supports high frame rates.
497
+
498
+ We use a plane that is always facing the camera to display the image.
499
+ """
500
+
501
+ tag = "ImageBackground"
502
+
503
+
485
504
  class Gamepads(SceneElement):
486
505
  tag = "Gamepads"
487
506
 
vuer/serdes.py CHANGED
@@ -1,5 +1,9 @@
1
+ import base64
2
+ from io import BytesIO
1
3
  from typing import Sequence
2
4
 
5
+ from PIL import Image as pil_image
6
+
3
7
 
4
8
  def serializer(data):
5
9
  if hasattr(data, "serialize"):
@@ -35,3 +39,57 @@ def serializer(data):
35
39
  #
36
40
  # return data
37
41
  # # raise NotImplementedError(f"Cannot serialize {data}")
42
+
43
+
44
+ def jpg(image, quality: int = 90):
45
+ """
46
+ base64 encode the image into a string, using JPEG encoding
47
+
48
+ Does not support transparency.
49
+ """
50
+ with BytesIO() as buff:
51
+ rgb_pil = pil_image.fromarray(image)
52
+ rgb_pil.save(buff, format="JPEG", quality=quality)
53
+ return buff.getbuffer().tobytes()
54
+
55
+
56
+ def png(image):
57
+ """
58
+ base64 encode the image into a string, using PNG encoding
59
+ """
60
+ with BytesIO() as buff:
61
+ rgb_pil = pil_image.fromarray(image)
62
+ rgb_pil.save(buff, format="PNG")
63
+ return buff.getbuffer().tobytes()
64
+
65
+
66
+ def b64jpg(image, quality: int = 90):
67
+ """
68
+ base64 encode the image into a string, using JPEG encoding
69
+
70
+ Does not support transparency.
71
+ """
72
+ buff = BytesIO()
73
+ rgb_pil = pil_image.fromarray(image)
74
+ rgb_pil.save(buff, format="JPEG", quality=quality)
75
+ img64 = base64.b64encode(buff.getbuffer().tobytes()).decode("utf-8")
76
+ return "data:image/jpeg;base64," + img64
77
+
78
+
79
+ def b64png(image):
80
+ """
81
+ base64 encode the image into a string, using PNG encoding
82
+ """
83
+ with BytesIO() as buff:
84
+ rgb_pil = pil_image.fromarray(image)
85
+ rgb_pil.save(buff, format="PNG")
86
+ img64 = base64.b64encode(buff.getbuffer().tobytes()).decode("utf-8")
87
+ return "data:image/png;base64," + img64
88
+
89
+
90
+ IMAGE_FORMATS = {
91
+ "jpg": jpg,
92
+ "png": png,
93
+ "b64jpg": b64jpg,
94
+ "b64png": b64png,
95
+ }
vuer/server.py CHANGED
@@ -49,12 +49,12 @@ class Vuer(PrefixProto, Server):
49
49
  name = "vuer"
50
50
  uri = "ws://localhost:8012"
51
51
  # change to vuer.dash.ml
52
- domain = "https://dash.ml/vuer"
52
+ domain = "https://vuer.ai"
53
53
  port = 8012
54
54
  free_port = True
55
55
  static_root = "."
56
56
  queue_len = None
57
- # cors = "https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*"
57
+ cors = "https://vuer.ai,https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*"
58
58
  queries = Proto({}, help="query parameters to pass")
59
59
 
60
60
  WEBSOCKET_MAX_SIZE = 2**28
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: vuer
3
+ Version: 0.0.9
4
+ Home-page: https://github.com/geyang/vuer
5
+ Author: Ge Yang<ge.ike.yang@gmail.com>
6
+ Author-email: ge.ike.yang@gmail.com
7
+ License: MIT
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Programming Language :: Python
10
+ Requires-Python: >=3.8.6
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: aiohttp
14
+ Requires-Dist: aiohttp-cors
15
+ Requires-Dist: killport
16
+ Requires-Dist: params-proto >=2.11.16
17
+ Requires-Dist: pillow
18
+ Requires-Dist: tqdm
19
+ Requires-Dist: msgpack
20
+ Requires-Dist: numpy
21
+ Requires-Dist: termcolor
22
+ Requires-Dist: trimesh
23
+ Requires-Dist: websockets
24
+ Provides-Extra: dev
25
+ Requires-Dist: black ==22.3.0 ; extra == 'dev'
26
+ Requires-Dist: pylint ==2.13.4 ; extra == 'dev'
27
+ Requires-Dist: pytest ==7.1.2 ; extra == 'dev'
28
+
29
+ # Vuer: A modern 3D Visualizer for Robotics and VR
30
+
31
+ Vuer is a 3D visualization tool for robotics and VR applications.
32
+
33
+ ## Installation In A Fresh Conda Environment
34
+
35
+ Setup the conda environment
36
+ ```bash
37
+ conda create -n vuer python=3.8
38
+ conda activate vuer
39
+ ```
40
+
41
+ Install vuer
42
+ ```bash
43
+ pip install vuer==0.0.9
44
+
45
+ pip install numpy
46
+ pip install trimesh
47
+ pip install websockets
48
+ pip install aiohttp-cors
49
+ pip install pillow
50
+ ```
51
+
52
+ Now, to run the examples, first download the example datasets.
53
+
54
+ Each subdirectory in the `assets` directory contains a `Makefile`. Run the `make` command in each subdirectory to download the datasets. For example:
55
+
56
+ ```bash
57
+ cd assets/static_3d
58
+ make
59
+ ```
60
+
61
+ Then run the examples
62
+
63
+ ```bash
64
+ cd vuer/examples/vuer
65
+ python 01_trimesh.py
66
+ ```
67
+
68
+ ## To Develop
69
+
70
+ ### Setting up the Document Site
71
+
72
+ https://www.docslikecode.com/learn/05-cd-for-docs/
73
+
74
+ ```bash
75
+ cd docs
76
+ pip install -r requirements.txt
77
+ ```
78
+
79
+
80
+
@@ -0,0 +1,29 @@
1
+ vuer/__init__.py,sha256=x2ZqgbBIDHQr7UvdkKhVdtYToIZdhXw4XTRnfrQiBos,28
2
+ vuer/base.py,sha256=ZpZJoOFXh73a0yiWep-S3SZHY4dgyuxLki4HT2A8k-o,2974
3
+ vuer/events.py,sha256=sfl5m1J0Tc3kDnboLGHQwELfBAUokA-ME-84OfvzfOg,4962
4
+ vuer/schemas.py,sha256=4ebQZWk02a3W-YNkj3wkifJTQZBoffTzJdZGPjYoW4g,13353
5
+ vuer/serdes.py,sha256=_4q65iHmIW-Op5OCvNwgAy7Z4ofOcvuW3NfTbRfiuZo,2398
6
+ vuer/server.py,sha256=JAJMUDKBAfmY9XQ2-KHYy7Ea_tWK3H5Bw186ZPT8fJM,10958
7
+ vuer/types.py,sha256=4jVXsuLjaQwmnCrK9j9G6vSVbmb8cq72WhptZg3qOuU,681
8
+ vuer/__pycache__/__init__.cpython-38.pyc,sha256=LI9NbVr-FxZraiRRd33pmOxNogkeiyVNjbZKLq-l93o,166
9
+ vuer/__pycache__/base.cpython-38.pyc,sha256=Y6PEto5NzO42uoQGObSAJJ6SDN8UTsx4oLqvemV9MZU,3868
10
+ vuer/__pycache__/events.cpython-38.pyc,sha256=P7yQWuaQWH8oQ6pgU8cfJDDzQXqkxtJChkpGwQxtnR0,6543
11
+ vuer/__pycache__/schemas.cpython-38.pyc,sha256=dWtBo-NzIZse1Ld6AD_HzB_5ZTou56oD5a5kBhFDEHU,18716
12
+ vuer/__pycache__/serdes.cpython-38.pyc,sha256=oT1A94H8ayRCxNnw0L-7Q5Dt3535MOwXZMkvyQQvB9M,2032
13
+ vuer/__pycache__/server.cpython-38.pyc,sha256=LhABfyQZmiWM9akGKwvDqgKByUTYK11q-raUCpWQr_Y,10518
14
+ vuer/__pycache__/types.cpython-38.pyc,sha256=c5flT-KV4D-N4Gz0v7FzLtAa9hiS9B5J_UeB2h5JiDY,1565
15
+ vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ vuer/addons/nerf_vuer/control_components.py,sha256=K4PU0nD572L4J7lLFfShWficWZQnH4t-x6WWMrAVw8g,290
18
+ vuer/addons/nerf_vuer/mixins.py,sha256=fQuW3adf6X2xw_PSfS145TNfbQ9OoTKuv8mYEo6Pt6A,12966
19
+ vuer/addons/nerf_vuer/nerf_vuer.py,sha256=R5vI7g_sObbW1LTZ2VnR7pci7aO8iUtkKIbNnbqHnRU,5183
20
+ vuer/addons/nerf_vuer/render_components.py,sha256=XilHnJySJWVgmdUbPFNYyc_YWV8O5AcKkBEZOUFbnMI,3821
21
+ vuer/addons/nerf_vuer/render_nodes.py,sha256=5TKqIbMPiOtBxfF4FQI6uB0w_9FTfGiwS8xRbhPa0_g,14441
22
+ vuer/addons/nerfuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ vuer/addons/nerfuer/render_nodes.py,sha256=EJK5N3xne5n7abTaAoLPX7SRqQ_tEen9zNypvSnZTTw,4465
24
+ vuer-0.0.9.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
25
+ vuer-0.0.9.dist-info/METADATA,sha256=Hg8Dvos7jt9H11n3PJGlfioXEtdNjQ8FoHg-cM-v6Qs,1691
26
+ vuer-0.0.9.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
27
+ vuer-0.0.9.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
28
+ vuer-0.0.9.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
29
+ vuer-0.0.9.dist-info/RECORD,,
@@ -1,34 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: vuer
3
- Version: 0.0.7rc2
4
- Home-page: https://github.com/geyang/vuer
5
- Author: Ge Yang<ge.ike.yang@gmail.com>
6
- Author-email: ge.ike.yang@gmail.com
7
- License: MIT
8
- Classifier: Development Status :: 3 - Alpha
9
- Classifier: Programming Language :: Python
10
- Requires-Python: >=3.8.6
11
- Description-Content-Type: text/markdown
12
- License-File: LICENSE
13
- Requires-Dist: tqdm
14
- Requires-Dist: termcolor
15
- Requires-Dist: params-proto
16
- Requires-Dist: killport
17
- Requires-Dist: msgpack
18
- Provides-Extra: dev
19
- Requires-Dist: black ==22.3.0 ; extra == 'dev'
20
- Requires-Dist: pylint ==2.13.4 ; extra == 'dev'
21
- Requires-Dist: pytest ==7.1.2 ; extra == 'dev'
22
-
23
- # Vuer: A modern 3D Visualizer for Robotics and VR
24
-
25
- Vuer is a 3D visualization tool for robotics and VR applications.
26
-
27
- ## Installation
28
-
29
- ```python
30
- pip install vuer
31
- ```
32
-
33
-
34
-
@@ -1,22 +0,0 @@
1
- vuer/__init__.py,sha256=x2ZqgbBIDHQr7UvdkKhVdtYToIZdhXw4XTRnfrQiBos,28
2
- vuer/base.py,sha256=qylAS25I-cBGB_GQd2CSLZMpmAk2dhpIGrTIhENX2nk,3038
3
- vuer/events.py,sha256=sfl5m1J0Tc3kDnboLGHQwELfBAUokA-ME-84OfvzfOg,4962
4
- vuer/schemas.py,sha256=lnipEPrD0GNaT6-yTbGIx657PuBIMB1eg8upJi1Jszc,13053
5
- vuer/serdes.py,sha256=MyTyc_qMlrlU9PLpX6VtIJz-XnmSyntj22bS_1SVzZE,921
6
- vuer/server.py,sha256=U0HjjcU1BxR2LPNSLCOXyrnivgHQvuMCxL-s0cXkRgI,10949
7
- vuer/types.py,sha256=4jVXsuLjaQwmnCrK9j9G6vSVbmb8cq72WhptZg3qOuU,681
8
- vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- vuer/addons/nerf_vuer/control_components.py,sha256=K4PU0nD572L4J7lLFfShWficWZQnH4t-x6WWMrAVw8g,290
11
- vuer/addons/nerf_vuer/mixins.py,sha256=fQuW3adf6X2xw_PSfS145TNfbQ9OoTKuv8mYEo6Pt6A,12966
12
- vuer/addons/nerf_vuer/nerf_vuer.py,sha256=R5vI7g_sObbW1LTZ2VnR7pci7aO8iUtkKIbNnbqHnRU,5183
13
- vuer/addons/nerf_vuer/render_components.py,sha256=XilHnJySJWVgmdUbPFNYyc_YWV8O5AcKkBEZOUFbnMI,3821
14
- vuer/addons/nerf_vuer/render_nodes.py,sha256=5TKqIbMPiOtBxfF4FQI6uB0w_9FTfGiwS8xRbhPa0_g,14441
15
- vuer/addons/nerfuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- vuer/addons/nerfuer/render_nodes.py,sha256=EJK5N3xne5n7abTaAoLPX7SRqQ_tEen9zNypvSnZTTw,4465
17
- vuer-0.0.7rc2.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
18
- vuer-0.0.7rc2.dist-info/METADATA,sha256=-feg2vczencHFqX1rP1WjG2JwEjYUUWbsX3rDaCTf3E,808
19
- vuer-0.0.7rc2.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
20
- vuer-0.0.7rc2.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
21
- vuer-0.0.7rc2.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
22
- vuer-0.0.7rc2.dist-info/RECORD,,
File without changes