XYZ Data to Mat

asked 2018-06-14 02:26:41 -0500

iwga gravatar image

Hi,

i have a 3D picture, with x,y,z data for each point in a struct. Now i want to save this data into a Mat. But don't know how.

Mat depthimage
depthimage.create(data->with, data->height),CV_32F...) // do I need 3 channels for xyz  or is that only for RGB values ? 

int c = 0;
for( int y; y< depthimage.rows, y++)
{...

for(int x; x< depthimage.cols; x++, c++)
{
auto currentpoint = data->points.at(c);
//Here i have to fill the matrix, i think, but how? I only see examples for 2D matrizes
...
}}

I want a 3D PointCloud

edit retag flag offensive close merge delete

Comments

it's unclear, what kind of data you have, so far, please show that.

what are you trying to do later with that ? (e.g. for PCL, you would use their Pointcloud struct, not a Mat)

berak gravatar imageberak ( 2018-06-14 04:32:20 -0500 )edit

Well at least i can answer one of the comment from the source code : // do I need 3 channels for xyz or is that only for RGB values ? Yes these are for the rgb values only

Maybe a stupid idea - could you represent the depth via a vector or something? Sorry - i am still very new to computer vision conceps.

holger gravatar imageholger ( 2018-06-14 04:45:53 -0500 )edit

@holger: bw depth images are usually just a visualization of the z component(1 channel only). coloured depth images are mostly done by converting this channel back to CV_8U, and applying some color_map (LUT) . the result of that is indeed bgr, 3 channels.

berak gravatar imageberak ( 2018-06-14 08:42:12 -0500 )edit

oh well - still have much to learn i guess XD

holger gravatar imageholger ( 2018-06-14 10:38:06 -0500 )edit