-
Hi everyone, I would like to generate a depth map image from a mesh using camera settings similar to the code snippet below. From my research, I found a distancemap function in MeshLib that appears to create depth images. However, I’m having trouble figuring out how to configure the settings correctly to match the desired camera parameters. Could anyone provide some guidance or share any suggestions?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello! Looks like you need this function with correctly specified parameters: MeshLib/source/MRMesh/MRDistanceMap.h Lines 178 to 181 in b68be6c You can setup to fit mesh MeshLib/source/MRMesh/MRDistanceMapParams.h Lines 21 to 28 in b68be6c Or more precisely: MeshLib/source/MRMesh/MRDistanceMapParams.h Lines 30 to 36 in b68be6c Please note that this algorithm will make depth map with parallel rays, so if you want to achieve perspective effect you will need to raycast each pixel by yourself. As I can see from your parameters you need something like this: Matrix3f rotation;
rotation.z = Vector3f::minusZ(); // direction `camLookAt - camPos`
float pixelSize = 0.1f * std::tan( 0.25f ) / 500.0f; // near * tg( xFov/2 ) / ( width / 2 ) : suggest that we have orthographic camera with screen placed on near plane
MeshToDistanceMapParams( rotation, Vector3f() /* origin = camPos + translation */, Vector2f(pixelSize,pixelSize), Vector2i(1000,1000) /* resolution */ ); |
Beta Was this translation helpful? Give feedback.
-
Thank you for your answer! |
Beta Was this translation helpful? Give feedback.
Thank you for your answer!
Could I get the Python example also ?