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 documented example image reshape in image_apis.md #2814

Closed
wants to merge 1 commit into from

Conversation

TRex22
Copy link

@TRex22 TRex22 commented Jun 30, 2020

What does this PR do?

  • Resolves a minor issue in the documentation where 3 dimensions were used and not 4
  • Adds a Quick Tip around image resizing

There was a small mistake in the example AirSim image processing with NumPy where only `3` dimensions were used instead of `4`
@@ -71,7 +71,7 @@ response = responses[0]
img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8)

# reshape array to 4 channel image array H X W X 4
img_rgb = img1d.reshape(response.height, response.width, 3)
img_rgb = img1d.reshape(response.height, response.width, 4)
Copy link
Contributor

Choose a reason for hiding this comment

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

UE currently gives RGB image, so I think the comment above needs to be fixed rather than the code

Copy link
Author

Choose a reason for hiding this comment

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

In my testing, with the latest environments in releases the returned image has 4 channels RGBA. Im not sure where the alpha channel is coming from but this change would be accurate to how the current AirSim python client behaves and what data you get back.

Potentially there is a bug somewhere and I can investigate it

Copy link
Author

Choose a reason for hiding this comment

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

I wanted to make this change because it tripped me up and wasted days of me trying to debug my code - then I realised the dimensions didnt match. I was using a different 1d -> 3d image resize mechanism (not the one defined in the docs) so I didnt get an error but rather scrambled data

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that so, from what I remember, it gives RGB, I'll test again.
Are you using Unity by any chance? I think that returns RGBA

Copy link
Author

Choose a reason for hiding this comment

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

No definitely Unreal. I tested this with the neighbourhood environment

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late response, however, I can say that the API is returning an RBG image rather than RGBA for sure.
Relevant UE code - https://github.com/microsoft/AirSim/blob/master/Unreal/Plugins/AirSim/Source/RenderRequest.cpp#L114-L116
Unity is also being changed to RBG in #2683

@madratman madratman closed this Sep 1, 2020
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.

3 participants