


CV_64F, 0, 1, ksize = 5 ) # convert to unit vectors :return: The corresponding surface normals map as numpy array of size (H,W,3). :param dmap: A grayscale depth map image as a numpy array of size (H,W). Using the Blender Python API, we can access the raw depth values from the Viewer node with the following code:ĭef dmap2norm ( dmap ): """Computes surface normals from a depth map. The Viewer node shows depth map of the camera view, with depth values normalised between 0 and 1. Add a Viewer node and a Normalize node, and connect everything as follows: The compositor should show a Render Layer and a Composite node at this point. Next, go to the Compositing tab and enable nodes by checking the Use Nodes box. In the bottom pane on the right-hand side, find the View Layer Properties and make sure that both the Combined and Z data passes are enabled. The default scene already has a cube, a camera and a light source added to it. It should give you something like this in the Layout tab. In this tutorial, we use Blender 2.93.6 to render images of a 3D surface, and save the corresponding depth maps and normal maps as numpy arrays using the Blender Python API.Ĭreate an empty project in Blender (File > New > General). There are many ways to represent the 3D shape of an object in a computer, such as the mesh vertices of the object, a depth map labelling each pixel in an object with its distance from the camera, a normal map providing surface normal vectors at each pixel in an image, etc. Primarily aimed at the 3D modelling and animation industry, such as for games, advertisements and entertainment, it also offers researchers working on 3D reconstruction a powerful tool at their disposal for generation of ground-truth 3D data.ģD reconstruction is an active research field in which we try to recreate the 3D shape of an object or a scene from a 2D image or a sequence of images, such as video frames. Blender is popular open-source 3D computer graphics tool widely used among the developer community, with over 14 million downloads in 2020 alone.
