ROS Point Cloud PreserveStructureOnRead True vs False

1 次查看(过去 30 天)
I am using the RGB and XYZ data from an ROS PointCloud2 to identify white lines and publish them in a point cloud. I read the RGB and XYZ with the PreserveStructureOnRead as true to get a mxnx3 image. I would like to then convert then to a dx3 matrix so I can publish a point cloud to my ROS environment. What is the mapping to a point in the mxnx3 matrix to the dx3? I notice that d = m*n, but do not know how the two relate to each other. In other words, I would like to convert my image from the PreserveStructureOnRead = true for to the PreserveStructureOnRead = false form.
Thank you!

回答(1 个)

Connor Fuhrman
Connor Fuhrman 2018-4-17

I created this function which I believe solves my own issue!

function dx3 = mxnx3_to_dx3(mxnx3)
[height, width, length] = size(mxnx3);
dx3 = zeros(height*width,3);
for i = 1:length
    for j = 1:height
        for k = 1:width
            l = width*(j-1)+k;
            dx3(l,i) = mxnx3(j,k,i);
        end
    end
end
end

类别

Help CenterFile Exchange 中查找有关 Specialized Messages 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by