I took a look at the lensfun code, and it sure looks like it has a 
consistent formula with what is described in hugin, and what you (Bruno) 
said hugin does for lens distortion in terms of where radius=1.

To confirm this in practice, I used a panorama where I have an excellent 
fit of lens distortion (using only a,b,c parameters).   I let the TrX, TrY 
and TrZ also be optimized per image.  The difference mode in the panorama 
viewer shows almost entirely black.  The tifs were created only using TCA 
correction in darktable.

Then I exited darktable, updated the lens distortion coefs in the 
appropriate lensfun *.xml file, restarted darktable (so it would re-read 
the *.xml file), and recreated the tifs, but this time enabling distortion 
correction as well as TCA.

I made a copy of the *.pto file, and loaded the newly created tifs in 
hugin, and set a,b,c to 0.0

Looking at the panorama in difference mode, it looks identical to the one 
where I let hugin do the distortion correction.

I'm convinced, at least for distortion correction, you can indeed use the 
same a,b,c parameters for hugin and lensfun (where you specify the 
distortion model to be "ptlens"

I would assume that vignetting and TCA are also consistent between hugin 
and lensfun.

On Thursday, April 28, 2022 at 8:49:58 AM UTC-7 [email protected] wrote:

> On Thu, 28 Apr 2022 at 15:57, Jeff Welty wrote:
> > On Thursday, April 28, 2022 at 2:33:53 AM UTC-7 Bruno Postle wrote:
> >>
> >> Lensfun and panorama tools have a slightly different lens model, so it
> >> isn't always possible to transfer parameters (I'm not sure if there is
> >> a converter, it wouldn't be difficult to write one if it doesn't
> >> exist).
> >>
> > I thought the "ptlens" distortion model in lensfun was identical to 
> hugin's model. The lensfun tutorials show the a,b,c parameters from hugin's 
> optimization being directly used in lensfun data. The equations documented 
> sure looks the same, but you have far, far more experience at it so I will 
> look harder at it. FWIW here's the web page I referenced documenting the 
> lensfun "ptlens" model:
>
> I may be wrong, it has been a while. The panotools/Hugin lens model
> does have a couple of flaws: the a & c parameters have an odd number
> power, whereas usually only even number powers are used for lens
> models (which is why we generally recommend starting with just the b
> parameter); the angle of view parameter is locked to the width of the
> image, but the lens correction parameters are scaled to the narrowest
> dimension of the image (which is the height for landscape shots and
> the width for portrait shots), the result is that you can't reuse the
> same parameters for landscape/portrait images. These have never been
> fixed because it would break existing PTO projects and they don't
> cause any problems in practice.
>
> >> The idea of optimising a merged project to get more accurate lens
> >> parameters should work. There is a tool called ptomerge in the
> >> Panorama::Script perl module for merging projects, I'm not sure if it
> >> merges lenses, but if it doesn't you can reassign the lens in Hugin.
> >>
> > Oooh, thanks for that. I'm perl fluent so that's a nice place to start.
> > After a little more research, I read where image stabilization could be 
> a cause for the "d,e" parameters to legitimately be different for each 
> image. So I may need to link only the a,b,c parameters and allow d&e to be 
> optimized for each indvidual image.
>
> To the optimiser, the d & e parameters resemble the TrX and TrY
> parameters at the small scale, so sometimes you can get strange
> results mixing them.
>
> -- 
> Bruno
>

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/a8afb6d0-2843-4dc7-8a99-65249d1d6fe1n%40googlegroups.com.

Reply via email to