microsoft / AirSim

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

Cannot change camera resolution on the drone #4910

Open Tzoulio opened 6 months ago

Tzoulio commented 6 months ago

Question

What's your question?

The camera resolution is kept at the default value (256x144) even through changes on my settings.json file.

Include context on what you are trying to achieve

I am trying to take screenshots from the drone camera in my environment, however all the pictures come out at the default resolution (256x144), as a result a I end up loosing visual information.

Context details

This is my settings.json file: { "SettingsVersion": 1.2, "SimMode": "Multirotor", "CameraDefaults": { "CaptureSettings": [ { "ImageType": 0, "Width": 640, "Height": 480, "FOV_Degrees": 90 }, { "ImageType": 2, "Width": 640, "Height": 480, "FOV_Degrees": 90 } ] } }

Include details of what you already did to find answers

I tried using all the different cameras on the drone by changing the ImageType and changing the Width and Height values however the issue persists. I found similar problem in other issues however none could solve mine. The code I'm using to take the screenshot is the following: client = airsim.MultirotorClient() image = client.simGetImages([airsim.ImageRequest("0", airsim.ImageType.Scene)])

MehdiShahbazi commented 6 months ago

Hello Use the following code, I think your problem get resolved:

import airsim
import numpy as np
client = airsim.MultirotorClient()

responses = client.simGetImages([
    airsim.ImageRequest("0", airsim.ImageType.Scene, False, False)])[0]
img1d = np.frombuffer(responses.image_data_uint8, dtype=np.uint8)
raw_image = img1d.reshape(responses.height, responses.width, 3)