pysdic.compute_pixel_integration_points#
- compute_pixel_integration_points(mesh, camera, *, warp_by=None, mask=None)[source]#
Compute the material points of a surface mesh seen by the pixels of a camera, as integration points of the mesh.
The (deformed) mesh is projected on the sensor, and the pixels whose center is inside a projected element are selected (see
compute_projected_mesh_mask()).The material point seen by each selected pixel is computed, according to the dimension \(E\) of the world points of the camera (the dimension of the mesh):
\(E = 3\) (3D surface mesh): the ray of the pixel (see
pysdic.Camera.get_camera_rays()) is intersected with the mesh (seepysdic.Mesh.cast_rays()). The first intersection gives the material point seen by the pixel, so the occlusions are taken into account.\(E = 2\) (2D surface mesh): the camera is inverted to get the world point of the pixel, \(\vec{x}_w = \text{Extrinsic}^{-1}(\vec{x}_n)\) with the normalized point \(\vec{x}_n\) of the pixel (see
pysdic.Camera.get_camera_normalized_points()), and the world point is located in the mesh (seepysdic.Mesh.locate_points()). This covers a camera of the plane (pysdic.PlanarRigidExtrinsic,pysdic.PlanarHomographicExtrinsic) and a 3D camera observing the plane \(Z_w = 0\) (pysdic.WorldPlanePerspectiveExtrinsic,pysdic.WorldPlaneOrthographicExtrinsic), whose inverse is the intersection of the ray of the pixel with the plane. The extrinsic must implementinvert.
The pixels that see no point of the mesh are discarded.
The natural coordinates of the points are valid for any displacement of the mesh (same connectivity), e.g. to follow the material points seen at a frame to another frame.
Important
The case \(E = 3\) requires the optional package
open3d(pip install open3d). The case \(E = 2\) has no optional dependency.- Parameters:
mesh (
pysdic.Mesh) – The surface mesh (with an element type), of dimension \(E = 2\) or \(3\) equal to the input dimension of the camera.camera (Union[
pysdic.Camera,pysdic.View]) – The camera (or a view, whose camera is used).warp_by (Optional[Union[str, ArrayLike]], optional) – The displacement of the vertices (name of a vertex property or array of shape \((N_v, E)\)), e.g. the displacement of a frame of an analysis.
mask (Optional[ArrayLike], optional) – A boolean mask of shape \((H, W)\) or \((H \times W,)\) restricting the pixels to use (e.g. a region of interest). By default, all the pixels inside the projected mesh.
- Returns:
integration_points (
pysdic.IntegrationPoints) – One located point per pixel seeing the mesh, in row-major order of the pixels.pixel_points (numpy.ndarray) – The pixel indices (row, column) of the points, of shape \((N_p, 2)\) and integer dtype.
- Raises:
TypeError – If an input has a wrong type.
ValueError – If the mesh is not a surface mesh of dimension 2 or 3, its dimension is not the input dimension of the camera, or the extrinsic of the camera cannot be inverted (\(E = 2\)).
- Return type: