allenai / ai2thor

An open-source platform for Visual AI.
http://ai2thor.allenai.org
Apache License 2.0
1.09k stars 210 forks source link

How to get a top view of a room in ai2thor #1196

Open suha4227 opened 3 months ago

suha4227 commented 3 months ago

Hello, I would like to ask a question. In the newly released procthor scene, I can get a panoramic view of the entire house through action="AddThirdPartyCamera". Why is the exported picture in ai2thor white and nothing?

mengmeng6660 commented 3 months ago

You can write it like this event = controller.step(action="GetMapViewCameraProperties") controller.step( action="AddThirdPartyCamera", **event.metadata["actionReturn"] )

This snippet comes from this link https://github.com/allenai/ai2thor/pull/814

suha4227 commented 3 months ago

@wanhaozhangxiaorui Thank you very much, this problem has been solved, but I have a new problem. What I want to know is how to adjust the camera parameters to get a high-definition photo.

prathishpratt commented 1 month ago

Can you try this

def get_top_down_frame():
    # Setup the top-down camera
    event = controller.step(action="GetMapViewCameraProperties", raise_for_failure=True)
    pose = copy.deepcopy(event.metadata["actionReturn"])

    bounds = event.metadata["sceneBounds"]["size"]
    max_bound = max(bounds["x"], bounds["z"])

    pose["fieldOfView"] = 50
    pose["position"]["y"] += 1.1 * max_bound
    pose["orthographic"] = False
    pose["farClippingPlane"] = 50
    del pose["orthographicSize"]

    # add the camera to the scene
    event = controller.step(
        action="AddThirdPartyCamera",
        **pose,
        skyboxColor="white",
        raise_for_failure=True,
    )
    top_down_frame = event.third_party_camera_frames[-1]
    return Image.fromarray(top_down_frame)

get_top_down_frame()

Maybe while creating the controller, give the quality to be "very high". controller = Controller(platform=CloudRendering, scene=house, quality= "Very High")