Point cloud extraction depending on normal direction

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

Point cloud extraction depending on normal direction

benoit duinat
Hi,

In a given point cloud, I would like to extract only the points with normals pointing upward (or close to pointing upward).
I'm a bit stuck with the normal estimation (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
Any help ?

Benoit

--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

lasdasdas

Hi,

You might be able to access the data like this

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (size_t i = 0; i < cloud->points.size (); ++i)
  {
    cloud->points[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

From here


Also look at this thread, idk how effective is to look at the direction of the normals since you might have some of them "flipped"




On 11/28/2017 04:32 PM, benoit duinat wrote:
Hi,

In a given point cloud, I would like to extract only the points with normals pointing upward (or close to pointing upward).
I'm a bit stuck with the normal estimation (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
Any help ?

Benoit

--
Duinat Benoit
+14184736970

[hidden email]


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


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

Sérgio Agostinho
Hey


On 28-11-2017 21:45, David wrote:

>
> Hi,
>
> You might be able to access the data like this
>
>   pcl::PointCloud<pcl::Normal>::Ptr cloud (new
> pcl::PointCloud<pcl::Normal>);
>
>   // Fill in the cloud data
>   cloud->width  = 5;
>   cloud->height = 1;
>   cloud->points.resize (cloud->width * cloud->height);
>
>   for (size_t i = 0; i < cloud->points.size (); ++i)
>   {
>     cloud->points[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
>   }
>
There's a (yet to have, past discussion) about closing access to the
internal members of points clouds. So start writing your code likes
(check below) from now on. It does exactly the same and it will save you
some potential deprecation warnings down the road.

   pcl::PointCloud<pcl::Normal>::Ptr cloud (new
pcl::PointCloud<pcl::Normal>);

   // Fill in the cloud data
   cloud->resize (5);

   for (size_t i = 0; i < cloud->size (); ++i)
   {
     (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
   }


> On 11/28/2017 04:32 PM, benoit duinat wrote:
>> Hi,
>>
>> In a given point cloud, I would like to extract only the points with
>> normals pointing upward (or close to pointing upward).
>> I'm a bit stuck with the normal estimation
>> (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
>> Any help ?
>>
What exactly are you stuck on?


Cheers
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
I don't get the lines:
  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

What does this exactly do ?

My function right now following the example:

int NormalEstimationFunct(PointCloud<PointXYZ>::Ptr cloud)
{
std::cout << "Start Normal Estimation.\n\n";
  // Create the normal estimation class, and pass the input dataset to it
       pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
       ne.setInputCloud (cloud);

  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
       pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
       ne.setSearchMethod (tree);

  // Output datasets
       pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);

  // Use all neighbors in a sphere of radius 3cm
      ne.setRadiusSearch (0.03);

  // Compute the features
      ne.compute (*cloud_normals);

std::cerr << "Normal Estimation: " << std::endl;
for (size_t i = 0; i < cloud_normals->points.size (); ++i){
std::cerr << "    " << cloud_normals->points[i].normal[0]  << " "
<< cloud_normals->points[i].normal[1] << " "
<< cloud_normals->points[i].normal[2] << std::endl;
}
std::cout << "Fin Normal Estimation\n\n";

return(0);
}




On Tue, Nov 28, 2017 at 6:23 PM, Sérgio Agostinho <[hidden email]> wrote:
Hey


On 28-11-2017 21:45, David wrote:

Hi,

You might be able to access the data like this

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (size_t i = 0; i < cloud->points.size (); ++i)
  {
    cloud->points[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

There's a (yet to have, past discussion) about closing access to the internal members of points clouds. So start writing your code likes (check below) from now on. It does exactly the same and it will save you some potential deprecation warnings down the road.

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->resize (5);

  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }


On 11/28/2017 04:32 PM, benoit duinat wrote:
Hi,

In a given point cloud, I would like to extract only the points with normals pointing upward (or close to pointing upward).
I'm a bit stuck with the normal estimation (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
Any help ?

What exactly are you stuck on?


Cheers



--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
I managed to calculate the normals, but I'm a bit confused about the value 
cloud_normals->points[i].normal[0] 
cloud_normals->points[i].normal[1] 
cloud_normals->points[i].normal[2] 

What would be the value of a Normal pointing to the upward direction ?

On Wed, Nov 29, 2017 at 3:54 PM, benoit duinat <[hidden email]> wrote:
I don't get the lines:
  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

What does this exactly do ?

My function right now following the example:

int NormalEstimationFunct(PointCloud<PointXYZ>::Ptr cloud)
{
std::cout << "Start Normal Estimation.\n\n";
  // Create the normal estimation class, and pass the input dataset to it
       pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
       ne.setInputCloud (cloud);

  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
       pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
       ne.setSearchMethod (tree);

  // Output datasets
       pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);

  // Use all neighbors in a sphere of radius 3cm
      ne.setRadiusSearch (0.03);

  // Compute the features
      ne.compute (*cloud_normals);

std::cerr << "Normal Estimation: " << std::endl;
for (size_t i = 0; i < cloud_normals->points.size (); ++i){
std::cerr << "    " << cloud_normals->points[i].normal[0]  << " "
<< cloud_normals->points[i].normal[1] << " "
<< cloud_normals->points[i].normal[2] << std::endl;
}
std::cout << "Fin Normal Estimation\n\n";

return(0);
}




On Tue, Nov 28, 2017 at 6:23 PM, Sérgio Agostinho <[hidden email]> wrote:
Hey


On 28-11-2017 21:45, David wrote:

Hi,

You might be able to access the data like this

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (size_t i = 0; i < cloud->points.size (); ++i)
  {
    cloud->points[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

There's a (yet to have, past discussion) about closing access to the internal members of points clouds. So start writing your code likes (check below) from now on. It does exactly the same and it will save you some potential deprecation warnings down the road.

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->resize (5);

  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }


On 11/28/2017 04:32 PM, benoit duinat wrote:
Hi,

In a given point cloud, I would like to extract only the points with normals pointing upward (or close to pointing upward).
I'm a bit stuck with the normal estimation (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
Any help ?

What exactly are you stuck on?


Cheers



--
Duinat Benoit
<a href="tel:(418)%20473-6970" value="+14184736970" target="_blank">+14184736970

[hidden email]



--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

lasdasdas

Sorry, yes. The normal data is not stored in data_c but in data_n.

Normal - float normal[3], curvature;

One of the other most used data types, the Normal structure represents the surface normal at a given point, and a measure of curvature (which is obtained in the same call as a relationship between the eigenvalues of a surface patch – see the NormalEstimation class API for more information).Because operation on surface normals are quite common in PCL, we pad the 3 components with a fourth one, in order to be SSE-aligned and computationally efficient. The user can either access points[i].data_n[0] or points[i].normal[0] or points[i].normal_x for accessing say, the first coordinate of the normal vector. Again, curvature cannot be stored in the same structure as it would be overwritten by operations on the normal data.

A regular normal upward normal would be 0,0,1 for a group of points in the XY plane for example. If I run this test with random points in the (0,1) range on the X and Y values and Z=0 (i.e. the Z=0 plane) I get always normals like 0,0,1 which make sense.

#include <pcl/point_types.h>
#include <pcl/features/normal_3d.h>
using namespace pcl;

int NormalEstimationFunct(PointCloud<PointXYZ>::Ptr cloud)
{
    std::cout << "Start Normal Estimation.\n\n";
  // Create the normal estimation class, and pass the input dataset to it
       pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
       ne.setInputCloud (cloud);

  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
       pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
       ne.setSearchMethod (tree);

  // Output datasets
       pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);

  // Use all neighbors in a sphere of radius 3cm
      ne.setRadiusSearch (0.03);

  // Compute the features
      ne.compute (*cloud_normals);

    std::cerr << "Normal Estimation: " << std::endl;
    for (size_t i = 0; i < cloud_normals->points.size (); ++i){
        std::cerr << "    " << cloud_normals->points[i].normal[0]  << " "
        << cloud_normals->points[i].normal[1] << " "
        << cloud_normals->points[i].normal[2] << std::endl;

    std::cout << "Fin Normal Estimation\n\n";

    return(0);
}


int main(){
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
    for (int i = 0; i < 10000; i++) {
        pcl::PointXYZ p;
        p.x = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
        p.y = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
        p.z = 0;
        cloud->push_back(p);
    }
    NormalEstimationFunct(cloud);
}

Perhaps your search radius is too small (specially if you are dealing with sparse clouds)?

NormalEstimation must find neighbors in order to find a proper normal.



On 11/29/2017 11:03 PM, benoit duinat wrote:
I managed to calculate the normals, but I'm a bit confused about the value 
cloud_normals->points[i].normal[0] 
cloud_normals->points[i].normal[1] 
cloud_normals->points[i].normal[2] 

What would be the value of a Normal pointing to the upward direction ?

On Wed, Nov 29, 2017 at 3:54 PM, benoit duinat <[hidden email]> wrote:
I don't get the lines:
  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

What does this exactly do ?

My function right now following the example:

int NormalEstimationFunct(PointCloud<PointXYZ>::Ptr cloud)
{
std::cout << "Start Normal Estimation.\n\n";
  // Create the normal estimation class, and pass the input dataset to it
       pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> ne;
       ne.setInputCloud (cloud);

  // Create an empty kdtree representation, and pass it to the normal estimation object.
  // Its content will be filled inside the object, based on the given input dataset (as no other search surface is given).
       pcl::search::KdTree<pcl::PointXYZ>::Ptr tree (new pcl::search::KdTree<pcl::PointXYZ> ());
       ne.setSearchMethod (tree);

  // Output datasets
       pcl::PointCloud<pcl::Normal>::Ptr cloud_normals (new pcl::PointCloud<pcl::Normal>);

  // Use all neighbors in a sphere of radius 3cm
      ne.setRadiusSearch (0.03);

  // Compute the features
      ne.compute (*cloud_normals);

std::cerr << "Normal Estimation: " << std::endl;
for (size_t i = 0; i < cloud_normals->points.size (); ++i){
std::cerr << "    " << cloud_normals->points[i].normal[0]  << " "
<< cloud_normals->points[i].normal[1] << " "
<< cloud_normals->points[i].normal[2] << std::endl;
}
std::cout << "Fin Normal Estimation\n\n";

return(0);
}




On Tue, Nov 28, 2017 at 6:23 PM, Sérgio Agostinho <[hidden email]> wrote:
Hey


On 28-11-2017 21:45, David wrote:

Hi,

You might be able to access the data like this

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (size_t i = 0; i < cloud->points.size (); ++i)
  {
    cloud->points[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }

There's a (yet to have, past discussion) about closing access to the internal members of points clouds. So start writing your code likes (check below) from now on. It does exactly the same and it will save you some potential deprecation warnings down the road.

  pcl::PointCloud<pcl::Normal>::Ptr cloud (new pcl::PointCloud<pcl::Normal>);

  // Fill in the cloud data
  cloud->resize (5);

  for (size_t i = 0; i < cloud->size (); ++i)
  {
    (*cloud)[i].data_c[0]  = 1024 * rand () / (RAND_MAX + 1.0f);
  }


On 11/28/2017 04:32 PM, benoit duinat wrote:
Hi,

In a given point cloud, I would like to extract only the points with normals pointing upward (or close to pointing upward).
I'm a bit stuck with the normal estimation (http://pointclouds.org/documentation/tutorials/normal_estimation.php)
Any help ?

What exactly are you stuck on?


Cheers



--
Duinat Benoit
<a href="tel:%28418%29%20473-6970" value="+14184736970" target="_blank" moz-do-not-send="true">+14184736970

[hidden email]



--
Duinat Benoit
+14184736970

[hidden email]


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


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

Sérgio Agostinho
In reply to this post by benoit duinat



On 29-11-2017 22:03, benoit duinat wrote:
I managed to calculate the normals, but I'm a bit confused about the value 
cloud_normals->points[i].normal[0] 
cloud_normals->points[i].normal[1] 
cloud_normals->points[i].normal[2] 

What would be the value of a Normal pointing to the upward direction ?

That depends entirely on your frame of reference. If for you z is a vertical coordinate, then normals close to [0, 0, a]^T with a > 0 are considered upwards.


_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
Thanks for the answers, it make sense ! The radius was the problem indeed, and the upward Normal in my case is 0,0,-1.

It works now.

On Wed, Nov 29, 2017 at 6:06 PM, Sérgio Agostinho <[hidden email]> wrote:



On 29-11-2017 22:03, benoit duinat wrote:
I managed to calculate the normals, but I'm a bit confused about the value 
cloud_normals->points[i].normal[0] 
cloud_normals->points[i].normal[1] 
cloud_normals->points[i].normal[2] 

What would be the value of a Normal pointing to the upward direction ?

That depends entirely on your frame of reference. If for you z is a vertical coordinate, then normals close to [0, 0, a]^T with a > 0 are considered upwards.


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




--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
Last thing, I can't change the colour of the point of my XYZRGB Point Cloud, any clue of what's wrong 
Just want to color the points with upward normals.

int NormalEstimationFunct2(PointCloud<PointXYZI>::Ptr cloud)
{

PointCloud<PointXYZRGB>::Ptr cloud_normalUp (new PointCloud<PointXYZRGB>);
cloud_normalUp->points.resize(cloud->points.size());

std::cout << "Début normal estimator." << std::endl;
search::Search<PointXYZI>::Ptr tree = boost::shared_ptr<search::Search<PointXYZI> > (new search::KdTree<PointXYZI>);
PointCloud <Normal>::Ptr normals (new PointCloud <Normal>);
NormalEstimation<PointXYZI, Normal> normal_estimator;
normal_estimator.setSearchMethod (tree);
normal_estimator.setInputCloud (cloud);
normal_estimator.setKSearch (50);
normal_estimator.compute (*normals);
std::cout << "Fin normal estimator." << std::endl;
for (size_t i = 0; i < normals->points.size (); ++i){

cloud_normalUp->points[i].x = cloud->points[i].x;
cloud_normalUp->points[i].y = cloud->points[i].y;
cloud_normalUp->points[i].z = cloud->points[i].z;
if(normals->points[i].normal[0]>-0.1&&normals->points[i].normal[0]<0.1&&normals->points[i].normal[1]>-0.1&&normals->points[i].normal[1]<0.1&&normals->points[i].normal[2]>-1.02&&normals->points[i].normal[2]<-0.98){
cloud_normalUp->points[i].r=255;
cloud_normalUp->points[i].g=0;
cloud_normalUp->points[i].b=0;
}
else{
cloud_normalUp->points[i].r=0;
cloud_normalUp->points[i].g=255;
cloud_normalUp->points[i].b=0;
}
}
cloud_normalUp->width = 1;
cloud_normalUp->height = cloud_normalUp->points.size();
pcl::io::savePCDFileASCII ("NormUpRGB.pcd", *cloud_normalUp);
return(0);
}

On Wed, Nov 29, 2017 at 6:12 PM, benoit duinat <[hidden email]> wrote:
Thanks for the answers, it make sense ! The radius was the problem indeed, and the upward Normal in my case is 0,0,-1.

It works now.

On Wed, Nov 29, 2017 at 6:06 PM, Sérgio Agostinho <[hidden email]> wrote:



On 29-11-2017 22:03, benoit duinat wrote:
I managed to calculate the normals, but I'm a bit confused about the value 
cloud_normals->points[i].normal[0] 
cloud_normals->points[i].normal[1] 
cloud_normals->points[i].normal[2] 

What would be the value of a Normal pointing to the upward direction ?

That depends entirely on your frame of reference. If for you z is a vertical coordinate, then normals close to [0, 0, a]^T with a > 0 are considered upwards.


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




--
Duinat Benoit
<a href="tel:(418)%20473-6970" value="+14184736970" target="_blank">+14184736970

[hidden email]



--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

Sérgio Agostinho
What exactly are you getting in your pcd file?
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
A point cloud with (0,0,0) Color Values

And if I try to display 
std::cout << "Point Value:"<< cloud_normalUp->points[12].r<< std::endl;
I got:
 Point Value: ?

On Thu, Nov 30, 2017 at 3:17 PM, Sérgio Agostinho <[hidden email]> wrote:
What exactly are you getting in your pcd file?



--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

benoit duinat
With 
std::cout << "Point Value:"<< (int)cloud_normalUp->points[12].r<< std::endl;
I got the R value = 255, the problem seems to be with the generation of .pcd
Like said in this link, I'm with PCL 1.8


On Thu, Nov 30, 2017 at 3:35 PM, benoit duinat <[hidden email]> wrote:
A point cloud with (0,0,0) Color Values

And if I try to display 
std::cout << "Point Value:"<< cloud_normalUp->points[12].r<< std::endl;
I got:
 Point Value: ?

On Thu, Nov 30, 2017 at 3:17 PM, Sérgio Agostinho <[hidden email]> wrote:
What exactly are you getting in your pcd file?



--
Duinat Benoit
<a href="tel:(418)%20473-6970" value="+14184736970" target="_blank">+14184736970

[hidden email]



--
Duinat Benoit
+14184736970

[hidden email]

_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Point cloud extraction depending on normal direction

Sérgio Agostinho
Saving color in a pcd has been one of the features which has been used since the early beginnings. It would be surprising if a bug popped up on that one I must say.

Nevertheless give it a try to the current development version. See if you get the same problem.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

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

Re: Point cloud extraction depending on normal direction

benoit duinat
I didn't manage to resolve my issue

int TestColor()
{
pcl::PointCloud<pcl::PointXYZRGB> cloud;
pcl::PointXYZRGBA point;
uint8_t r = 255;
uint8_t g = 0;
uint8_t b = 0;
int32_t rgb = (r << 16) | (g << 8) | b;

 // Fill in the cloud data
 cloud.width    = 100;
 cloud.height   = 1;
 cloud.is_dense = false;
 cloud.points.resize (cloud.width * cloud.height);

 for (size_t i = 0; i < cloud.points.size (); ++i)
 {
   cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
   cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
   cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
cloud.points[i].rgb = *(float *)(&rgb);


 }

 pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
 std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

 for (size_t i = 0; i < cloud.points.size (); ++i)
   std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << " " << (int)cloud.points[i].r<< std::endl;

 return (0);
}


This give me correct value : 

Saved 100 data points to test_pcd.pcd.

    0.0080142 0.694695 -0.26015 255

    -0.342265 -0.446349 0.214207 255

    0.173687 -0.84253 -0.400481 255

    -0.874475 0.706127 -0.117635 255

...


But when I open test_pcd.pcd, I got (0,0,0)


On Thu, Nov 30, 2017 at 4:17 PM, Sérgio Agostinho <[hidden email]> wrote:
Saving color in a pcd has been one of the features which has been used since the early beginnings. It would be surprising if a bug popped up on that one I must say.

Nevertheless give it a try to the current development version. See if you get the same problem.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users




--
Duinat Benoit
+14184736970

[hidden email]

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

Sans titre.png (65K) Download Attachment