Why does transforming with affine3D yield different result than multiplying with transfomation matrix?

1 次查看(过去 30 天)
Hi,
I am trying to transform a pointcloud with a transformation matrix on a point-per-point basis.
In the following script I run a pctransform which does indeed shift the pointcloud over a unit of 1.
However, when applying the same transformation matrix on a point per point basis, I dont see any difference in the resulting point cloud.
I cant use pctransform in my final setup since my transformation matrices are non-rigid.
Could anyone point me out what i am doing wrong?
ptCloud1 = pointCloud(rand(10000,3,'single'));
moveRight = [1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
1 0 0 1];
ptCloudRight = pctransform(copy(ptCloud1),affine3d(moveRight));
pcshowpair(ptCloud1,ptCloudRight);
ptCloudRightCreated = pointCloud(transformPoints(copy(ptCloud1), moveRight))
pcshowpair(ptCloud1,ptCloudRightCreated);
function newPoints = transformPoints(ptc, tmatrix)
newPoints = [];
disp(tmatrix)
for i = 1 : ptc.Count
point = [ptc.Location(i,:), 0];
tPoint = point * tmatrix;
newPoints = cat(1, newPoints, tPoint(1:3));
end
end

回答(2 个)

Kin Sung Chan
Kin Sung Chan 2019-11-9
ptCloud = pointCloud(rand(10000,3,'single'));
moveRight = [1 0 0 0; ...
0 1 0 0; ...
0 0 1 0; ...
1 0 0 1];
tform = affine3d(moveRight);
ptCloudRight = pctransform(ptCloud, tform);
figure(1)
pcshowpair(ptCloud, ptCloudRight );
I have no problems translating the point cloud.

Lewis Newton
Lewis Newton 2020-2-27
This appears to have been expanded in the 2019 version, if you check your current help you'll find that it says it must be rigid.
If you update your version, help says this function works for both rigid and non-rigid transforms!

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by