Skip to content

python simGetImages API bug #1755

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

Open
flyers opened this issue Jan 30, 2019 · 4 comments
Open

python simGetImages API bug #1755

flyers opened this issue Jan 30, 2019 · 4 comments
Labels

Comments

@flyers
Copy link

flyers commented Jan 30, 2019

I use the following code to get the segmentation image from the camera.

responses = client.simGetImages([ImageRequest("0", airsim.ImageType.Segmentation, False, False)])
response = responses[0]

# get numpy array
img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8) 

# reshape array to 4 channel image array H X W X 4
img_rgba = img1d.reshape(response.height, response.width, 4)  

However, the following error happens very randomly.

ValueError: cannot reshape array of size 1 into shape (0,0,4)

It seems that sometimes the returned response will have zero height and width and the data only have a length of 1.
Similar problems have been reported in #1710.
I believe it's a serious bug in the simGetImages API.

@srivatsankrishnan
Copy link

@flyers @sytelus I am seeing this issue too. But I do have a workaround for this issue. I have a try and except before the simGetImages call. On exception, I try to reset AirSim and pass the dummy image. Something like this:

try:
   image = client.simGetImage(....)
except Exception as e:
    client.reset()
     image = np.ones(image.shape)

I have seen this workaround recovering from that error. But this is definitely a hack and it would be great if this is fixed in AirSim.

@gurkanctn
Copy link

Until a permanent solution is found, another workaround can be using an if statement to check for the length of the response, and only try reshaping if it passes the test. This might be faster than the try-catch (to be confirmed).

@annisanazi
Copy link

did anyone resolve this issue?

@rallen10
Copy link

I am still facing this issue! There are many more issues like this open and the ones that are closed are only closed because someone recommended the if statement workaround. Can we get a higher priority on this?

@madratman madratman removed the binary label Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants