RGB Cloud

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

RGB Cloud

lucasamparo
I need to load a texture from a png image (Bosphorus dataset)...

i'm using this code

cloud.points[i].x = r->points[i].x;
cloud.points[i].y = r->points[i].y;
cloud.points[i].z = r->points[i].z;
cv::Vec3b v = m.at<cv::Vec3b>(r->pixels[i].y,r->pixels[i].x);
uint32_t rgb = ((uint32_t)v[2] << 16 | (uint32_t)v[1] << 8 | (uint32_t)v[0]);
cloud.points[i].rgb = rgb;

for each point XYZ i had a correspondent texture value from the PNG imagem.
I dont know why isn't works... when i save my pcd file, the rgb column always has a single value...

Some one can help me?

P.S.: The Vec3b is working... if i show the struct with cout, show the right value... the same to v[i], show the right...

Some one? Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

lucasamparo
i've forgot something... still not working, but more correct then before.

cloud.points[i].x = r->points[i].x;
cloud.points[i].y = r->points[i].y;
cloud.points[i].z = r->points[i].z;
cv::Vec3b v = m.at<cv::Vec3b>(r->pixels[i].y,r->pixels[i].x);
uint8_t r = *v.val[2], g = *v.val[1], b = *v.val[0];
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b);
cloud.points[i].rgb = *reinterpret_cast<float*>(&rgb);
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

Sérgio Agostinho
There’s some inconsistent behaviour when it comes use RGB only, in some of the library's functions. It happens because of the way NaN’s are defined in float types, in conjunction with the fact that we pack the alpha component on the MSB part of the color, and we set it by default to 255.

Switch to RGBA if possible. In terms of storage it occupies the same memory footprint and it’s in general better handled.

Cheers


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

Sérgio Agostinho
It goes without saying, that if you feel like debugging the issue properly, and manage to find an issue in the lib, just file a PR.

Cheers
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

lucasamparo
In reply to this post by Sérgio Agostinho
Sérgio, i will try this
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

lucasamparo
In reply to this post by Sérgio Agostinho
cv::Vec3b v = m.at<cv::Vec3b>(r->pixels[i].y,r->pixels[i].x);
cloud.points[i].r = (int)v[2];
cloud.points[i].g = (int)v[1];
cloud.points[i].b = (int)v[0];
cloud.points[i].a = 255;

Change the point type (XYZRGBA) and set "a" to 255 always...

The problem still, the same value for all the cloud...

I'm realy concerned about it...
Reply | Threaded
Open this post in threaded view
|

Re: RGB Cloud

lucasamparo
This post was updated on .
In reply to this post by lucasamparo
HAHA

I'm a dummy.

The texture coordinates are a float.
The OpenCV mat index is a int.

So easy...

Holy s***