ai2thor icon indicating copy to clipboard operation
ai2thor copied to clipboard

How to get a top view of a room in ai2thor

Open suha4227 opened this issue 11 months ago • 3 comments

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?

suha4227 avatar Mar 15 '24 12:03 suha4227

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

mengmeng6660 avatar Mar 18 '24 01:03 mengmeng6660

@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.

suha4227 avatar Mar 20 '24 06:03 suha4227

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")

prathishpratt avatar May 15 '24 01:05 prathishpratt