@@ -3888,9 +3888,17 @@ can continuously warp an image plane so that C<ncoords + 2> arbitrarily chosen
38883888points exactly map to the same number of other arbitrarily chosen points. They
38893889have the property that straight lines remain straight after transformation.
38903890
3891+ =for example
3892+
3893+ # perspective projection 3D -> 2D
3894+ $t_proj = t_projective(
3895+ src => pdl('1 1 1; -1 1 1; -1 -1 1; 1 -1 1; 2 2 2; -2 -2 2'),
3896+ dst => pdl('0 1000; 1000 1000; 1000 0; 0 0; 0 1000; 1000 0'),
3897+ );
3898+
38913899You can specify your projective transformation directly in homogeneous
38923900coordinates, or (as of 2.104, not just in 2 dimensions) as a set
3893- of C<ncoords + 2> unique points that
3901+ of unique points that
38943902are mapped one to the other by the transformation.
38953903
38963904Projective transforms are quasi-linear because they are most easily
@@ -3936,8 +3944,7 @@ For example, specifying
39363944maps the origin and the point (0,1) to themselves, the point (5,9)
39373945to (5,8), and the point (9,4) to (9,3).
39383946
3939- Added in 2.104. Works on any number of dimensions, the same for
3940- C<src> and C<dst> (a homography).
3947+ Added in 2.104. Works on any number of dimensions.
39413948
39423949=item p, point, points, Points
39433950
@@ -4007,9 +4014,7 @@ sub solve_DLT {
40074014 my ($A, $T_src, $T_dst) = @_;
40084015 my ($U, $S, $V) = svd($A, 1); # full SVD
40094016 my $P_norm = $V->slice(-1)->reshape(map $_->dim(0), $T_src, $T_dst); # reshape smallest singular value vector
4010- my $P = $T_dst->inv x $P_norm x $T_src; # Denormalize
4011- my $div_value = $P->slice(($T_dst->dim(0)-1) x 2); # scaling for numerical stability
4012- $P / $div_value;
4017+ $T_dst->inv x $P_norm x $T_src; # Denormalize
40134018}
40144019
40154020sub t_projective {
0 commit comments