microsoft / AirSim

Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
https://microsoft.github.io/AirSim/
Other
16.47k stars 4.59k forks source link

How can I get labeled images in segmentation? #3946

Open sunilhoho opened 3 years ago

sunilhoho commented 3 years ago

Question

What's your question?

Hi. I'm trying to get labeled images in segmentation, but it doesn't work.

Include context on what you are trying to achieve

I used simSetSegmentationObjectID(name + r"[\w]*", id, True) to merge( e.x) ground_1, ground_2, ground_3 -> ground) and set it to same object id.

And then I did response = airsim.ImageRequest("0", airsim.ImageType.Segmentation, False, False) img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8) img_rgb = img1d.reshape(128, 256, 3) cv2.imwrite(os.path.normpath(filename + '.png'), img_rgb) to save my image as png form.

To check each pixel's labels in image, img_l = Image.open(filename + '.png').convert('L') print(np.array(img_l)[64])

But the result is different from what I set. I think it should be matched with object id.

My segmentation model uses the cityscapes dataset which is an 'L' type image. So I want to convert it as an 'L' type image.

Thanks

Context details

Include details of what you already did to find answers

sandilyasg commented 9 months ago

@sunilhoho any update regarding this?