Skip to content
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

Fix camera limitation due to jpg encoding #171

Conversation

alexandrefch
Copy link
Contributor

@alexandrefch alexandrefch commented Sep 24, 2024

I noticed that the camera sensor was limited in resolution and frequency, by default is set to 640x480 10fps, when trying to increase that the frame rate was falling down to 6/7fps on a Quadro RTX 5000.

After looking in the code and searching for a performance bottleneck with unity profiling tool, I find out that the image where send in CompressedImage format made from Texture2D.EncodeToJPG().
This method was intended for screenshots purpose and not real-time encoding.
Following ZeroSimROSUnity camera sensor implementation, a good way is to simply send raw buffer without any encoding, allowing high quality.

Screenshot from 2024-09-24 17-58-49
Screenshot from 2024-09-24 17-58-56

Now running the simulation at 140fps in the demo scene, using camera sensor of 1920x1080 at 20fps (Running on Ubuntu 22.04 with Quadro RTX 5000).

Warning

The depth camera may be broken I didn't check.

@alexandrefch alexandrefch changed the title Fix Lidar lag spike from RaycastLiDARSensor.cs Fix camera limitation due to jpg encoding Sep 24, 2024
@Autumn60 Autumn60 self-requested a review September 27, 2024 02:05
Copy link
Contributor

@Autumn60 Autumn60 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great PR.

Can you please change the topic name for the camera prefab in Assets/UnitySensorsROS/Runtime/Prefabs/Camera?

Rviz will crash if ImageMsg topic have /compressed in topic name.

@Autumn60
Copy link
Contributor

Autumn60 commented Oct 6, 2024

@alexandrefch
Our changes have made it difficult to merge this PR into the master branch.
Could you please submit the PR to beta/v2.x.x? so we can include your changes in v2.0.6.

@alexandrefch alexandrefch changed the base branch from master to beta/v2.x.x October 7, 2024 08:39
@alexandrefch alexandrefch force-pushed the fix/camera_image_jpg_limitation branch from b4343f8 to d1da2d0 Compare October 7, 2024 08:52
@Autumn60 Autumn60 self-requested a review October 7, 2024 09:26
Copy link
Contributor

@Autumn60 Autumn60 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thanks!! 🎉

@Autumn60 Autumn60 merged commit 5b73f20 into Field-Robotics-Japan:beta/v2.x.x Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants