Creating a 3D object using PCL

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

Creating a 3D object using PCL

Shweta07
Hello,

I have two primesense RGB-D sensors that are placed opposite to each other, so that they capture the top and bottom views of an object placed between them. I have calibrated the two cameras so that they are in the same co-ordinate system and hence ultimately the point clouds also lie in the same co-ordinate system.
My main aim is to determine the depth of the object using the top and the bottom views and the corresponding point clouds.

Is there a way to pass a perpendicular ray from one point cloud to the other point cloud and fill the space between the two point clouds with more points, such that it would ultimately lead to the entire 3d object to be reconstructed using the point clouds of the top and bottom views?

All help and suggestions are appreciated.

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

VictorLamoine
Administrator
This post was updated on .
Hello,

I understand you camera setup but I'm not sure I've understood your question;

You have 2 points clouds:
- Top surface
- Bottom surface

If you want to reconstruct an object with these (incomplete) information here is what I would do:
- Triangulate bottom and top surfaces completely
- Detect points that lies on the border of the bottom/top surfaces
- For each point of the bottom surface BORDER find the closest one in top surface BORDER etc.. and triangulate that way.

Bye

EDIT: surface borders!
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
Hello VictorL,

Thank you for the prompt reply.
This is exactly what I was looking for :)

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
Hello,

I am a bit unclear about calculating the point cloud borders.
At the moment I convert the point cloud into range images and then find the borders. Is this correct?
Or should I use pcl::BoundaryEstimation?

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
In reply to this post by VictorLamoine
Hello,
 
To find the closest point point between the borders, do I iterate throughout the points and find the closest one? Or is there any other PCL functionality that I may use?
Can you please elaborate a bit on the third point? How do I triangulate after finding the closest point between the top and bottom surface borders?

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

VictorLamoine
Administrator
Hello,

I don't know to find the border of the mesh, if you don't find anything in PCL take a look at VTK functions.

To triangulate the surface you can use the greedy triangulation algorithm:
http://www.pointclouds.org/documentation/tutorials/greedy_projection.php#greedy-triangulation

Bye
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
Hello Victor,

I use greedy projection for triangulation. I save the polygon mesh as a vtk file as well as a ply file and tried visualizing it. However, the mesh is not visible. Can you please suggest what may be wrong. I use the same code as mentioned in the tutorial.
I am attaching the image of my result.

Thanks and Regards,
Shweta

Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
In reply to this post by VictorLamoine
Hello Victor,

How do I triangulate after I find the point in the top surface closest to the one in the bottom surface?
For surface triangulation I have implemented greedyprojection.

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

VictorLamoine
Administrator
Hello,

You should be able to create triangles in the mesh with this method:
http://docs.pointclouds.org/trunk/classpcl_1_1geometry_1_1_polygon_mesh.html#afc59c7aa14982d42ed46d4b05e387a89

I would suggest trying to build 1 face from a point cloud with 3 points first.
After that try to work on very simple meshes (a cube for example) before trying your code on complex meshes!

Bye
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
Hello Victor,

I have a small query. I have the  borders of the point clouds. Will it be possible to triangulate between these now using addface()? As far as I understood addface() needs vertexIndex as input which come form the half edge mesh?

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

VictorLamoine
Administrator
Hello,

Yes it should be possible but beware not creating faces that crosses themselves.
You need an algorithm that makes sure that faces do no overlap, I'm not sure how to achieve that.

Bye
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
Hello Victor,

Thank you for the promot reply. However, I am still confused? What do I supply as the input to addFace()? How do I get the vertexIndex from the point cloud?

Thanks and Regards,
Shweta.
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

VictorLamoine
Administrator
Hello,

The point cloud is a list of 3D points, the index is simply the index of the cloud in it's vector.
So for a point cloud with 5 points:

clouds.points[0]
clouds.points[1]
clouds.points[2]
clouds.points[3]
clouds.points[4]

Your job is now to find a method for correctly connecting those vertices into faces :)

Bye
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07

Hello,

Great. Thank you once again :)

Best Regards,
Shweta.

On 22-Feb-2016 11:04 pm, "VictorLamoine [via Point Cloud Library (PCL) Users mailing list]" <[hidden email]> wrote:
Hello,

The point cloud is a list of 3D points, the index is simply the index of the cloud in it's vector.
So for a point cloud with 5 points:

clouds.points[0]
clouds.points[1]
clouds.points[2]
clouds.points[3]
clouds.points[4]

Your job is now to find a method for correctly connecting those vertices into faces :)

Bye


If you reply to this email, your message will be added to the discussion below:
http://www.pcl-users.org/Creating-a-3D-object-using-PCL-tp4039604p4041018.html
To unsubscribe from Creating a 3D object using PCL, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: Creating a 3D object using PCL

Shweta07
In reply to this post by VictorLamoine
Hello Victor,

I have another query regarding the same problem.
So now I have a point cloud (pcl::PointCloud<pcl::PointXYZ>::Ptr). Now I want to genetrate faces within this point cloud using addFace(). For this I create a mesh (typedef pcl::geometry::PolygonMesh <pcl::geometry::DefaultMeshTraits<std::vector<int> > > Mesh). Using this mesh I try to access the vertices. However, I do not understand how should I do that. Can you please suggest something. Please find below my code:


typedef pcl::geometry::PolygonMesh <pcl::geometry::DefaultMeshTraits<int > > Mesh;
    Mesh::VertexIndices vi;
    Mesh::VertexIndices tmp;
    Mesh mesh;

    std::cout<<cloud_top_gray->points[0]<<std::endl;
    for(size_t i = 0; i < cloud_top_gray->points.size(); ++i)
    {
        vi.push_back(mesh.addVertex(i));
    }

    for(int i = 0; i < cloud_top_gray->points.size() - indices.size(); ++i)
    {
        tmp.push_back(vi[i]);
        tmp.push_back(vi[i+1]);
        tmp.push_back(vi[indices[i]]);
        mesh.addFace(tmp);
        tmp.clear();
        tmp.push_back(vi[i+1]);
        tmp.push_back(vi[indices[i]]);
        tmp.push_back(vi[indices[i+1]]);
        mesh.addFace(tmp);
        tmp.clear();
    }

In the above code, won't the actual 3D point data be lost if I simply use the indices?

Thanks and Regards,
Shweta.