Comments (4)
Thanks both for your answers!
For context, I am evaluating threedworld to use for learning object manipulation from raw images using CV + RL, and from the feature matrix on your website it seemed like the perfect environment (good graphics + physics). So a live stream of images is exactly what I need, although 720p might be slightly overkill.
I understand all of your points, I already excluded everything except (1) reading pixels from Unity and (2) compressing the image as only likely reasons for what I observe based on experiments I ran.
From the benchmark you pointed out (thanks!), I was able to find that indeed you do have a flag for the point (2) that I asked for: {"$type": "set_img_pass_encoding", "value": False}
, and by setting this I indeed get a considerable speed-up, further confirming my suspicion. That's great, as I don't care about transfer costs: everything runs on localhost.
(Also, the benchmark on my machine is similar to the expected values, confirming my setup is fine.)
Regarding (1), I have never done this in Unity, but in OpenGL, it should not lead to that dramatic slowdown. In fact, that's exactly what primusrun
and optirun
commands for linux laptops do: render into a pixel buffer (PBO) on the discrete GPU, and move this onto the CPU's integrated GPU for rendering, and they do so in real-time.
One more comment:
The _img passes defaults to a jpg. All other passes need to be lossless png to be accurate.
This does not seem to be the case. I'm looking at the raw bytes I'm getting, and the RGB image definitely has the typical \x89PNG
header, so I'm sure it's png encoded, not jpg.
Anyways, {"$type": "set_img_pass_encoding", "value": False}
is what I was looking for, thanks.
from tdw.
Hi Lucas --
You can send the "send_images" command once, with frequency of "always"; sending the command every frame is going to cause a slowdown. The objects_and_images.py
example controller shows a slightly different way of structuring image saving. Have you tried that controller, to see what difference in performance that makes on your system?
While getting pixel data out of Unity is always going to be a bit of a bottleneck, you should be able to get more like 35-40 fps at that resolution. We have published benchmarks on the repo that you can refer to.
from tdw.
For benchmarks: https://github.com/threedworld-mit/tdw/blob/master/Documentation/benchmark/image_capture.md
For information re: performance optimizations: https://github.com/threedworld-mit/tdw/blob/master/Documentation/benchmark/performance_optimizations.md
Known causes of image capture slowdown:
- Reading the pixel buffer is slow (there is no way to avoid this)
- The amount of data being sent over the wire is high (see this document for how the size of the byte array affects performance)
- Encoding to jpg or png is slow (there is no way to avoid this in Unity) But the raw data is so larger that it's better to encode than not.
- Running in Unity Editor is very slow
- Saving images to disk (or converting them into PIL) can be slow (though this is probably not as big a factor as the other factors, and can be mitigated with multithreading)
It seems that the image is sent to the controller as a png encoded image. I believe this is where the slowdown comes from. It is not possible to encode an image into png format in real-time for higher resolutions in my experience.
The _img
passes defaults to a jpg. All other passes need to be lossless png to be accurate.
from tdw.
@lucasb-eyer Closing this Issue. I ran your controller and you're not doing anything incorrect... Unfortunately, this an issue with how Unity reads the pixels off the GPU.
A few ways to speed up the simulation:
- Reduce screen size
- Only send
{"$type": "send_images", "frequency": "once", "avatar_id": avatar_id}
when you actually need the image; rendering without this command is much faster. - If all you need is a video and not the frames themselves, video capture with an external program might be faster.
from tdw.
Related Issues (20)
- MacOS Silicon sometimes freezes if downloading many asset bundles HOT 1
- Scene asset bundles aren't unloaded when a new scene loads
- Lighting is broken in tdw_room if scenes are loaded before it HOT 2
- Incomplete code example
- screen position documentation, missing link
- send_local_transforms actually sent global transforms HOT 3
- rotate_object_by "is_world" doesn't seem to cause any differences HOT 3
- saved images are upsidedown after updating to v1.12.9
- Teleop/Manual Control Example HOT 2
- TDW not compatible with Jupyter Notebook on VSCode HOT 4
- About nav_mesh.py example with magnebot HOT 3
- Invisible Rigid Body Object
- Occupancy Maps with rectangular layouts
- Some object's pivot is not its bottom-center
- send_occlusion and Occlusion is not working properly
- adding `use_centroid` in `teleport_object` api?
- Error when creating asset bundles from .fbx models, .obj file fails to be created
- How to customize build HOT 1
- How are interior_walls treated as mesh obstacles? HOT 2
- Add force in the middle HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tdw.