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

Vikas Singh csviks at gmail.com
Mon Nov 7 16:22:39 EST 2005


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.



More information about the vtkusers mailing list