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

Changing depth resolution different from 256x144 #5014

Open
DanieleMarchisotti opened this issue Mar 7, 2025 · 0 comments
Open

Changing depth resolution different from 256x144 #5014

DanieleMarchisotti opened this issue Mar 7, 2025 · 0 comments

Comments

@DanieleMarchisotti
Copy link

Bug report

  • AirSim Version/#commit: Linux 1.8.1
  • UE/Unity version: 4.27
  • autopilot version: N/A
  • OS Version: Ubuntu 22.04

What's the issue you encountered?

Slowing dramatically the number of depth images saved if the resolution is different from 256x144.
I can save 1 image per second with 256x144 of resolution, but when the resolution is changed I can save only 1 image every 30 s.

Settings

This is the portion of code I use to save images. I pause the simulation to get synchronized depth and rgb images.

...
    # Request scene and segmentation images separately
    scene_requests = [
        airsim.ImageRequest("0", airsim.ImageType.Scene, False, False), # camera_name, image_type, pixels_as_float, compress
        airsim.ImageRequest("0", airsim.ImageType.DepthPlanar, True, False), # camera_name, image_type, pixels_as_float, compress
    ]
    frame_num = 0
    while capturing:
        try:
            # pausing simulation to capture data synchronously
            client_sim.call('simPause', True)
            scene_responses = client.simGetImages(scene_requests)
            for idx, response in enumerate(scene_responses):
                if response.pixels_as_float:
                    filename = save_dir + "/depth/" + str(response.time_stamp)
                    print("Type %d, size %d" % (response.image_type, len(response.image_data_float)))
                    airsim.write_pfm(os.path.normpath(filename + '.pfm'), airsim.get_pfm_array(response))
                else: #uncompressed array
                    filename = save_dir + "/rgb/" + str(response.time_stamp)
                    print("Type %d, size %d" % (response.image_type, len(response.image_data_uint8)))
                    img1d = np.fromstring(response.image_data_uint8, dtype=np.uint8) # get numpy array
                    img_rgb = img1d.reshape(response.height, response.width, 3)
                    img_rgb = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2RGB)
                    cv2.imwrite(os.path.normpath(filename + '.png'), img_rgb) # write to png
            # resuming simulation after capture
            client_sim.call('simPause', False)
            print(f"Captured frame: ", str(frame_num))
            frame_num += 1
            time.sleep(1)
        except Exception as e:
            print(f"Failed to capture image: {str(e)}")
...

settings.json:
If I change the resolution I get the issue.

{
    "SettingsVersion": 1.2,
    "SimMode": "Multirotor",
    "Vehicles": {
      "drone_test": {
        "VehicleType": "SimpleFlight",
        "AutoCreate": true,
        "X": 0,
        "Y": 0,
        "Z": 0,
        "Cameras": {
          "0": {
            "X": 0.5,
            "Y": 0,
            "Z": 0.1,
            "Pitch": -30.0,
            "Roll": 0.0,
            "Yaw": 0.0,
            "CaptureSettings": [
              { "ImageType": 0,
                "Width": 1280,
                "Height": 720,
                "FOV_Degrees": 32
              },
              { "ImageType": 1,
              "Width": 256,
              "Height": 144,
              "FOV_Degrees": 32
              },
              { "ImageType": 7,
              "Width": 1280,
              "Height": 720,
              "FOV_Degrees": 32
              }
            ]
          }
        }
      }
    },
    "SubWindows": [
      {
        "WindowID": 0,
        "CameraName": "0",
        "ImageType": 0,
        "VehicleName": "drone_test",
        "Visible": true
      },
      {
        "WindowID": 1,
        "CameraName": "0",
        "ImageType": 1,
        "VehicleName": "drone_test",
        "Visible": true
      },
      {
        "WindowID": 2,
        "CameraName": "0",
        "ImageType": 7,
        "VehicleName": "drone_test",
        "Visible": true
      }
    ]
  }

How can the issue be reproduced?

Run the code I put above with the settigns.json above

Include full error message in text form

No error message but just slowing down the saving of depth images.
I can save only one image in approximately 30 seconds.

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

No branches or pull requests

1 participant