pysdic.View.image_project_points#
- View.image_project_points(world_points, dx=False, dintrinsic=False, ddistortion=False, dextrinsic=False)[source]#
Project 3D world points to gray level using the camera’s intrinsic, extrinsic, distortion parameters and image interpolation function from a
PointCloudinstance.This method is a convenience wrapper around
image_project()that extracts the numpy array from thePointCloudinstance.See also
image_project()for the main projection functionality.pysdic.PointCloudfor the structure of the input.
See also
pysdic.Camera.project()for the geometric projection process.ImageProjectionResultfor the structure of the output.
- Parameters:
world_points (
PointCloud) – The 3D world points to be projected.dx (
bool, optional) – IfTrue, the function will also return the jacobian of the gray levels with respect to the world points. Default isFalse.dintrinsic (
bool, optional) – IfTrue, compute the Jacobian of the gray levels with respect to the intrinsic parameters. Default isFalse.ddistortion (
bool, optional) – IfTrue, compute the Jacobian of the gray levels with respect to the distortion parameters. Default isFalse.dextrinsic (
bool, optional) – IfTrue, compute the Jacobian of the gray levels with respect to the extrinsic parameters. Default isFalse.
- Returns:
An instance of
ImageProjectionResultcontaining:gray_levels: A 2D array of shape (\(N_p\), channels) representing the image values at the projected pixel points.
jacobian_dx: (optional) A 3D array of shape (\(N_p\), channels, 3) representing the jacobian of the normalized points with respect to the world points if
dxis True.jacobian_dintrinsic: (optional) A 3D array of shape (\(N_p\), channels, \(N_{\text{intrinsic}}\)) representing the jacobian of the pixel points with respect to the intrinsic parameters if
dintrinsicis True.jacobian_ddistortion: (optional) A 3D array of shape (\(N_p\), channels, \(N_{\text{distortion}}\)) representing the jacobian of the pixel points with respect to the distortion parameters if
ddistortionis True.jacobian_dextrinsic: (optional) A 3D array of shape (\(N_p\), channels, \(N_{\text{extrinsic}}\)) representing the jacobian of the pixel points with respect to the extrinsic parameters if
dextrinsicis True.
- Return type:
Examples
Lets create a simple view and project some 3D points from a
PointCloudinstance:import numpy from pysdic import Camera, Image, View from pysdic import PointCloud from pycvcam import Cv2Extrinsic, Cv2Intrinsic rotation_vector = numpy.array([0.1, 0.2, 0.3]) translation_vector = numpy.array([12.0, 34.0, 56.0]) extrinsic = Cv2Extrinsic.from_rt(rotation_vector, translation_vector) intrinsic = Cv2Intrinsic.from_matrix( numpy.array([[1000, 0, 320], [0, 1000, 240], [0, 0, 1]]) ) camera = Camera( sensor_height=480, sensor_width=640, intrinsic=intrinsic, extrinsic=extrinsic, ) # Create a simple view with a blank image image = Image.from_array(numpy.zeros((480, 640), dtype=numpy.uint8)) view = View(camera=camera, image=image) # Define some 3D world points in a PointCloud instance world_points_array = numpy.array([ [0, 0, 1000], [100, 0, 1000], [0, 100, 1000], [100, 100, 1000] ]) world_points = PointCloud(world_points_array) # Project the 3D points to 2D image points image_projection_result = view.image_project_points(world_points, dx=True, dintrinsic=True, dextrinsic=True)
Extracting the projected image points and jacobians:
gray_levels = image_projection_result.image_points # The projected 2D image points of shape (4, 1) jacobian_dx = image_projection_result.jacobian_dx # The jacobian with respect to the world points of shape (4, 1, 3) jacobian_dintrinsic = image_projection_result.jacobian_dintrinsic # The jacobian with respect to the intrinsic parameters of shape (4, 1, 4) jacobian_dextrinsic = image_projection_result.jacobian_dextrinsic # The jacobian with respect to the extrinsic parameters of shape (4, 1, 6)