Open StarsTesla opened 1 month ago
Hello @StarsTesla,
Could you please describe what you expected to see vs what actually happened.
Furthermore, the code that you included refers to undefined functions and meshes that you did not attach, so we cannot reproduce this.
@merlinND The right rendering box should be like the left one, which is the right size or scale. The right box maybe squeezed? The only different is just with the ground mesh, even I use a fake plane, the box is still being squeezed. For the code: `def opencv_camera2world_to_lookat(camera2world):
assert camera2world.shape == (4, 4), "Input matrix must be 4x4"
# Extract the camera position (origin)
origin = camera2world[:3, 3]
# Extract the camera's forward direction (positive z-axis in OpenCV)
forward = camera2world[:3, 2]
# Calculate the target point
# We'll use a distance of 1 unit in front of the camera
target = origin + forward
# Extract the up vector (negative y-axis of the camera in OpenCV)
up = [0,0,1]
return origin, target, up
def calculate_fov(fx, fy, image_width, image_height):
hw = image_width / 2
hh = image_height / 2
# Calculate FOV in radians
fov_x = 2 * math.atan2(hw, fx)
fov_y = 2 * math.atan2(hh, fy)
# Convert to degrees
fov_x_deg = math.degrees(fov_x)
fov_y_deg = math.degrees(fov_y)
return fov_x_deg, fov_y_deg`
`def setup_mitsuba_camera(fx, fy, cx, cy, w, h, camera2world):
fov_x, fov_y = calculate_fov(fx, fy, w, h)
print(fov_x, fov_y)
c2w = opencv_to_mitsuba_transform(camera2world)
origin, target, up = opencv_camera2world_to_lookat(camera2world)
camera_dict = {
'type': 'perspective',
'to_world': T.look_at(origin=origin, target=target, up=up),
'fov': fov_x,
'fov_axis': 'x',
'film': {
'type': 'hdrfilm',
'width': w,
'height': h,
"pixel_format": "rgba",
},
}
return camera_dict`
How should I providing you the mesh?
@StarsTesla
From your screenshot, the ground plane appears to be going through the middle of the box which is probably why you're seeing only half of the box with the ground added.
Try moving the box up or the ground plane down and see if that resolves your issue.
@knightcrawler25 In fact, the box on the right (not normal) feels elongated, while the model on the left looks normal, which can be distinguished by the white lines on the box. I use blender to open the original model, as shown below
@StarsTesla
Could you please provide a fully reproducible example? You can zip up the scene file along with the meshes and attach it here. If the file is too big for GitHub, perhaps upload it to Google Drive/One Drive and share the link (accessible to everyone)
The snippet of code you've provided refers to objects, transformations and function arguments that weren't shared. It would be helpful to have everything that reproduces the bug so that people don't have to spend time figuring out or assume things about the code.
'to_world': T.translate(obj_1['position']).rotate([0, 0, 1], obj_1['heading']),
sensor = setup_mitsuba_camera(fx, fy, cx, cy, w, h, camera2world)
Hi @StarsTesla
I've cropped out the box on the right and it overlays perfectly with the one on the left - as far as I can tell. I think you're just falling for some optical illusion here.
As @knightcrawler25 said, we'd need access to the assets to debug this if there is indeed a bug.
A very interesting bug: The only different of these two scene is just with or without ground mesh:
For other component: