ROS Point Cloud PreserveStructureOnRead True vs False

1 visualizzazione (ultimi 30 giorni)
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!

Risposte (1)

Connor Fuhrman
Connor Fuhrman il 17 Apr 2018

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

Categorie

Scopri di più su Specialized Messages in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by