-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Labels
Description
I found that in the latest master branch, the simGetImages API returns wrong image types if we use "NoDisplay" viewmode in settings.json. I use the Blocks environment and the following python scripts to reproduce this bug. When the viewmode is "NoDisplay", the following code gets the RGB image instead of the segmentation image.
import numpy as np
import cv2
import airsim
def uncompressed_to_cvimage(response):
'''
Convert uncompressed RGBA image to cv2 BGR format H x W x Channels
'''
assert response.pixels_as_float == False
img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8)
img = img1d.reshape(response.height, response.width, 4)[:, :, 0:-1]
return img[:, :, ::-1]
client = airsim.MultirotorClient()
client.confirmConnection()
client.enableApiControl(True)
client.armDisarm(True)
response = client.simGetImages([airsim.ImageRequest(
"0", airsim.ImageType.Segmentation, False, False)])[0]
seg = uncompressed_to_cvimage(response)
cv2.imshow('seg', seg)
cv2.waitKey(0)mfe7