[CREATE] Filling in LensFun database - solution (well, maybe)

Alexandre Prokoudine alexandre.prokoudine at gmail.com
Sat Jun 14 06:22:22 PDT 2008


Howdy,

We need a tool that would help us filling LensFun database with
geometry distortions data, right? (Not speaking about CA right now,
sorry)

So, I was playing with Inkscape/SVN last night and suddenly realized
that the solution probably has been sitting right in front of us for
quite a while now,

Among others the SVN version has several new live path effects,including:

1. Grid construction
2. Envelope deformation
3. Lattice deformation
4. Bend

Let's imagine our target that we shoot is a grid with known settings
like number of cells and sides ratio.

So we shoot this target and have its photo.

In Inkscape we have a template that has this rectangular grid. Then we
simply resize an imported photo of the target so that a required
number of corners would match the grid (question one: is it
possible?).

Then we apply either Envelope or Lattice deformation LPE and deform a
grid to make it match the curved grid on a photo (there is a
bottleneck, read below).

Now here is why I'm talking about LPE. It works this way:

There is always

a) an original path that is never changed (unless user specifically wants it),

b) a description of a change and

c) a final path that is stored separately so that all viewers that
don't handle LPE (all of them right now :)) would be able to show the
result of the effect.

So basically we have an original path with cusp nodes that have known
IDs and a final path with *predictable* node names and handles in
known positions that provide some curvature.

In case of Envelope Deformation LPE we have description of four
bending curves (top,bottom, left, right).

You get the idea? ;-)

Working with bezier curves is not a rocket science (lib2geom
developers would hate me for saying that :)),and extensions in
Inkscape can easily be written in Python, Ruby and even Perl (if my
memory serves me well). There are dozens of them written in Python
already.

Or this data can be processed on server side - a contributor just
upload a bunch of SVG files with some metadata (Lens model, focus
length) and off it goes.

The grid construction LPE is probably not required, but then if for
some reason a photo was taken from <90deg> angle, a user can always
make a new template where constructed grid would not be rectangular
(worst idea of mine, but I digress).

Now the promised bottleneck: with current version of Envelope LPE it's
impossible to deform a grid to a pincushion distortion type - corners
become rounded. Same goes for barrel distortion - it's close, but not
exactly what is needed.That's because each bending path of the four
uses same two nodes that another bending path uses. So each node would
require two sets of handles.

Have a look at the attached file.

Since there are several people on this list who are far more
knowledgable in SVG and Inkscape's internals than me, here comes my
second question: is it possible to solve the nodes issue on that side?

If it's not, well, we still can construct grids with individual
straight bezier curves that have known IDs and use Bend LPE (that's a
semi-new one as well) for each one to simulate barrel/pincushion
distortions, then compute XML code for LensFun DB from curvatures.

Do I make sense? :-)

Of course, someone could just create a new smart LPE that would apply
abc PanoTools lens model method to that grid, but that's another story
in another (C++) language.

Alexandre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: distort.svg.bz2
Type: application/x-bzip2
Size: 13570 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/create/attachments/20080614/bb3eba83/attachment.bin 


More information about the CREATE mailing list