[vtkusers] ICP not working well

David Doria daviddoria at gmail.com
Mon Mar 23 11:15:34 EDT 2009


I got it work, very odd behavior though. For the next guy:

vtkLinearTransform* inv = icp->GetLinearInverse();
seems to return something very bizarre and not the actual inverse that I
wanted.

I'm not sure if it's a good plan, but I directly modified the matrix of the
vtkIterativeClosestPointTransform:

    vtkTransformPolyDataFilter* ModelToScan =
vtkTransformPolyDataFilter::New();
    ModelToScan->SetInput(Model);
    icp->GetMatrix()->Invert();
    ModelToScan->SetTransform(icp);
    ModelToScan->Update();
    vtkPolyData* polydataModel = ModelToScan->GetOutput();

and it worked properly.

Thanks for the guidance Wes.

Thanks,

David


On Mon, Mar 23, 2009 at 10:33 AM, Wes Turner <wes.turner at kitware.com> wrote:

>
>
> On Mon, Mar 23, 2009 at 9:52 AM, David Doria <daviddoria at gmail.com> wrote:
>
>> Wes - you were right on, I switched which file was the target and it
>> worked much better. I guess I thought the implementation would have thrown
>> away points that didn't have a "good" match, but maybe it is and that
>> threshold is just larger than expected? Is that modifiable?
>>
>> Also, I am apparently doing something wrong with the inverse transform.
>> This works correctly, and brings the Scan to the Model:
>>     vtkTransformPolyDataFilter* ScanToModel =
>> vtkTransformPolyDataFilter::New();
>>     ScanToModel->SetInput(Scan);
>>     ScanToModel->SetTransform(icp);
>>     ScanToModel->Update();
>>     vtkPolyData* polydataScan = ScanToModel->GetOutput();
>>
>
> I don't believe there is a threshold, and can't find it in the
> documentation of the class.  I believe that this variant simply uses the
> closest point regardless of the actual distance.
>
>>
>> So I thought this would bring the Model to the Scan:
>>
>>     vtkTransformPolyDataFilter* ModelToScan =
>> vtkTransformPolyDataFilter::New();
>>     ModelToScan->SetInput(Model);
>>     vtkLinearTransform* inv = icp->GetLinearInverse();
>>     ModelToScan->SetTransform(inv);
>>     ModelToScan->Update();
>>     vtkPolyData* polydataModel = ModelToScan->GetOutput();
>>
>> but it ends up in a really wacky position. Is there more to it than simply
>> calling GetLinearInverse?
>
>
> First, make sure you do an icp->Update() before you grab the linear
> transform, just to be sure the ICP has actually run.  Other than that, I'm
> not sure what GetLinearInverse() does in the ICP algorithm and would have to
> look in the code.   If it grabs the transform matrix and explicitly inverts
> it, then this should probably work.  If it calls the icp->Inverse()
> function, then you will end in the same state as what you had originally.
> The way I normally do it is to call icp->Update, followed by
> icp-?GetLandMarkTransform()->GetMatrix() and then operate explicitly on the
> 4x4 matrix as I described in my last note.  There are undoubtedly other
> ways, but I have used this and know it works.  Check out the Doxygen pages
> if you need specific calls:
> http://www.vtk.org/doc/nightly/html/classvtkMatrix4x4.html
>
> - Wes
>
>
>>
>> Thanks,
>>
>> David
>>
>>
>>
>> On Mon, Mar 23, 2009 at 9:13 AM, Wes Turner <wes.turner at kitware.com>wrote:
>>
>>> My apologies ... as always haste makes waste.  I edited what I wrote to
>>> make it (slightly) more readable.
>>>
>>> On Mon, Mar 23, 2009 at 9:05 AM, Wes Turner <wes.turner at kitware.com>wrote:
>>>
>>>> David,
>>>>
>>>> I just took a quick look, so you probably need to do some analysis on
>>>> your own to fully resolve this issue.  Looking at the data sets, it appears
>>>> that you are sampling Bunny.vtp (source) and using it to sample points from
>>>> BunnyScan.vtp (target) using ICP.  Since BunnyScan only contains the front
>>>> side of Bunny, any points sampled from the rear surface of Bunny will not
>>>> find a true match and will end up pulling BunnyScan away from the front
>>>> surface and more toward the center of Bunny.  This is consistent with the
>>>> data you are showing.
>>>>
>>>> You might be able to get what you are looking for simply by swapping the
>>>> source and target in the ICP and using that as the transform to apply to
>>>> BunnyScan, moving it towards Bunny.  If you need the inverse transform
>>>> (moving Bunny towards BunnyScan) you will need to explicitly calculate the
>>>> inverse transform by grabbing the Matrix4x4 from the ICP on completion,
>>>> inverting it, and applying it as the transform to Bunny.  Directly inverting
>>>> the icp will not work as it just swaps source and target which will get you
>>>> right back to your current state.
>>>>
>>>> All of this is from memory, so your mileage may vary.
>>>>
>>>> - Wes
>>>>
>>>> On Sat, Mar 21, 2009 at 11:48 AM, David Doria <daviddoria at gmail.com>wrote:
>>>>
>>>>> Here are my input files / output file:
>>>>>
>>>>> http://www.rpi.edu/~doriad/Bunny/<http://www.rpi.edu/%7Edoriad/Bunny/>
>>>>>
>>>>> I am trying to register Bunny.vtp to BunnyScan.vtp and the result is in
>>>>> MatchedBunny.vtp
>>>>>
>>>>> Here are my settings:
>>>>>     vtkIterativeClosestPointTransform * icp =
>>>>> vtkIterativeClosestPointTransform::New();
>>>>>     icp->SetMaximumNumberOfIterations(1000);
>>>>>     icp->SetMaximumMeanDistance(1e-6);
>>>>>     icp->GetLandmarkTransform()->SetModeToRigidBody();
>>>>>
>>>>> I believe I am calling everything correctly because the resulting point
>>>>> cloud is much nearer than the original. However it seems to still be
>>>>> significantly wrong. Anyone know why this would be?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Wesley D. Turner, Ph.D.
>>>> Kitware, Inc.
>>>> R&D Engineer
>>>> 28 Corporate Drive
>>>> Clifton Park, NY 12065-8662
>>>> Phone: 518-371-3971 x120
>>>>
>>>
>>>
>>>
>>> --
>>> Wesley D. Turner, Ph.D.
>>> Kitware, Inc.
>>> R&D Engineer
>>> 28 Corporate Drive
>>> Clifton Park, NY 12065-8662
>>> Phone: 518-371-3971 x120
>>>
>>
>>
>> _______________________________________________
>> 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
>>
>>
>
>
> --
> Wesley D. Turner, Ph.D.
> Kitware, Inc.
> R&D Engineer
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x120
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090323/4a23f347/attachment.htm>


More information about the vtkusers mailing list