Normal vectors visualization problem

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

Normal vectors visualization problem

Guner Orhan
Hi,

After creating boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer, I have added the point cloud to the visualizer using the following code:

        viewer->setBackgroundColor(0.0, 0.0, 0.0);
        pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA> rgb(output);
        viewer->addPointCloud<pcl::PointXYZRGBA> (output, rgb, "cloud");

        viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");

        viewer->addCoordinateSystem (0.5);

        viewer->initCameraParameters ();

After some filtering and segmentation operations (viewer is spinning during this filtering and segmentation processes), I compute the normal vectors using the following code:
       pcl::PointCloud<pcl::Normal>::Ptr output(new pcl::PointCloud<pcl::Normal>);

        pcl::search::KdTree<pcl::PointXYZRGBA>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZRGBA>);
        pcl::NormalEstimation<pcl::PointXYZRGBA, pcl::Normal> ne;

        ne.setInputCloud(cloud->makeShared());
        ne.setSearchMethod(tree);

        ne.setRadiusSearch(0.02);
        ne.setViewPoint(0.0, -0.6, 0.6);
        ne.compute(*output);

When I use the following code in order to add the normal vectors to the visualizer, no normal vector appears. It does not give any warning or error, and also addPointCloudNormals method returns true.

        viewer->addPointCloudNormals<pcl::PointXYZRGBA, pcl::Normal>(cloud, normals, 10, 0.1, pid, viewport);

Therefore, I thought that there can be some problems related with the computed normal vectors. I tested my normal vectors by adding lines to the visualizer using computed normal vectors cloud. However, the added lines seem to be good representation of normal vectors.

Am I missing something?

Thanks,

Guner
Reply | Threaded
Open this post in threaded view
|

Re: Normal vectors visualization problem

Radu B. Rusu
Administrator
Are there NaNs in your normals? That might be the first thing to try to filter. If not, please take a look at the
pcd_viewer.cpp code to see what is a correct way to add normals to the viewer.

Cheers,
Radu.
--
http://openperception.org

On 06/10/2013 04:18 AM, Guner Orhan wrote:

> Hi,
>
> After creating boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer,
> I have added the point cloud to the visualizer using the following code:
>
>          viewer->setBackgroundColor(0.0, 0.0, 0.0);
> pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA>
> rgb(output);
> viewer->addPointCloud<pcl::PointXYZRGBA> (output, rgb, "cloud");
>
> viewer->setPointCloudRenderingProperties
> (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
>
> viewer->addCoordinateSystem (0.5);
>
> viewer->initCameraParameters ();
>
> After some filtering and segmentation operations (viewer is spinning during
> this filtering and segmentation processes), I compute the normal vectors
> using the following code:
>         pcl::PointCloud<pcl::Normal>::Ptr output(new
> pcl::PointCloud<pcl::Normal>);
>
>          pcl::search::KdTree<pcl::PointXYZRGBA>::Ptr tree(new
> pcl::search::KdTree<pcl::PointXYZRGBA>);
> pcl::NormalEstimation<pcl::PointXYZRGBA, pcl::Normal> ne;
>
> ne.setInputCloud(cloud->makeShared());
> ne.setSearchMethod(tree);
>
> ne.setRadiusSearch(0.02);
> ne.setViewPoint(0.0, -0.6, 0.6);
> ne.compute(*output);
>
> When I use the following code in order to add the normal vectors to the
> visualizer, no normal vector appears. It does not give any warning or error,
> and also addPointCloudNormals method returns true.
>
>          viewer->addPointCloudNormals<pcl::PointXYZRGBA, pcl::Normal>(cloud,
> normals, 10, 0.1, pid, viewport);
>
> Therefore, I thought that there can be some problems related with the
> computed normal vectors. I tested my normal vectors by adding lines to the
> visualizer using computed normal vectors cloud. However, the added lines
> seem to be good representation of normal vectors.
>
> Am I missing something?
>
> Thanks,
>
> Guner
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Normal-vectors-visualization-problem-tp4028177.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [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: Normal vectors visualization problem

Guner Orhan
Thank you for your reply,

Before adding pointcloud to the PCLVisualizer, I have already used the pcl::removeNaNFromPointCloud method. Sorry for not mentioning this before.

When I start to push some keys while viewer spinning after adding normal vectors to it, something strange happened. When "p" key is pressed, the normal vectors become visible, so I think that there could be some rendering problem, and then, I start to look some methods which does the same job with "p" key. I found setRepresentationToPointsForAllActors() method inside pcl::visualization::PCLVisualizer class. However, when I use it, normal vectors again does not appear on viewer.

After that, I looked at the method implementation of pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown() function in interactor_style.cpp file, and pcl::visualization::PCLVisualizer::setRepresentationToPointsForAllActors() method in pcl_visualizer.cpp file. I think, they nearly do the same job if we push "p" key or use the setRepresentationToPointsForAllActors() method. However, they have different implementation.

Up to here, I have mentioned these, because I think, you want to know. Nevertheless, the solution came from your advice.

As you have said, I looked at the pcd_viewer.cpp code, I have added the following line after adding normals.

        viewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 1.0, 1.0, "normals");

Miraculously, all normal vectors become visible.

Thank you, again for your support and kind reply.

Guner

Radu B. Rusu wrote
Are there NaNs in your normals? That might be the first thing to try to filter. If not, please take a look at the
pcd_viewer.cpp code to see what is a correct way to add normals to the viewer.

Cheers,
Radu.
--
http://openperception.org

On 06/10/2013 04:18 AM, Guner Orhan wrote:
> Hi,
>
> After creating boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer,
> I have added the point cloud to the visualizer using the following code:
>
>          viewer->setBackgroundColor(0.0, 0.0, 0.0);
> pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGBA>
> rgb(output);
> viewer->addPointCloud<pcl::PointXYZRGBA> (output, rgb, "cloud");
>
> viewer->setPointCloudRenderingProperties
> (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
>
> viewer->addCoordinateSystem (0.5);
>
> viewer->initCameraParameters ();
>
> After some filtering and segmentation operations (viewer is spinning during
> this filtering and segmentation processes), I compute the normal vectors
> using the following code:
>         pcl::PointCloud<pcl::Normal>::Ptr output(new
> pcl::PointCloud<pcl::Normal>);
>
>          pcl::search::KdTree<pcl::PointXYZRGBA>::Ptr tree(new
> pcl::search::KdTree<pcl::PointXYZRGBA>);
> pcl::NormalEstimation<pcl::PointXYZRGBA, pcl::Normal> ne;
>
> ne.setInputCloud(cloud->makeShared());
> ne.setSearchMethod(tree);
>
> ne.setRadiusSearch(0.02);
> ne.setViewPoint(0.0, -0.6, 0.6);
> ne.compute(*output);
>
> When I use the following code in order to add the normal vectors to the
> visualizer, no normal vector appears. It does not give any warning or error,
> and also addPointCloudNormals method returns true.
>
>          viewer->addPointCloudNormals<pcl::PointXYZRGBA, pcl::Normal>(cloud,
> normals, 10, 0.1, pid, viewport);
>
> Therefore, I thought that there can be some problems related with the
> computed normal vectors. I tested my normal vectors by adding lines to the
> visualizer using computed normal vectors cloud. However, the added lines
> seem to be good representation of normal vectors.
>
> Am I missing something?
>
> Thanks,
>
> Guner
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Normal-vectors-visualization-problem-tp4028177.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [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: Normal vectors visualization problem

Radu B. Rusu
Administrator
Guner,

Glad things worked out :)

Cheers,
Radu.
--
http://openperception.org

On 06/11/2013 10:52 AM, Guner Orhan wrote:

> Thank you for your reply,
>
> Before adding pointcloud to the PCLVisualizer, I have already used the
> pcl::removeNaNFromPointCloud method. Sorry for not mentioning this before.
>
> When I start to push some keys while viewer spinning after adding normal
> vectors to it, something strange happened. When "p" key is pressed, the
> normal vectors become visible, so I think that there could be some rendering
> problem, and then, I start to look some methods which does the same job with
> "p" key. I found setRepresentationToPointsForAllActors() method inside
> pcl::visualization::PCLVisualizer class. However, when I use it, normal
> vectors again does not appear on viewer.
>
> After that, I looked at the method implementation of
> pcl::visualization::PCLVisualizerInteractorStyle::OnKeyDown() function in
> interactor_style.cpp file, and
> pcl::visualization::PCLVisualizer::setRepresentationToPointsForAllActors()
> method in pcl_visualizer.cpp file. I think, they nearly do the same job if
> we push "p" key or use the setRepresentationToPointsForAllActors() method.
> However, they have different implementation.
>
> Up to here, I have mentioned these, because I think, you want to know.
> Nevertheless, the solution came from your advice.
>
> As you have said, I looked at the pcd_viewer.cpp code, I have added the
> following line after adding normals.
>
>          viewer->setPointCloudRenderingProperties
> (pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 1.0, 1.0, "normals");
>
> Miraculously, all normal vectors become visible.
>
> Thank you, again for your support and kind reply.
>
> Guner
>
>
> Radu B. Rusu wrote
>> Are there NaNs in your normals? That might be the first thing to try to
>> filter. If not, please take a look at the
>> pcd_viewer.cpp code to see what is a correct way to add normals to the
>> viewer.
>>
>> Cheers,
>> Radu.
>> --
>> http://openperception.org
>>
>> On 06/10/2013 04:18 AM, Guner Orhan wrote:
>>> Hi,
>>>
>>> After creating boost::shared_ptr
>> <pcl::visualization::PCLVisualizer>
>>   viewer,
>>> I have added the point cloud to the visualizer using the following code:
>>>
>>>           viewer->setBackgroundColor(0.0, 0.0, 0.0);
>>> pcl::visualization::PointCloudColorHandlerRGBField
>> <pcl::PointXYZRGBA>
>>> rgb(output);
>>> viewer->addPointCloud
>> <pcl::PointXYZRGBA>
>>   (output, rgb, "cloud");
>>>
>>> viewer->setPointCloudRenderingProperties
>>> (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 3, "cloud");
>>>
>>> viewer->addCoordinateSystem (0.5);
>>>
>>> viewer->initCameraParameters ();
>>>
>>> After some filtering and segmentation operations (viewer is spinning
>>> during
>>> this filtering and segmentation processes), I compute the normal vectors
>>> using the following code:
>>>          pcl::PointCloud
>> <pcl::Normal>
>> ::Ptr output(new
>>> pcl::PointCloud
>> <pcl::Normal>
>> );
>>>
>>>           pcl::search::KdTree
>> <pcl::PointXYZRGBA>
>> ::Ptr tree(new
>>> pcl::search::KdTree
>> <pcl::PointXYZRGBA>
>> );
>>> pcl::NormalEstimation&lt;pcl::PointXYZRGBA, pcl::Normal&gt; ne;
>>>
>>> ne.setInputCloud(cloud->makeShared());
>>> ne.setSearchMethod(tree);
>>>
>>> ne.setRadiusSearch(0.02);
>>> ne.setViewPoint(0.0, -0.6, 0.6);
>>> ne.compute(*output);
>>>
>>> When I use the following code in order to add the normal vectors to the
>>> visualizer, no normal vector appears. It does not give any warning or
>>> error,
>>> and also addPointCloudNormals method returns true.
>>>
>>>           viewer->addPointCloudNormals&lt;pcl::PointXYZRGBA,
>>> pcl::Normal&gt;(cloud,
>>> normals, 10, 0.1, pid, viewport);
>>>
>>> Therefore, I thought that there can be some problems related with the
>>> computed normal vectors. I tested my normal vectors by adding lines to
>>> the
>>> visualizer using computed normal vectors cloud. However, the added lines
>>> seem to be good representation of normal vectors.
>>>
>>> Am I missing something?
>>>
>>> Thanks,
>>>
>>> Guner
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.pcl-users.org/Normal-vectors-visualization-problem-tp4028177.html
>>> Sent from the Point Cloud Library (PCL) Users mailing list mailing list
>>> archive at Nabble.com.
>>> _______________________________________________
>>>
>
>> PCL-users@
>
>>   / http://pointclouds.org
>>> http://pointclouds.org/mailman/listinfo/pcl-users
>>>
>> _______________________________________________
>
>> PCL-users@
>
>>   / http://pointclouds.org
>> http://pointclouds.org/mailman/listinfo/pcl-users
>
>
>
>
>
> --
> View this message in context: http://www.pcl-users.org/Normal-vectors-visualization-problem-tp4028177p4028204.html
> Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
> _______________________________________________
> [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: Normal vectors visualization problem

samer
Hello all,

I tried to draw the normals on point cloud but this error shows up to me , please have a look to the photo




Kind regards,
Samer
Reply | Threaded
Open this post in threaded view
|

Re: Normal vectors visualization problem

MechanicalMonk

Is normals a pointer (::Ptr) perchance?
Also the screenshot isn't very useful as most of the error gets cut. Better to paste code/error at some text sharing site and link it.

Jari

On Jul 12, 2016 7:06 AM, "samer" <[hidden email]> wrote:
Hello all,

I tried to draw the normals on point cloud but this error shows up to me ,
please have a look to the photo

<http://www.pcl-users.org/file/n4042285/DrawNormalsOfCloudPoints.png>


Kind regards,
Samer



--
View this message in context: http://www.pcl-users.org/Normal-vectors-visualization-problem-tp4028177p4042285.html
Sent from the Point Cloud Library (PCL) Users mailing list mailing list archive at Nabble.com.
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

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