# How can we simulate barrel and pincushion distortion using VTK camera?

**URL:** https://discourse.vtk.org/t/how-can-we-simulate-barrel-and-pincushion-distortion-using-vtk-camera/14051
**Category:** Support
**Tags:** python
**Created:** [June 14, 2024, 7:43am UTC](https://discourse.vtk.org/t/how-can-we-simulate-barrel-and-pincushion-distortion-using-vtk-camera/14051 "2024-06-14T07:43:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vinzileo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/v/f6c823/32.png) [@vinzileo](https://discourse.vtk.org/u/vinzileo)
#### Post date: [June 14, 2024, 7:43am UTC](https://discourse.vtk.org/t/how-can-we-simulate-barrel-and-pincushion-distortion-using-vtk-camera/14051/1 "2024-06-14T07:43:07Z")

</div>

Hello everyone,

I’m trying to do some image matching projects using VTK, I have a 3d object and its scene taken by real camera, since my real camera is an iphone. there is always barrel distortion in real image, therefore from any angle towards its 3D object, I couldn’t find a view to perfectly match the real-time image with the 3D object’s view.

Is there anything can help with this, Will vtkWarpLens help? I haven’t investigated and tried it.  
Appreciate for any comments, thanks!

---

<div class="post-metadata">

### Author: ![vinzileo](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/v/f6c823/32.png) [@vinzileo](https://discourse.vtk.org/u/vinzileo)
#### Post date: [June 21, 2024, 2:32am UTC](https://discourse.vtk.org/t/how-can-we-simulate-barrel-and-pincushion-distortion-using-vtk-camera/14051/2 "2024-06-21T02:32:26Z")

</div>

Any suggestion is great, thanks!

---

<div class="post-metadata">

### Author: ![rexthor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rexthor/32/6481_2.png) [@rexthor](https://discourse.vtk.org/u/rexthor)
#### Post date: [June 26, 2024, 8:38pm UTC](https://discourse.vtk.org/t/how-can-we-simulate-barrel-and-pincushion-distortion-using-vtk-camera/14051/3 "2024-06-26T20:38:16Z")

</div>

One idea: if you could specify the distortion as a vector field, you could use [vtkWarpVector](https://vtk.org/doc/nightly/html/classvtkWarpVector.html#details). You’d add the vector distortion to the point data and then operate on it. Barrel and pincushion vector fields could be simulated with something like this from [SO](https://stackoverflow.com/questions/6199636/formulas-for-barrel-pincushion-distortion).
