trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

Scene.save_image resolution bug

Open TianshuangQiu opened this issue 2 years ago • 0 comments

I am loading a series of .obj files and converting them into a gif. My code is below

for i, f in enumerate(filenames):
    print(f"Reading {f}")
    mesh = tr.load(f)
    scene = tr.Scene(geometry=mesh)
    scene.set_camera(angles=(0, np.pi / 4, 0), resolution=(1000, 1000), distance=1)
    # Santiy check
    # scene.show()
    data = scene.save_image(visible=False)
    imgs.append(data)

out = []

for im in imgs:
    img_file = Image.open(io.BytesIO(im))
    width, height = img_file.size
    print(width, height)
    out.append(img_file)

out[0].save(
    "grasp.gif",
    format="GIF",
    append_images=out[1:],
    save_all=True,
    duration=60,
    loop=0,
)

This seemed pretty standard until I checked the output: the mesh was extremely tiny in the middle of the image, even though it looked fine when I checked the visualization with scene.show(). Digging further, I found that even though I specified the resolution to be (1000, 1000), the printed width and height is actually (2000, 2000). Please let me know if I am doing anything wrong here!

TianshuangQiu avatar Jul 12 '22 05:07 TianshuangQiu