<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma" size="2">Hi VTK,</font><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">I have some problems with ICP and I hope you can help me.</div><div style="font-family: Tahoma; font-size: 10pt; ">I have two clouds of points:</div><div style="font-family: Tahoma; font-size: 10pt; "> 1. source points => 638 3D Points</div><div style="font-family: Tahoma; font-size: 10pt; "> 2. target points => 204 3D Points</div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div style="font-family: Tahoma; font-size: 10pt; ">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)</div><div style="font-family: Tahoma; font-size: 10pt; ">but I can not apply the computed transfomration on the source points. Here is the code, probably I am doing some very basic mistake:</div><div style="font-family: Tahoma; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" face="Tahoma" size="2">void ShapeAlignment::iterativeClosesPoint( const PointArray &mesh, const std::vector<PointArray> &sparseMesh, PointArray &mappedMesh )</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">{</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>//MESH</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPointsPtr vtkMesh;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>VTKConversion::convertSeC2VTK(mesh,vtkMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(mesh,MString("mesh"),PointType(1,0,0),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> //vtkMesh is of type vtkPoints => 638 3D vtkPoints</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyData> vtkPolyDataMesh = vtkSmartPointer<vtkPolyData>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataMesh->SetPoints(vtkMesh);</font></div><div><span class="Apple-style-span" style="font-family: Tahoma; font-size: 10pt; "><span class="Apple-tab-span" style="white-space:pre">        </span></span></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkVertexGlyphFilter> vertexMesh = vtkSmartPointer<vtkVertexGlyphFilter>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexMesh->SetInputConnection(vtkPolyDataMesh->GetProducerPort());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexMesh->Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>//SPARSE MESH</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPointsPtr vtkSparseMesh;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>VTKConversion::convertSeC2VTK(sparseMesh,vtkSparseMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(vtkSparseMesh,MString("sparseMesh"),PointType(0,1,0),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> //vtkSparseMesh is of type vtkPoints => 204 3D points</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkPolyData> vtkPolyDataSparseMesh = vtkSmartPointer<vtkPolyData>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyDataSparseMesh->SetPoints(vtkSparseMesh);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkVertexGlyphFilter> vertexSparseMesh = vtkSmartPointer<vtkVertexGlyphFilter>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexSparseMesh->SetInputConnection(vtkPolyDataSparseMesh->GetProducerPort());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vertexSparseMesh->Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"> //setup ICP</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkIterativeClosestPointTransform> icp = vtkSmartPointer<vtkIterativeClosestPointTransform>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetSource(<span class="Apple-style-span" style="font-size: 13px; ">vertexMesh</span>->GetOutput()); </font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetTarget(vertexSparseMesh->GetOutput());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->DebugOn();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->GetLandmarkTransform()->SetModeToRigidBody();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetMaximumNumberOfIterations(40);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetMaximumNumberOfLandmarks(vertexSparseMesh->GetOutput()->GetNumberOfPoints());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetCheckMeanDistance(1);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->SetMaximumMeanDistance(0.0000001);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->Modified();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icp->Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkMatrix4x4> m = icp->GetMatrix();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << "The resulting matrix is: " << *m << std::endl;</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>// Transform the source points by the ICP solution</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkSmartPointer<vtkTransformPolyDataFilter> icpTransformFilter = vtkSmartPointer<vtkTransformPolyDataFilter>::New();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter->SetInput(vertexSparseMesh->GetOutput());</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter->SetTransform(icp);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>icpTransformFilter->Update();</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span></font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre"> </span> //visualize transformed mesh</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><span class="Apple-tab-span" style="white-space:pre">        </span>DebugRender::renderPoint(vertexSparseMesh->GetOutput()->GetPoints(),MString("mesh"),PointType(0,0,1),0);</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">}</font></div></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">Can you please give me some feedback.</font></div><div><font class="Apple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="Apple-style-span" face="Tahoma" size="2">Thanks a lot,</font></div><div><font class="Apple-style-span" face="Tahoma" size="2">padre</font></div>                                            </body>
</html>