Given coordinate of a point in depth image, how to find its index in point cloud

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

Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
This post was updated on .
Hi,
I have a point with (u,v) and depth value got from registered depth image
from a Kinect V2. Later I want to do surface normal estimation around this
point. To do that I need the corresponding index at this point.
I have tried with this method but it did not work:
p.z = depth/1000;
p.x = (u-cx) * p.z / fx;
p.y = (v-cy) * p.z / fy;
It gave me all NaN when I printed the plane_parameters out.

so any ideas?



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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

Dominique Vaufreydaz
Hello,

> I have a point with (u,v) and depth value got from registered depth image
> from a Kinect V2. Later I want to do surface normal estimation around this
> point. To do that I need the corresponding index at this point.
> I have tried with this method but it did not work:
> p.z = depth/1000;
> p.x = (u-cx) * p.z / fx;
> p.x = (v-cy) * p.z / fy;

        This one should be p.y, no ?

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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
Dominique Vaufreydaz wrote

> Hello,
>
>> I have a point with (u,v) and depth value got from registered depth image
>> from a Kinect V2. Later I want to do surface normal estimation around
>> this
>> point. To do that I need the corresponding index at this point.
>> I have tried with this method but it did not work:
>> p.z = depth/1000;
>> p.x = (u-cx) * p.z / fx;
>> p.x = (v-cy) * p.z / fy;
>
> This one should be p.y, no ?
>
> Dominique.
> _______________________________________________

> PCL-users@

>  / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

Yes, should be p.y, I have edited.



--
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: Given coordinate of a point in depth image, how to find its index in point cloud

Dominique Vaufreydaz
Hello,

> Yes, should be p.y, I have edited.

        And then it works?

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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
This post was updated on .
Dominique Vaufreydaz wrote
> Hello,
>
>> Yes, should be p.y, I have edited.
>
> And then it works?
>
> Best regards. Dominique.
> _______________________________________________

> PCL-users@

>  / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

Hi,
No it does not. It's just a typo :D



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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

Dominique Vaufreydaz
In reply to this post by TrinhTUHH
Hello,

>      p.z = (float)depth/1000.0; (or you will get 0 as z in int

        p.z = (float)depth/1000.0; (or you will get 0 as z in int
        computation thinking that depth is a short int and 1000 an int.

        Ok, for pure good code (no mixing between float and double).
        p.z = (flaot)depth/1000.0f;

        or
       
        p.z = (double)depth/1000.0;

        It depends of your p.z type.

        Dominique.

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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

Sérgio Agostinho
Are p.x, p.y and p.z populated with proper coordinates?

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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
In reply to this post by Dominique Vaufreydaz
Dominique Vaufreydaz wrote

> Hello,
>
>>      p.z = (float)depth/1000.0; (or you will get 0 as z in int
>
> p.z = (float)depth/1000.0; (or you will get 0 as z in int
> computation thinking that depth is a short int and 1000 an int.
>
> Ok, for pure good code (no mixing between float and double).
> p.z = (flaot)depth/1000.0f;
>
> or
>
> p.z = (double)depth/1000.0;
>
> It depends of your p.z type.
>
> Dominique.
>
>
> _______________________________________________

> PCL-users@

>  / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

I did use double and print out all the values and check. They are fine.
However, I still get NaN. I also did removeNaNFromPointCloud() before doing
surface normal. I have another question, is it correct if I use fx, fy, cx,
cy taken from the color camera matrix instead of ir camera matrix, since I
use the registered depth image? Anyway, I tried both of them and neither
work :(



--
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: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
Yes, I think they are correct since it is on the position that I want when I
draw it out. You can see it on the photo below (the small red dot inside the
rectangle).
<http://www.pcl-users.org/file/t499017/pcl1.png>

Here is the zoom-in image:
<http://www.pcl-users.org/file/t499017/Capture.jpg>




--
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: Given coordinate of a point in depth image, how to find its index in point cloud

Dominique Vaufreydaz
In reply to this post by TrinhTUHH
Hello,

> I did use double and print out all the values and check. They are fine.
> However, I still get NaN. I also did removeNaNFromPointCloud() before doing
> surface normal. I have another question, is it correct if I use fx, fy, cx,
> cy taken from the color camera matrix instead of ir camera matrix, since I
> use the registered depth image? Anyway, I tried both of them and neither
> work :(

        The parameters are not the same on both camera. The Kinect2 can
        give you them on Windows. I did not use it on Linux.

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

Re: Given coordinate of a point in depth image, how to find its index in point cloud

Sujan Dasmahapatra
In reply to this post by TrinhTUHH
surface normal = N(x, y, z)
where N = cross product of two vectors P1 and P2.
Where P1 is vector I clockwise and P2 is vector 2 anticlockwise.

You need at least 3 consecutive points  on the surface to compute the
surface normal and from 3 points you must find out two vectors. And
from two vectors you must be able to compute the coordinate of normal
for the surface.
Best Regards
Sujan Dasmahapatra
Programmer
C/C++, C#.Net, JavaScript, WordPress, PHP, Qt, OpenGL 3D, VC++
Windows, Linux, Android, iOS


On 7 December 2017 at 22:02, TrinhTUHH <[hidden email]> wrote:

> Dominique Vaufreydaz wrote
>> Hello,
>>
>>> I have a point with (u,v) and depth value got from registered depth image
>>> from a Kinect V2. Later I want to do surface normal estimation around
>>> this
>>> point. To do that I need the corresponding index at this point.
>>> I have tried with this method but it did not work:
>>> p.z = depth/1000;
>>> p.x = (u-cx) * p.z / fx;
>>> p.x = (v-cy) * p.z / fy;
>>
>>       This one should be p.y, no ?
>>
>>       Dominique.
>> _______________________________________________
>
>> PCL-users@
>
>>  / http://pointclouds.org
>> http://pointclouds.org/mailman/listinfo/pcl-users
>
> Yes, should be p.y, I have edited.
>
>
>
> --
> 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: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
In reply to this post by Dominique Vaufreydaz
Dominique Vaufreydaz wrote

> Hello,
>
>> I did use double and print out all the values and check. They are fine.
>> However, I still get NaN. I also did removeNaNFromPointCloud() before
>> doing
>> surface normal. I have another question, is it correct if I use fx, fy,
>> cx,
>> cy taken from the color camera matrix instead of ir camera matrix, since
>> I
>> use the registered depth image? Anyway, I tried both of them and neither
>> work :(
>
> The parameters are not the same on both camera. The Kinect2 can
> give you them on Windows. I did not use it on Linux.
>
> Best regards. Dominique.
> _______________________________________________

> PCL-users@

>  / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

Yes I know the parameters are not the same, but in this case I use depth
image which is registered (align) with the color image, so I think using
color camera parameter should be correct, right?



--
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: Given coordinate of a point in depth image, how to find its index in point cloud

TrinhTUHH
In reply to this post by Sujan Dasmahapatra
Sujan Dasmahapatra wrote

> surface normal = N(x, y, z)
> where N = cross product of two vectors P1 and P2.
> Where P1 is vector I clockwise and P2 is vector 2 anticlockwise.
>
> You need at least 3 consecutive points  on the surface to compute the
> surface normal and from 3 points you must find out two vectors. And
> from two vectors you must be able to compute the coordinate of normal
> for the surface.
> Best Regards
> Sujan Dasmahapatra
> Programmer
> C/C++, C#.Net, JavaScript, WordPress, PHP, Qt, OpenGL 3D, VC++
> Windows, Linux, Android, iOS
>
>
> On 7 December 2017 at 22:02, TrinhTUHH &lt;

> nguyencongtrinh.vn@

> &gt; wrote:
>> Dominique Vaufreydaz wrote
>>> Hello,
>>>
>>>> I have a point with (u,v) and depth value got from registered depth
>>>> image
>>>> from a Kinect V2. Later I want to do surface normal estimation around
>>>> this
>>>> point. To do that I need the corresponding index at this point.
>>>> I have tried with this method but it did not work:
>>>> p.z = depth/1000;
>>>> p.x = (u-cx) * p.z / fx;
>>>> p.x = (v-cy) * p.z / fy;
>>>
>>>       This one should be p.y, no ?
>>>
>>>       Dominique.
>>> _______________________________________________
>>
>>> PCL-users@
>>
>>>  / http://pointclouds.org
>>> http://pointclouds.org/mailman/listinfo/pcl-users
>>
>> Yes, should be p.y, I have edited.
>>
>>
>>
>> --
>> Sent from: http://www.pcl-users.org/
>> _______________________________________________
>>

> PCL-users@

>  / http://pointclouds.org
>> http://pointclouds.org/mailman/listinfo/pcl-users
> _______________________________________________

> PCL-users@

>  / http://pointclouds.org
> http://pointclouds.org/mailman/listinfo/pcl-users

Hi,
By 3 consecutive points you mean points in the depth image coordinate or in
the cloud coordinate?



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