[vtkusers] Iterative closest point transform for point clouds - need some help

Vikas Singh csviks at gmail.com
Mon Nov 7 18:01:17 EST 2005


Hi Sylvain:

Unfortunately, that doesnt work.  I mentioned that in my email
(attached below) that if I do not do a delaunay triangulation and call
icpt directly as

_icpt->SetSource(polydata_1);
_icpt->SetTarget(polydata_2);

it gives me a segmentation fault and the following error message:
ERROR: In /usr/local/VTK/Filtering/vtkCellLocator.cxx, line 1190
vtkCellLocator (0x8093b88): No cells to subdivide.

Same error message even if I typecast it.

But If I do a Delaunay, I avoid the error message and seg fault.
However, after applying the transformation on the source cloud set, I
cannot see the point set when it renders it.
See partial code below:

 // Iterative Closest Point Transform
  vtkIterativeClosestPointTransform *_icpt =
vtkIterativeClosestPointTransform::New();
  _icpt->GetLandmarkTransform()->SetModeToRigidBody();
  _icpt->StartByMatchingCentroidsOn();
  _icpt->SetMaximumNumberOfIterations(100.);

// del_1 and del_2 are the delaunay triangulations for first and
second point clouds.
  _icpt->SetSource((vtkDataSet *)del_1->GetOutput());
  cout << "Calling icpt" << endl;
  _icpt->SetTarget((vtkDataSet *)del_2->GetOutput());

  _icpt->Update();

  cout << "done icpt" << endl;

  // Now lets tranform the data
  vtkTransformPolyDataFilter* transformer = vtkTransformPolyDataFilter::New();
  transformer->SetTransform(_icpt);

  transformer->SetInput((vtkPolyData*)polydata_1);
  transformer->Update();
  transformer->PrintSelf(std::cout,0);

  // map for displaying

  vtkDataSetMapper *surface_mapper_1 = vtkDataSetMapper::New();

  //surface_mapper_1->SetInput((vtkDataSet*)del_1->GetOutput());
  // if i do this ^^^^^^^^^^^^^ it shows the untransformed first point cloud
  // and the one below does not show anything (I want it to show the
  // the transformed (aligned) point cloud
  surface_mapper_1->SetInput(transformer->GetOutput());

  vtkDataSetMapper *surface_mapper_2 = vtkDataSetMapper::New();
  surface_mapper_2->SetInput((vtkDataSet*)_icpt->GetTarget());

  // Create an actor for cloud 1.
  vtkActor* actor_1 = vtkActor::New();
  actor_1->SetMapper(surface_mapper_1);
  actor_1->GetProperty()->SetRepresentationToPoints();
  actor_1->GetProperty()->SetColor(1,1,1);

  // create an actor for cloud 2
  vtkActor* actor_2 = vtkActor::New();
  actor_2->SetMapper(surface_mapper_2);
  actor_2->GetProperty()->SetRepresentationToPoints();
  actor_2->GetProperty()->SetColor(0,1,1);

......and then the rendering part.


Any suggestions ?

--Vikas


On 11/7/05, Sylvain Jaume <sylvain.jaume at kitware.com> wrote:
> Hi Vikas,
>
> vtkIterativeClosestPointTransform gives a transform. You need to apply
> the resulting transform to your input dataset using
> vtkTransformPolyDataFilter. You don't need to use vtkDelaunay3D, nor to
> type cast your datasets.
>
> Cheers,
> Sylvain
>
> Vikas Singh wrote:
>
> >Hello!
> >
> >I am a newbie to VTK and need some help with ICPT. Been trying all
> >sorts of things since today morning including the VTK User's guide and
> >the online documentation but nothing has worked so far. Seems to me
> >that the problem is simple for someone who knows VTK well.
> >
> >I am trying to randomly generate point clouds and align them (as a start).
> >
> >vtkPolyData* polydata_1 = vtkPolyData::New();
> >vtkDelaunay3D* del_1    = vtkDelaunay3D::New();
> >vtkPoints* cloud_1         = vtkPoints::New();
> >
> >static float mypoint_1[3];
> >
> >for (int i = 0; i < 50; i++)
> >    {
> >      mypoint_1[0] = drand48()*50;
> >      mypoint_1[1] = drand48()*50;
> >      mypoint_1[2] = drand48()*50;
> >
> >      cloud_1->InsertNextPoint(mypoint_1);
> >    }
> >
> >  polydata_1->SetPoints(cloud_1);
> >
> >  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->PrintSelf(std::cout,0);
> >
> >I repeat the same for cloud 2 - variable names end with "_2".
> >
> >
> >Then I call ICPT as follows:
> >
> >vtkIterativeClosestPointTransform *_icpt =
> >vtkIterativeClosestPointTransform::New();
> >_icpt->GetLandmarkTransform()->SetModeToRigidBody();
> >_icpt->StartByMatchingCentroidsOn();
> >_icpt->SetMaximumNumberOfIterations(10);
> >
> >_icpt->SetSource((vtkDataSet *)del_1->GetOutput());
> >cout << "Calling icpt" << endl;
> >_icpt->SetTarget((vtkDataSet *)del_2->GetOutput());
> >
> >_icpt->Update();
> >
> >
> >To this it gives me an error
> >
> >ERROR: In /usr/local/VTK/Hybrid/vtkIterativeClosestPointTransform.cxx, line 274
> >vtkIterativeClosestPointTransform (0x80650e0): Can't execute with NULL or empty
> >input
> >
> >I think that up until the delaunay triangulation, it is working ok - I
> >rendered it and it is alright. If I do not do a delaunay triangulation
> >and typecast cloud_1 and cloud_2 directly it never returns from ICPT.
> >
> >any pointers, please?
> >
> >VS.
> >_______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> >Follow this link to subscribe/unsubscribe:
> >http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
> >
>



More information about the vtkusers mailing list