Sphere Detection in Point Cloud

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

Sphere Detection in Point Cloud

ravijoshi
I have captured a point cloud having a ball mounted on robotic manipulator.
Please see below the screenshot of point cloud-

<http://www.pcl-users.org/file/t499210/input.png>

I want to track the ball (orange color in above screenshot). I first made a
template, which is the point cloud of ball made using following code-

typedef pcl::PointXYZRGB Point;
typedef pcl::PointCloud<Point> PointCloud;
PointCloud sphere;
float r = 0.075; // in meters
for(float phi = 0;  phi < 2* M_PI; phi+=0.01)
{
  float z = r * cos(phi);
  for(float th = 0;  th < M_PI; th+=0.01)
  {
    float x = r * sin(phi) * cos(th);
    float y = r * sin(phi) * sin(th);
    Point point;
    point.x = x; point.y = y; point.z = z;  // position
    point.b = 51; point.g = 87; point.r = 255; // color
    sphere.push_back(point);
  }
}
sphere.is_dense = true;
sphere.height = 1;
sphere.width = sphere.points.size();

The above template is then matched with captured point cloud shown above
using  Sample Consensus Initial Alignment (SAC-IA) algorithm
<http://pointclouds.org/documentation/tutorials/template_alignment.php>  .
Below is the result in which I painted a green sphere in detected location-

<http://www.pcl-users.org/file/t499210/output.png>

The ball detection has failed. My queries are following-
(1) How to make it working? Any fine-tuning of parameters?
(2) Is there any better approach for sphere detection in PCL suitable for
this scenario?

Thanks



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

Re: Sphere Detection in Point Cloud

Stephen McDowell
Foreword: I have no experience with the template matching, I’m only offering high level suggestions on some things that stick out.

1. The matching is not non-existent, it’s just not matching what you want.  Sphere’s in particular present problems like this because they are so “regular”.  The green part of the robot arm is “sphere-like” from that view point.  The tutorial returns a single result in the `findBestAlignment` method.  Instead of returning a single one, return the whole vector.  Then you can just (temporarily) color all of the matches found.  Did the other spheres get detected?

2. Assuming the other spheres got detected, usually those robotic arms have in the hardware a way of calculating where the arm is, where the hand is, etc.  You might be able to use that knowledge (e.g., where the elbow joint is) to reduce the number of false positives.  You’d likely have to be careful around the hand, but it’s also unlikely that the hand will be matched unless it’s forming a clenched fist at the moment.

3. If (1) is not actually working (the spheres you desire are not getting detected at all), try testing your code with a different template.  One of the things you can see in the tutorial is that the template they are matching against is “feature rich”.  It has only half of the face, there’s a chin, there’s a nose, it’s asymmetric, etc.  These kinds of features make the matching much more robust.  Things like a cube or a sphere do not have many distinct features.  So as a sanity check, to make sure your code itself is working, try something a little more complex and see if you can match that?

4. Can you assume the color of the sphere is always this pale orange color?  If so, you should use that to your advantage.  Pre-process the point-cloud and create a reduced point cloud that only has points included that are similar to this color.  Some analogies: green-screens in movie production, wearing a specific color latex glove to speed up hand tracking.  Color based approaches are less general, but if you state your assumptions clearly then they are often more robust.

5. The last thing that comes to mind is to maybe try using a template that is only half of a sphere (just generate a hemisphere).  From any given view point, you will never see more than half of the sphere.  I doubt that will help reducing the false positives, but it would be very easy for you to implement (just slightly modify your existing loop).

As stated at the beginning, I have no experience here, and none of the above may be helpful.  It was a fun problem to think about though :)


> On Feb 1, 2018, at 6:34 PM, ravijoshi <[hidden email]> wrote:
>
> I have captured a point cloud having a ball mounted on robotic manipulator.
> Please see below the screenshot of point cloud-
>
> <http://www.pcl-users.org/file/t499210/input.png>
>
> I want to track the ball (orange color in above screenshot). I first made a
> template, which is the point cloud of ball made using following code-
>
> typedef pcl::PointXYZRGB Point;
> typedef pcl::PointCloud<Point> PointCloud;
> PointCloud sphere;
> float r = 0.075; // in meters
> for(float phi = 0;  phi < 2* M_PI; phi+=0.01)
> {
>  float z = r * cos(phi);
>  for(float th = 0;  th < M_PI; th+=0.01)
>  {
>    float x = r * sin(phi) * cos(th);
>    float y = r * sin(phi) * sin(th);
>    Point point;
>    point.x = x; point.y = y; point.z = z;  // position
>    point.b = 51; point.g = 87; point.r = 255; // color
>    sphere.push_back(point);
>  }
> }
> sphere.is_dense = true;
> sphere.height = 1;
> sphere.width = sphere.points.size();
>
> The above template is then matched with captured point cloud shown above
> using  Sample Consensus Initial Alignment (SAC-IA) algorithm
> <http://pointclouds.org/documentation/tutorials/template_alignment.php>  .
> Below is the result in which I painted a green sphere in detected location-
>
> <http://www.pcl-users.org/file/t499210/output.png>
>
> The ball detection has failed. My queries are following-
> (1) How to make it working? Any fine-tuning of parameters?
> (2) Is there any better approach for sphere detection in PCL suitable for
> this scenario?
>
> Thanks
>
>
>
> --
> Sent from: http://www.pcl-users.org/
> _______________________________________________
> [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: Sphere Detection in Point Cloud

Sérgio Agostinho
In reply to this post by ravijoshi
You might want to have a look at how circle detection is made in OpenCV for camera calibration. 

This is the method
https://docs.opencv.org/3.1.0/d9/d0c/group__calib3d.html#gac8fb88c7652a7699743aeb6073ef9b4a

And the corresponding detector
https://docs.opencv.org/3.1.0/d0/d7a/classcv_1_1SimpleBlobDetector.html#a1d7a06c8b8749207a978e42cd8d0cdf6

Happy digging 


--

On Friday, Feb 02, 2018 at 3:34 AM, ravijoshi <[hidden email]> wrote:
I have captured a point cloud having a ball mounted on robotic manipulator.
Please see below the screenshot of point cloud-

<http://www.pcl-users.org/file/t499210/input.png>

I want to track the ball (orange color in above screenshot). I first made a
template, which is the point cloud of ball made using following code-

typedef pcl::PointXYZRGB Point;
typedef pcl::PointCloud<Point> PointCloud;
PointCloud sphere;
float r = 0.075; // in meters
for(float phi = 0; phi < 2* M_PI; phi+=0.01)
{
float z = r * cos(phi);
for(float th = 0; th < M_PI; th+=0.01)
{
float x = r * sin(phi) * cos(th);
float y = r * sin(phi) * sin(th);
Point point;
point.x = x; point.y = y; point.z = z; // position
point.b = 51; point.g = 87; point.r = 255; // color
sphere.push_back(point);
}
}
sphere.is_dense = true;
sphere.height = 1;
sphere.width = sphere.points.size();

The above template is then matched with captured point cloud shown above
using Sample Consensus Initial Alignment (SAC-IA) algorithm
<http://pointclouds.org/documentation/tutorials/template_alignment.php> .
Below is the result in which I painted a green sphere in detected location-

<http://www.pcl-users.org/file/t499210/output.png>

The ball detection has failed. My queries are following-
(1) How to make it working? Any fine-tuning of parameters?
(2) Is there any better approach for sphere detection in PCL suitable for
this scenario?

Thanks



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

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

signature.asc (882 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Sphere Detection in Point Cloud

ravijoshi
In reply to this post by Stephen McDowell
Thanks, Stephen. I am looking into your suggestions.



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

Re: Sphere Detection in Point Cloud

ravijoshi
In reply to this post by Sérgio Agostinho
Thanks, Sérgio. I read the references. Thank you. But but I am still not able
to implement it in PCL. Can you please explain your idea in detail?



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

Re: Sphere Detection in Point Cloud

ravijoshi
Hi,

While reading the references and ideas, I also searched in PCL documentation
and found Random sample consensus (RANSAC) estimator. Though RANSAC
estimator is shown robust in the documentation, I tried to use it for sphere
detection.

Please see below the screenshot of the point cloud-

<http://www.pcl-users.org/file/t499210/pcd.png>

Below is the corresponding image-

<http://www.pcl-users.org/file/t499210/img.png>

The sphere, having the diameter of 100 mm is located in the center of the
image held by the robotic arm. Below is the code snippet-
--------------------------------------------------------------------------------------
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_raw(new
pcl::PointCloud<pcl::PointXYZRGBA>);
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_seg(new
pcl::PointCloud<pcl::PointXYZRGBA>);

float radius = 0.05; // 100 mm diameter
pcl::io::loadPCDFile("capture.pcd", *cloud_raw);

pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
pcl::SACSegmentation<pcl::PointXYZRGBA> seg;

seg.setOptimizeCoefficients(true);
seg.setModelType(pcl::SACMODEL_SPHERE);
seg.setMethodType(pcl::SAC_RANSAC);
seg.setMaxIterations(10000);
seg.setDistanceThreshold(0.001);
seg.setProbability(0.9999);
seg.setRadiusLimits(radius - 0.05, radius + 0.05); //5 cm tolerance
seg.setInputCloud(cloud_raw);
seg.segment(*inliers, *coefficients);

if (inliers->indices.size() > 0)
    std::cout << coefficients->values[0] << ", " << coefficients->values[1]
<< ", "  << coefficients->values[2] << ", " << coefficients->values[3] <<
std::endl;
--------------------------------------------------------------------------------------

The input PCD file can be downloaded from shared Dropbox
[here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0)
Unfortunately, SAC_RANSAC is unable to detect sphere.

What's wrong here? Any advice, please.

-
Thanks
Ravi



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

Re: Sphere Detection in Point Cloud

Richard Frank
Hi. I have done sphere detection in 3D medical images to find fiducial markers - human placed markers designed to be “bright” objects located within the image and easy to locate. Once found they indicate a relative position, or are used to compute a relative pose of an instrument or device.
This kind of thing is also done in image guided surgery to track surgical instruments.

From what I’ve seen, your robot arm does not have any special markers, and you are trying to locate a spherical joint in the arm. I believe this will not be a simple task, and I wouldn’t expect it to just work with a few lines of code.

In an image processing case, there are a few ways to do it. One straight forward way it to produce  3 edge detection images perpendicular to each other. Then use the hough circle algorithm to find the circles in each image. This gives you the boundaries of the objects circles. Then, you will need to find the centers of these circles ( you will need to use least squares estimation to find the centers) and then correlate the centers to find the spheres described by the 3 circles that belong to the same center.

In your case it seems the sphere is n the space of the arm, prohibiting you from getting a side view however.

Another way is to us principal component analysis for a 2 or 3D circular blob, the 2 (3) largest  principal components should be the same magnitude ( length ) for a sphere.

I’m not sure how easy this would be to replicate in PCL, but in theory I would think something similar would work.

If you are involved in the design of this arm, one way to increase robustness is to add markers specifically designed to help the software track the arm rather than trying to locate an arbitrary part of the arm which could change shape with new designs.





Rick Frank
Dominion Software, Inc.
825 Beacon Street
Newton, MA 02459
Medical, Scientific, and Industrial Software

> On Feb 5, 2018, at 6:38 AM, ravijoshi <[hidden email]> wrote:
>
> Hi,
>
> While reading the references and ideas, I also searched in PCL documentation
> and found Random sample consensus (RANSAC) estimator. Though RANSAC
> estimator is shown robust in the documentation, I tried to use it for sphere
> detection.
>
> Please see below the screenshot of the point cloud-
>
> <http://www.pcl-users.org/file/t499210/pcd.png>
>
> Below is the corresponding image-
>
> <http://www.pcl-users.org/file/t499210/img.png>
>
> The sphere, having the diameter of 100 mm is located in the center of the
> image held by the robotic arm. Below is the code snippet-
> --------------------------------------------------------------------------------------
> pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_raw(new
> pcl::PointCloud<pcl::PointXYZRGBA>);
> pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_seg(new
> pcl::PointCloud<pcl::PointXYZRGBA>);
>
> float radius = 0.05; // 100 mm diameter
> pcl::io::loadPCDFile("capture.pcd", *cloud_raw);
>
> pcl::ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
> pcl::PointIndices::Ptr inliers(new pcl::PointIndices());
> pcl::SACSegmentation<pcl::PointXYZRGBA> seg;
>
> seg.setOptimizeCoefficients(true);
> seg.setModelType(pcl::SACMODEL_SPHERE);
> seg.setMethodType(pcl::SAC_RANSAC);
> seg.setMaxIterations(10000);
> seg.setDistanceThreshold(0.001);
> seg.setProbability(0.9999);
> seg.setRadiusLimits(radius - 0.05, radius + 0.05); //5 cm tolerance
> seg.setInputCloud(cloud_raw);
> seg.segment(*inliers, *coefficients);
>
> if (inliers->indices.size() > 0)
>    std::cout << coefficients->values[0] << ", " << coefficients->values[1]
> << ", "  << coefficients->values[2] << ", " << coefficients->values[3] <<
> std::endl;
> --------------------------------------------------------------------------------------
>
> The input PCD file can be downloaded from shared Dropbox
> [here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0)
> Unfortunately, SAC_RANSAC is unable to detect sphere.
>
> What's wrong here? Any advice, please.
>
> -
> Thanks
> Ravi
>
>
>
> --
> Sent from: http://www.pcl-users.org/
> _______________________________________________
> [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: Sphere Detection in Point Cloud

ravijoshi
Hi

I am not sure if I got your suggestion properly or not. Let me try to
explain it again.

The sphere is gripped by two fingers of the robotic arm. Maybe if you see
the corresponding color image of this point cloud
[here](http://www.pcl-users.org/file/t499210/img.png), it will be easier to
understand.

This sphere is not a joint in the robotic arm. It can simply be considered
as a payload. If required, I can replace this sphere with a bigger one.
However, I am not sure about the exact issue in this scenario. If you view
the shared PCD file
[here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0), you may
notice that only half of the sphere is visible in the point cloud. That is
because the depth camera can only see the front face. It can be a limitation
of this point cloud. Though I am not sure and looking for suggestions. I
still believe that it should be doable.

Thanks again.

-
Ravi



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

Re: Sphere Detection in Point Cloud

Richard Frank
Ok, but what I wrote will still apply.

I’ll take a look at the data later today.

Rick Frank
Dominion Software, Inc.
825 Beacon Street
Newton, MA 02459
Medical, Scientific, and Industrial Software

> On Feb 5, 2018, at 10:19 AM, ravijoshi <[hidden email]> wrote:
>
> Hi
>
> I am not sure if I got your suggestion properly or not. Let me try to
> explain it again.
>
> The sphere is gripped by two fingers of the robotic arm. Maybe if you see
> the corresponding color image of this point cloud
> [here](http://www.pcl-users.org/file/t499210/img.png), it will be easier to
> understand.
>
> This sphere is not a joint in the robotic arm. It can simply be considered
> as a payload. If required, I can replace this sphere with a bigger one.
> However, I am not sure about the exact issue in this scenario. If you view
> the shared PCD file
> [here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0), you may
> notice that only half of the sphere is visible in the point cloud. That is
> because the depth camera can only see the front face. It can be a limitation
> of this point cloud. Though I am not sure and looking for suggestions. I
> still believe that it should be doable.
>
> Thanks again.
>
> -
> Ravi
>
>
>
> --
> Sent from: http://www.pcl-users.org/
> _______________________________________________
> [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: Sphere Detection in Point Cloud

Frank Dekervel
In reply to this post by ravijoshi
Hey,

We tried something similar using RANSAC sphere detection. We didn't get it working reliably with the size of sphere you have in your pointcloud either.
We tried to find the reasons, and this is what we came up with:
  • ToF camera's distort images slightly (experience with kinect v2 and an IFM camera), dependant on the color/ reflection of the object. This distortion was enough to throw sphere inliers out for the RANSAC method, and if you set the inlier tolerance higher, it will find random other sections on the image. Eg if you have distortion of a 2cm "bump" on a sphere diameter 15 cm, it will prevent the match. 
  • RANSAC (and i guess template matching) works on the number of inliers. As you have a small sphere, you have a small number of points on it, so a bad match that happens to have more points (because it is in an area that's closer to your camera) could be "chosen" over the good match. Including normals in your ransac matching improves this to a certain extent.
If you "cut out" the sphere by hand (eg using meshlab) from your point cloud, you can verify how spherical it is, and you can use the cut point cloud to see which tolerance for inliers gives you how many inliers. I think this would be the way to finding out the feasibility or the solution.

In the end, our solution was to get a bigger sphere covered by fabric to prevent reflection/distortion. But maybe we could have created a template that modeleded the distortion too. 

Frank



 

On Mon, Feb 5, 2018 at 4:19 PM, ravijoshi <[hidden email]> wrote:
Hi

I am not sure if I got your suggestion properly or not. Let me try to
explain it again.

The sphere is gripped by two fingers of the robotic arm. Maybe if you see
the corresponding color image of this point cloud
[here](http://www.pcl-users.org/file/t499210/img.png), it will be easier to
understand.

This sphere is not a joint in the robotic arm. It can simply be considered
as a payload. If required, I can replace this sphere with a bigger one.
However, I am not sure about the exact issue in this scenario. If you view
the shared PCD file
[here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0), you may
notice that only half of the sphere is visible in the point cloud. That is
because the depth camera can only see the front face. It can be a limitation
of this point cloud. Though I am not sure and looking for suggestions. I
still believe that it should be doable.

Thanks again.

-


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

Re: Sphere Detection in Point Cloud

Richard Frank
In reply to this post by Richard Frank
I think what Frank mentioned in a recent post on this applies here - your TOF beam is being scattered off the arm.

I opened your pcd file in matlab and displayed it as follows:

ptCloud1 = pcread('capture.pcd');
% they're all white. Reset the color to red.
ptCloud1.Color(:,2:3) = 0;
pcshow(ptCloud1);

Here's a link to a movie showing what I saw:

https://www.dropbox.com/s/6khaql8odkizi3w/PointCloud.mp4?dl=0

Your point data is normalized (i.e. between 0 and 1.0) so it's not going to match up necessarily with world coordinates unless you calibrate it in some fashion....

The TOF data is reflected off the robot arm - you're not getting any data back from the arm, just from the surrounding area. The beam is being bounced off but not back
to your camera.

At least that what it looks like to me.

HTH

Rick



>-----Original Message-----
>From: PCL-users [mailto:[hidden email]] On Behalf Of
>Richard Frank
>Sent: Monday, February 5, 2018 10:27 AM
>To: Point Cloud Library (PCL) users <[hidden email]>
>Subject: Re: [PCL-users] Sphere Detection in Point Cloud
>
>Ok, but what I wrote will still apply.
>
>I’ll take a look at the data later today.
>
>Rick Frank
>Dominion Software, Inc.
>825 Beacon Street
>Newton, MA 02459
>Medical, Scientific, and Industrial Software
>
>> On Feb 5, 2018, at 10:19 AM, ravijoshi <[hidden email]> wrote:
>>
>> Hi
>>
>> I am not sure if I got your suggestion properly or not. Let me try to
>> explain it again.
>>
>> The sphere is gripped by two fingers of the robotic arm. Maybe if you
>> see the corresponding color image of this point cloud
>> [here](http://www.pcl-users.org/file/t499210/img.png), it will be
>> easier to understand.
>>
>> This sphere is not a joint in the robotic arm. It can simply be
>> considered as a payload. If required, I can replace this sphere with a bigger one.
>> However, I am not sure about the exact issue in this scenario. If you
>> view the shared PCD file
>> [here](https://www.dropbox.com/s/mo4xlxiyjmiwaz9/capture.pcd?dl=0),
>> you may notice that only half of the sphere is visible in the point
>> cloud. That is because the depth camera can only see the front face.
>> It can be a limitation of this point cloud. Though I am not sure and
>> looking for suggestions. I still believe that it should be doable.
>>
>> Thanks again.
>>
>> -
>> Ravi
>>
>>
>>
>> --
>> Sent from: http://www.pcl-users.org/
>> _______________________________________________
>> [hidden email] / http://pointclouds.org
>> http://pointclouds.org/mailman/listinfo/pcl-users
>_______________________________________________
>[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: Sphere Detection in Point Cloud

ravijoshi
Rick,

Thank you very much.

The point cloud data is not normalized. In fact, it is the raw data from the
sensor. While capturing it, I placed a whiteboard in the front just to keep
the view clean.

I got your point about TOF camera. However, I don't need any point cloud
data associated with the robotic arm. It is a positive for me. Since I am
just trying to find the sphere.

-
Regards
Ravi



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

Re: Sphere Detection in Point Cloud

Frank Dekervel
Hello,

i opened your pcd file in pcl viewer, and use the "f" key (fly to point) to zoom in on the ball.
this is what it looks like:

Inline image 1

not very ball anymore, right ?

Frank


On Tue, Feb 6, 2018 at 2:31 PM, ravijoshi <[hidden email]> wrote:
Rick,

Thank you very much.

The point cloud data is not normalized. In fact, it is the raw data from the
sensor. While capturing it, I placed a whiteboard in the front just to keep
the view clean.

I got your point about TOF camera. However, I don't need any point cloud
data associated with the robotic arm. It is a positive for me. Since I am
just trying to find the sphere.

-
Regards


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

Re: Sphere Detection in Point Cloud

Frank Dekervel
Hello,
I guess i got the wrong point cloud (i found the right one in the related thread), but i think my point still stands. 
The bump on the point cloud (only visible when looking at an angle) is exactly what we saw, and using a non-reflective material improved this for us ...

Inline image 1

greetings,
Frank


On Tue, Feb 6, 2018 at 5:47 PM, Frank Dekervel <[hidden email]> wrote:
Hello,

i opened your pcd file in pcl viewer, and use the "f" key (fly to point) to zoom in on the ball.
this is what it looks like:

Inline image 1

not very ball anymore, right ?

Frank


On Tue, Feb 6, 2018 at 2:31 PM, ravijoshi <[hidden email]> wrote:
Rick,

Thank you very much.

The point cloud data is not normalized. In fact, it is the raw data from the
sensor. While capturing it, I placed a whiteboard in the front just to keep
the view clean.

I got your point about TOF camera. However, I don't need any point cloud
data associated with the robotic arm. It is a positive for me. Since I am
just trying to find the sphere.

-
Regards



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

Re: Sphere Detection in Point Cloud

ravijoshi
Hi,

Thank you very much. I understand your point. Even I noticed the spike in
point cloud after reading the post. I changed the lights, changed the
material and captured new point cloud. Please see below the screenshot-

<http://www.pcl-users.org/file/t499210/yellow_ball.png>

The yellow ball is made from rubber and it is located in the center of the
above image. I did color based segmentation (at present RGB values are used
just for testing) and I am able to remove most of the unwanted points from
the cloud. Please see the screenshot of the segmentation output-

<http://www.pcl-users.org/file/t499210/color_segmentation.png>

Unfortunately, the segmented point cloud contains two clusters. However,
upon close inspection, I can find out that one cluster is almost flat and
another cluster is almost spherical. Is it possible to perform sphere
detection on this segmented cloud using SAC_RANSAC?

Below are the point clouds shared from my DropBox-
(1) Captured Point Cloud (contains all points): https://goo.gl/H8T7dc
(2) Segmented Point Cloud (output could obtain from color-based
segmentation): https://goo.gl/XkFj8N

Thank you very much.

-
Ravi



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

Re: Sphere Detection in Point Cloud

Frank Dekervel
Hello,

If the color segmentation will always be as reliable in the example it looks like a good approach. The less points you have to consider for ransac sphere finding (or other methods) , the less strict you can set your tolerances without getting false matches. You could also try to segment and remove the planes from your scenes (ransac or organised multiplane segmentation), this will remove a lot of points (but not more than your example with the color segmentation). When i try to measure the diameter of the sphere i get 0.068, so 0.034 could be a good starting point for the radius. Be sure to use sample consensus normal sphere (see https://answers.ros.org/question/229784/detecting-spheres-using-ransac-in-pcl/ for the reason).

I think your point cloud must have been organised from the start, but it is not organised anymore because you did some operation on it ? 

Frank




On Wed, Feb 7, 2018 at 10:57 AM, ravijoshi <[hidden email]> wrote:
Hi,

Thank you very much. I understand your point. Even I noticed the spike in
point cloud after reading the post. I changed the lights, changed the
material and captured new point cloud. Please see below the screenshot-

<http://www.pcl-users.org/file/t499210/yellow_ball.png>

The yellow ball is made from rubber and it is located in the center of the
above image. I did color based segmentation (at present RGB values are used
just for testing) and I am able to remove most of the unwanted points from
the cloud. Please see the screenshot of the segmentation output-

<http://www.pcl-users.org/file/t499210/color_segmentation.png>

Unfortunately, the segmented point cloud contains two clusters. However,
upon close inspection, I can find out that one cluster is almost flat and
another cluster is almost spherical. Is it possible to perform sphere
detection on this segmented cloud using SAC_RANSAC?

Below are the point clouds shared from my DropBox-
(1) Captured Point Cloud (contains all points): https://goo.gl/H8T7dc
(2) Segmented Point Cloud (output could obtain from color-based
segmentation): https://goo.gl/XkFj8N

Thank you very much.

-


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

Re: Sphere Detection in Point Cloud

ravijoshi
Hi Frank,

Thank you so much. Your suggestions are indeed helpful. The point cloud is
unorganized.

Anyway, I used SAC_RANSAC with SACMODEL_NORMAL_SPHERE model and it worked
well. Later, I realized that even SACMODEL_SPHERE is able to detect sphere
in the segmented cloud. However, I believe that using Normals are going to
make the detection more robust.

Meanwhile, can you please have a look at the below values used in SAC_RANSAC
and suggest accordingly-
--------------------------------------------------------------
NormalEstimation<PointXYZRGB, Normal> ne;
PointCloud<Normal>::Ptr cloud_normals(new PointCloud<Normal>);
pcl::search::KdTree<PointXYZRGB>::Ptr tree(new
pcl::search::KdTree<PointXYZRGB>());
ne.setSearchMethod(tree);
ne.setInputCloud(rgb_cloud);
ne.setKSearch(10);
ne.compute(*cloud_normals);

SACSegmentationFromNormals<PointXYZRGB, Normal> seg;
PointIndices::Ptr inliers(new pcl::PointIndices());
ModelCoefficients::Ptr coefficients(new pcl::ModelCoefficients());
seg.setOptimizeCoefficients(true);
seg.setModelType(pcl::SACMODEL_NORMAL_SPHERE);
seg.setNormalDistanceWeight(0.05);
seg.setMethodType(pcl::SAC_RANSAC);
seg.setMaxIterations(1000);
seg.setDistanceThreshold(0.005);
seg.setProbability(0.99999);
seg.setRadiusLimits(0.034 - 0.02, 0.034 + 0.02); // 2 cm tolerance
seg.setEpsAngle(pcl::deg2rad(15.0f));
seg.setInputCloud(rgb_cloud);
seg.setInputNormals(cloud_normals);
seg.segment(*inliers, *coefficients);
--------------------------------------------------------------

The rgb_cloud used in above code can be downloaded from
[here](https://goo.gl/XkFj8N)

Thanks again.

-
Ravi



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