-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow performance on showing image in CameraFrustumHandle #351
Comments
Hi @abcamiletto! One thing you could try is the from pathlib import Path
frustum_handle._image_data = Path("some_image.jpeg").read_bytes() If you can confirm that this is much faster, I'm also open to supporting already-encoded images by (1) changing the type of the |
Hi @brentyi, thanks a lot for the answer! For anyone having this problem in the future, it's also necessary to set the image media type as follow to trigger the rendering from pathlib import Path
frustum_handle._image_data = Path("some_image.jpeg").read_bytes()
frustum_handle.image_media_type = "image/jpeg" I do agree that having the option to provide images as bytes could be nicer, but I am afraid implementing this across the project could go over my availability for the PR. |
This also leads to a weird behaviour: from pathlib import Path
frustum_handle._image_data = Path("some_image.jpeg").read_bytes()
frustum_handle.image_media_type = "image/jpeg"
print(frustum_handle.image) # None I assume the underlying getter should check if |
I am currently using the
.image
setter of the CameraFrustumHandle. In my use case I have a lot of images to show in parallel (120+) and it becomes quite slow since the input is a numpy array that is then encoded into bytes.The current implementation does this
viser/src/viser/_scene_handles.py
Lines 354 to 369 in faa9c57
Which make sense to me but does not scale. I am decoding the jpg images from disk, converting them to numpy array only to convert them back to jpg and visualize them.
Even with threading this cannot be done in real time with large number of cameras.
I am very open to work on a PR to support either accepting paths or streams of bytes in the image setter method.
Please let me know if that would be welcomed and how you would prefer this to behave!
The text was updated successfully, but these errors were encountered: