How to enable dt recognize the correct smartphone lens

I started to create distortion corrections for my new OnePlus 10 Pro 5G. I have my first set (draft) set of parameters defined for the super wide (2.3mm) and wide angle lenses (6.1mm). It seems that the only indication of the lens used is the focal length, as exiv2 doesn’t return any lens name information and exiftool reports Unique Camera Model : NE2213-OnePlus-OnePlus. dt recognizes the camera, but defaults always to the 2.3mm lens (maybe because it is the first in my config file).

Have I missed something in the configuration file, or is this just something that cannot be solved automatically? You can find below my configuration file, if there are obvious errors there. Also, how should I define the cropfactor as the different lenses have different cropfactors?

<lensdatabase>
    <camera>
       <maker>OnePlus</maker>
        <model>OnePlus 10 Pro 5G</model>
        <mount>oneplus10pro</mount>
        <cropfactor>6.52174</cropfactor>
    </camera>
    <lens>
        <maker>OnePlus</maker>
        <model>OnePlus 2.3mm</model>
        <mount>oneplus10pro</mount>
        <cropfactor>6.52174</cropfactor>
        <focal value="2.3" />
        <aperture value="2.2" />
        <type>rectilinear</type>
        <calibration>
            <distortion model="ptlens" focal="2.3" a="0.100" b="-0.344" c="0.067" />
        </calibration>
    </lens>
    <lens>
        <maker>OnePlus</maker>
        <model>OnePlus 6.1mm</model>
        <mount>oneplus10pro</mount>
        <cropfactor>3.7705</cropfactor>
        <focal value="6.1" />
        <aperture value="1.8" />
        <type>rectilinear</type>
        <calibration>
            <distortion model="ptlens" focal="6.1" a="0.051" b="-0.200" c="0.008" />
        </calibration>
    </lens>
</lensdatabase>

Uoload the two raw files. I have vacation so I can’t check right now.

1 Like

Here are the raw files. There is also another issue, when I have a lensfun.xml in C:\Users\<user>\AppData\Local\lensfun, dt detects only the OnePlus camera, nothing else. I thought the definitions in my personal folder are on top of the standard definitions, not replacing them, but have I misunderstood?

IMG20220803084902.dng (24.3 MB)
IMG20220803084821.dng (23.3 MB)

When I copied my OnePlus settings into the same folder where all the other lensfun xml files reside, I have now all the original camera/lens combinations available and my OnePlus test file.

I would try to not making two different lenses, but one lens with two different focal lengths

        <maker>OnePlus</maker>
        <model>OnePlus 2.3mm</model>
        <mount>oneplus10pro</mount>
        <cropfactor>6.52174</cropfactor>
        <focal value="2.3" />
        <aperture value="2.2" />
        <type>rectilinear</type>
        <calibration>
            <distortion model="ptlens" focal="2.3" a="0.100" b="-0.344" c="0.067" />
			<distortion model="ptlens" focal="6.1" a="0.051" b="-0.200" c="0.008" />
        </calibration>

Since DT recognizes the correct focal length it then should choose the corresponding correction data.

And I think crop factor doesn’t matter in your case as long as you insert the same number for cam and lens.

**And my lensfun data is in C:\Program Files\darktable\share\lensfun\version_1, so I wonder about your AppData folder. ** Edit: Got what you mean. I don’t know about this AppData folder.

Thanks for the tip, but unfortunately it didn’t work. I still get the 2.3mm lens as the default choise.

AppData in Win is the same as ~/.local/share in Linux. At least in Windows, it seems to replace the full lensfun database, and not append the contents to the global database.

It works for me :man_shrugging:

It’s just that the correction data for the 6.1 is pretty off.

But I’m wondering why the correction in DT is so different from hugin.

Yes, it works also for me. I had forgotten to restart dt. :blush:

For the 6.1mm lens, I had forgotten to change the projection to rectlinear, so that’s why the coefficients were totally off.

The difference for the ultrawide lens corrections in Hugin and in dt is interesting. When I looked at the image in dt, I thought that my quick shot was not perfect, and the error was caused by my inaccurate parameters. But as you @apostel338 noticed, it’s quite good in Hugin, but clearly off in dt.

I also added the parameters for the tele, so the full definitions are here.

<lensdatabase version="1">
    <camera>
       <maker>OnePlus</maker>
        <model>OnePlus 10 Pro 5G</model>
        <mount>oneplus10pro</mount>
        <cropfactor>6.52174</cropfactor>
    </camera>
    <lens>
        <maker>OnePlus</maker>
        <model>OnePlus 10 Pro</model>
        <mount>oneplus10pro</mount>
        <cropfactor>6.52174</cropfactor>
        <focal value="2.3" />
        <aperture value="2.2" />
        <type>rectilinear</type>
        <calibration>
            <distortion model="ptlens" focal="2.3" a="0.100" b="-0.344" c="0.067" />
            <distortion model="ptlens" focal="6.1" a="-0.017" b="0.043" c="-0.024" />
            <distortion model="ptlens" focal="7.4" a="0.017" b="-0.058" c="0.076" />
        </calibration>
    </lens>
</lensdatabase>

IMG20220803084802.dng (15.6 MB)

1 Like

Nice :+1:

I can’t see why. It’s also in ART / RT. :man_shrugging:

I suspect to be something in the process of creating the lens profile. But I’m not getting any better result out of this photo. Would you mind making a photo for the 2.3 with a clear seperate line at the top border over the whole width?

I tried also to change the definition to fisheye, but it didn’t change the outcome. I will shoot another image and share it. When I shot the image, I didn’t know that the phone screen doesn’t show the full image, only what would be included into the JPEG. This is what I believed I captured.

Here is a new take from the same place. The window in the picture is quite small, so I had to stand pretty close. I’ll try to define new correction parameters later today. For the “production quality” corrections I have to find a better target.

IMG20220816123041.dng (24.3 MB)

With the new image totally different coefficients, but still more curved view in dt than in Hugin.

This is what I get out of your photo. I recognized that I have to set the focal in the xml to something like 2.15 to get comparable results in DT. (Maybe tweak between ~ 2.14 - 2.17 to find your favourite result)

<distortion model="ptlens" focal="2.15" a="0.07297" b="-0.27346" c="0.02681" />


1 Like

Thanks for your help!

1 Like

Do you @asn have any idea why the outcome is different in Hugin and dt, and why the focal length needs tweaking? Should I file a report in Github?

The issue was that I had the aspect-ratio tag missing from my definitions. Now it looks correct with correct focal length. I got help, when I opened the issue in lensfun github. https://github.com/lensfun/lensfun/issues/1887

1 Like

Good to know. Looks like lensfun expects 3:2 and it must be explicitly stated if it differs. Something has been learned. :+1: