ICP and parametric surface

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

ICP and parametric surface

raimi87
Hi !
how can i disolay the ICP algo with a parametric surface ?
Reply | Threaded
Open this post in threaded view
|

Re: ICP and parametric surface

David Doria-2-3
On Tue, Aug 9, 2011 at 8:51 AM, raimi87 <[hidden email]> wrote:
> Hi !
> how can i disolay the ICP algo with a parametric surface ?

As far as I know, you would have to convert the parametric surface
into a discrete representation (sample it, obtaining a point cloud)
and then apply ICP as normal.

David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: ICP and parametric surface

raimi87
actually i have the cloud point how can i use it ?
sorry I'm beginner with vtk
Reply | Threaded
Open this post in threaded view
|

Re: ICP and parametric surface

raimi87
hi make this little code but i have some problem after
build suuceed but debug start working and then "nuage.exe" stopped working



#include <stdio.h>
#include "vtkActor.h"
#include "vtkCellArray.h"
#include "vtkDoubleArray.h"
#include "vtkFloatArray.h"
#include "vtkIntArray.h"
#include "vtkPointData.h"
#include "vtkPoints.h"
#include "vtkPointSet.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkDelaunay3D.h"
#include "vtkDataSetMapper.h"
#include "vtkOutlineFilter.h"
#include "vtkProperty.h"
#include "vtkIterativeClosestPointTransform.h"
#include "vtkLandmarkTransform.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkMaskPoints.h"

using namespace std;
int main(int/*argc*/, char ** /*argv*/)

{
        // Read some 3d points.
        FILE *datei = fopen("bs000_N_N_1mesh1remaillage.obj","r");
        vtkDelaunay3D* del_1    = vtkDelaunay3D::New();
        vtkPolyData *polydata_1 = vtkPolyData::New();
        vtkPoints *points = vtkPoints::New();
        vtkDelaunay3D* del_2    = vtkDelaunay3D::New();
        vtkPolyData *polydata_2 = vtkPolyData::New();
        vtkPoints *points_2 = vtkPoints::New();
       
        int iCounter = 0;
        while (!feof(datei))
        {
                fprintf(stdout,"reading points: %i\r", iCounter);
                char a ;
                float x, y, z;
                fscanf(datei,"%c %f %f %f \n",&a , &x, &y, &z);
                if (a == 'v')
                points->InsertPoint(iCounter++, x, y, z);
                //cout<<"x=    "<<x<<"y=    "<<y<<"z=    "<<z<<endl;
        }
        polydata_1->SetPoints(points);
        fclose(datei);
        fprintf(stdout,"\n\n");

       
        int num_of_points_1 = polydata_1->GetPoints()->GetNumberOfPoints();
        cout << "in all, num of points in cloud 1 is " << num_of_points_1 << endl;
        del_1->SetInput((vtkPointSet*)polydata_1);
        del_1->SetTolerance(0.01);
        del_1->Update();
        del_1->SetAlpha(0);
        FILE *datei2 = fopen("bs015_N_N_0mesh1.obj","r");
int iCounter2 = 0;

        while (!feof(datei2))
        {
                fprintf(stdout,"reading points: %i\r", iCounter);
                char a ;
                float x, y, z;
                fscanf(datei,"%c %f %f %f \n",&a , &x, &y, &z);
                if (a == 'v')
                points_2->InsertPoint(iCounter2++, x, y, z);
                //cout<<"x=    "<<x<<"y=    "<<y<<"z=    "<<z<<endl;
        }
        polydata_2->SetPoints(points_2);
        fclose(datei2);
        fprintf(stdout,"\n\n");
       
        int num_of_points_2 = polydata_1->GetPoints()->GetNumberOfPoints();
        cout << "in all, num of points in cloud 1 is " << num_of_points_2 << endl;
        del_2->SetInput((vtkPointSet*)polydata_2);
        del_2->SetTolerance(0.01);
        del_2->Update();
        del_2->SetAlpha(0);
       

       
        vtkIterativeClosestPointTransform *_icpt = vtkIterativeClosestPointTransform::New();
        _icpt->GetLandmarkTransform()->SetModeToRigidBody();
        _icpt->StartByMatchingCentroidsOn();
        _icpt->SetMaximumNumberOfIterations(10.);
       
        vtkMaskPoints *maskPoints1 = vtkMaskPoints::New();
  maskPoints1->SetInput(polydata_1);
  maskPoints1->SetMaximumNumberOfPoints(402);
  maskPoints1->GenerateVerticesOn();
        _icpt->SetSource((vtkPolyData *)maskPoints1);
        cout << "Calling icpt" << endl;
       
        vtkMaskPoints *maskPoints2 = vtkMaskPoints::New();
  maskPoints2->SetInput(polydata_2);
  maskPoints2->SetMaximumNumberOfPoints(6034);
  maskPoints2->GenerateVerticesOn();
        _icpt->SetSource((vtkPolyData *)maskPoints2);
        cout << "Calling icpt" << endl;
  _icpt->SetTarget((vtkPolyData *)maskPoints2);
  _icpt->SetMeanDistanceModeToAbsoluteValue();
        _icpt->Update();
       
        cout << " Mean distance is " << _icpt->GetMeanDistance() << endl;
    cout << "done icpt" << endl;
        vtkTransformPolyDataFilter* transformer = vtkTransformPolyDataFilter::New();
        transformer->SetTransform(_icpt);
        transformer->SetInput((vtkPolyData*)maskPoints1);
        transformer->Update();
       
       
        //transformer->PrintSelf(std::cout,0);  
        vtkDataSetMapper *surface_mapper_1 = vtkDataSetMapper::New();
        surface_mapper_1->SetInput((vtkDataSet*)maskPoints1->GetOutput());
       
       
        vtkActor* actor_1 = vtkActor::New();
        actor_1->SetMapper(surface_mapper_1);
        actor_1->GetProperty()->SetRepresentationToPoints();
        actor_1->GetProperty()->SetColor(1,1,1);
       
        vtkRenderer* ren = vtkRenderer::New();
         ren->AddActor(actor_1);
       
        vtkRenderWindow* renWin = vtkRenderWindow::New();
         renWin->AddRenderer(ren);
        vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);
  iren->Initialize();
  iren->Start();
       
 return 0;



       
       
       
        }

what's wrong with my project