[vtkusers] ICP does not apply transformation on source data

Dime Vitanovski vitanovski at hotmail.com
Mon Dec 6 04:33:14 EST 2010


Hi VTK,
I have some problems with ICP and I hope you can help me.I have two clouds of points: 1. source points => 638 3D Points 2. target points  => 204 3D Points
I used vtkIterativeClosestPointTransform to map the source points to the target points, everything work fines in terms of compilation and transformation ( i have printed the transfomration matrix)but I can not apply the computed transfomration on the source points. Here is the code, probably I am doing some very basic mistake:
void ShapeAlignment::iterativeClosesPoint( const PointArray &mesh, const std::vector<PointArray> &sparseMesh, PointArray &mappedMesh ){	//MESH	vtkPointsPtr vtkMesh;	VTKConversion::convertSeC2VTK(mesh,vtkMesh);	DebugRender::renderPoint(mesh,MString("mesh"),PointType(1,0,0),0);
       //vtkMesh is of type vtkPoints => 638 3D vtkPoints	vtkSmartPointer<vtkPolyData> vtkPolyDataMesh = vtkSmartPointer<vtkPolyData>::New();	vtkPolyDataMesh->SetPoints(vtkMesh);		vtkSmartPointer<vtkVertexGlyphFilter> vertexMesh = vtkSmartPointer<vtkVertexGlyphFilter>::New();	vertexMesh->SetInputConnection(vtkPolyDataMesh->GetProducerPort());	vertexMesh->Update();
	//SPARSE MESH	vtkPointsPtr vtkSparseMesh;	VTKConversion::convertSeC2VTK(sparseMesh,vtkSparseMesh);	DebugRender::renderPoint(vtkSparseMesh,MString("sparseMesh"),PointType(0,1,0),0);
        //vtkSparseMesh is of type vtkPoints => 204 3D points	vtkSmartPointer<vtkPolyData> vtkPolyDataSparseMesh = vtkSmartPointer<vtkPolyData>::New();	vtkPolyDataSparseMesh->SetPoints(vtkSparseMesh);
	vtkSmartPointer<vtkVertexGlyphFilter> vertexSparseMesh = vtkSmartPointer<vtkVertexGlyphFilter>::New();	vertexSparseMesh->SetInputConnection(vtkPolyDataSparseMesh->GetProducerPort());	vertexSparseMesh->Update();
       //setup ICP	vtkSmartPointer<vtkIterativeClosestPointTransform> icp = vtkSmartPointer<vtkIterativeClosestPointTransform>::New();	icp->SetSource(vertexMesh->GetOutput());  	icp->SetTarget(vertexSparseMesh->GetOutput());	icp->DebugOn();	icp->GetLandmarkTransform()->SetModeToRigidBody();	icp->SetMaximumNumberOfIterations(40);	icp->SetMaximumNumberOfLandmarks(vertexSparseMesh->GetOutput()->GetNumberOfPoints());	icp->SetCheckMeanDistance(1);	icp->SetMaximumMeanDistance(0.0000001);	icp->Modified();	icp->Update();
	vtkSmartPointer<vtkMatrix4x4> m = icp->GetMatrix();	std::cout << "The resulting matrix is: " << *m << std::endl;
	// Transform the source points by the ICP solution	vtkSmartPointer<vtkTransformPolyDataFilter> icpTransformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();	icpTransformFilter->SetInput(vertexSparseMesh->GetOutput());	icpTransformFilter->SetTransform(icp);	icpTransformFilter->Update();	        //visualize transformed mesh	DebugRender::renderPoint(vertexSparseMesh->GetOutput()->GetPoints(),MString("mesh"),PointType(0,0,1),0);}
Can you please give me some feedback.
Thanks a lot,padre 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101206/3ef2d34b/attachment.htm>


More information about the vtkusers mailing list