carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
10.88k stars 3.5k forks source link

pygame windows generate bad camera image #6225

Closed cdefg closed 1 year ago

cdefg commented 1 year ago

CARLA version: 0.9.14 from release download Platform/OS: windows 11 with Nvidia RTX 4070ti(driver 528) Problem you have experienced:

I had bad camera output from the Python examples provided by carla I had hoped that the cause is I opened Nvidia's GSync option, so I tried to turn off windows-mode GSync and it's useless. I completed abandoned GSync but it still doesn't matter.

badly rendered image

but lidar is ok

What you expected to happen: Hope this can be fixed. Steps to reproduce: A trial to use windows 11, I think. Or it's a matter of RTX 40 card.

myleskeller commented 1 year ago

I'm experiencing the same issue with any RGBCamera output--both when displaying them in pygame and when exporting frames as image files. I'm using Carla 0.9.14 that I built on Windows 10 with a RTX 3090.

cdefg commented 1 year ago

I have tested image output, it also doesn't work normally as you. @myleskeller I hoped to solve this problem by building carla, but in another issue: https://github.com/carla-simulator/carla/issues/6120 I just can't find the private repository so far(20230220).

cdefg commented 1 year ago

I have successfully built carla 0.9.14. I can both run the simulator in Unreal Editor and isolatedly, but the bad image still happens. I don't know how to do, this function is important for a simulator.

mawistc commented 1 year ago

Maybe that is the stride problem, try to use width and height resolution of multiple of 256 pixel. see #6085

cdefg commented 1 year ago

Maybe that is the stride problem, try to use width and height resolution of multiple of 256 pixel. see #6085

That helps, thanks alot

myleskeller commented 1 year ago

For those discovering this and wondering exactly what is done regarding the fix in #6085, any client side .py file that initializes a sensor of type RGBCamera should have image_size_x and image_size_y attributes used to set the camera image size.

For example, in visualize_multiple_sensors.py, they are initialized as follows:

camera_bp = self.world.get_blueprint_library().find('sensor.camera.rgb')
disp_size = self.display_man.get_display_size()
camera_bp.set_attribute('image_size_x', str(disp_size[0]))
camera_bp.set_attribute('image_size_y', str(disp_size[1]))

In my case, a debug print of disp_size returned [426, 360]. I simply hard-coded disp_size like:

scalar = 1
disp_size = [256,256]*scalar

that way if I need the increased resolution, I can just change the scalar.

There is probably a more sophisticated way to do this, as my implementation doesn't fill the previously allocated space in the pygame window, but I can at least see what's going on now.

carla_rgbcamera

TzabarDolev commented 10 months ago

I wrote a short blog post about this issue on the Carla simulator research blog - https://carlasimblog.wordpress.com/2023/09/16/the-64-division-curse/. And added a short code snippet to fix this.

MayaHL2 commented 7 months ago

From what I understood, the disp_size needs to be a power of 2 for both the height and the width, so you would have a normal image for disp_size = [256, 256] but not for [255, 255]