You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on a research project where I need to retrieve the data from an offscreen camera.
My problem is the following:
My window's framebuffer size is exactly twice the window's size.
I have a predefined resolution that I need to use for downstream analysis which corresponds to the window size.
I extract the pixels of my offscreen camera using read_pixels(...) but the dimensions are 2 times too big for the first two dimensions corresponding to (width , height)
window_size: (480, 640)
framebuffer_size: (960, 1280)
window_content_scale: (2.0, 2.0)
read_pixels(...).shape: (1280,960,3)
Traceback (most recent call last):
camera_feedback[:] = offscreen.read_pixels(camid=0)
ValueError: could not broadcast input array from shape (1280,960,3) into shape (640,480,3)
I could fix my problem by down sampling the output of offscreen.read_pixels(camid=0) by the window content scale: offscreen.read_pixels(camid=0)[::2, ::2] or more elaborately:
But this is still not the ideal situation as potentially other machines have different DPI and scaling settings.
I was wondering wether there might be an option to either set the frame buffer size to be exactly the same as the window size when creating the MujocoViewer object, or alternatively to set the window content scaling to be 1:1, or to downsample automatically when calling read_pixels(...), or any other options?
I already tried adding various macOS specific glfw.window_hints(...) in mujoco_viewer/mujoco_viewer.pyline 37 with no luck:
Hello,
I am on macOS 13.3.1. And using these versions:
I am currently working on a research project where I need to retrieve the data from an offscreen camera.
My problem is the following:
My window's framebuffer size is exactly twice the window's size.
I have a predefined resolution that I need to use for downstream analysis which corresponds to the window size.
I extract the pixels of my offscreen camera using
read_pixels(...)
but the dimensions are 2 times too big for the first two dimensions corresponding to(width , height)
Here is a very shortened version of the code:
Outputs:
I could fix my problem by down sampling the output of
offscreen.read_pixels(camid=0)
by the window content scale:offscreen.read_pixels(camid=0)[::2, ::2]
or more elaborately:But this is still not the ideal situation as potentially other machines have different DPI and scaling settings.
I was wondering wether there might be an option to either set the frame buffer size to be exactly the same as the window size when creating the
MujocoViewer
object, or alternatively to set the window content scaling to be 1:1, or to downsample automatically when callingread_pixels(...)
, or any other options?I already tried adding various macOS specific
glfw.window_hints(...)
inmujoco_viewer/mujoco_viewer.py
line 37 with no luck:Thanks in advance!
The text was updated successfully, but these errors were encountered: