pysdic.optimize_chains_transformation_input_points#

optimize_chains_transformation_input_points(seq_transformations, seq_chains, seq_outputs, guess, *, seq_kwargs=None, mode='rJ', loss=None, loss_scale=1.0, use_cache=False, **solve_kwargs)[source]#

Optimize the input points \(X\) such that their images by several chains of transformations match the given output points, with pysolvegn.solve_batch.

The problems are built with pysdic.build_chains_transformation_input_points_term() (one independent problem per point) and the optimized points are returned with the batch shape of guess:

points, result = optimize_chains_transformation_input_points(seq_transformations, seq_chains, seq_outputs, guess, ...)

The pysolvegn.BatchSolveResult gives the convergence information of each point (success, reasons, cost, n_iterations, …), with the points flattened along the first dimension: use result.success.reshape(points.shape[:-1]) to recover the batch shape.

See also

Parameters:
Returns:

  • numpy.ndarray – The optimized input points with shape \((\dots, n_i)\).

  • pysolvegn.BatchSolveResult – The result of pysolvegn.solve_batch.

Return type:

Tuple[ndarray, BatchSolveResult]

Examples

Triangulate 3D points seen by two calibrated cameras:

seq_transformations = [extrinsic_0, distortion_0, intrinsic_0, extrinsic_1, distortion_1, intrinsic_1]
seq_chains = [(0, 1, 2), (3, 4, 5)]

world_points, result = optimize_chains_transformation_input_points(
    seq_transformations, seq_chains, [image_points_0, image_points_1], guess, max_iteration=20, xtol=1e-10
)