Lens Calibration: A complete guide how to calibrate a lens.

Tips, Tricks, and Results
FotoLars
Posts: 35
Joined: Thu Jan 12, 2012 11:58 am
operating_system: Linux
System_Drive: X
32bit or 64bit: 64 Bit
motherboard: Intel D975XBX2
processor: Intel QuadCore Q6700
ram: 8 GB
Video Card: NVIDIA Quadro NVS 295
Hard_Drive_Capacity: 8 TB
Monitor/Display Make & Model: 2xDell 30", 5120x1600 (2x2560x1600)

Lens Calibration: A complete guide how to calibrate a lens.

Post by FotoLars »

Hi!

I also had problems to get Hugin to do the work for me, so instead I developed the method I describe below. Bibble Labs recommended me to use the SciLab method for the actual correction parameter calculations, and my workflow is based on the SciLab method. The results I received work very well.

I hope this guide will be of help for those, like myself, that need to have a particular non-calibrated lens calibrated but can't wait forever for "someone else" to do the work. For me, it was the lack of calibration data for the Nikkor AF-S 28-300mm f/3.5-5.6G ED VR, a very useful lens with severe distortion, that pushed me into learning how to make a proper lens calibration.

==================================
EDIT: New version 2012-04-11.

Guide v1.21, edited 2013-07-10 (dead links removed)


This guide assumes a working linux or MacOSX environment, with bash, awk, scilab-cli, g3data and exiftool. In Windows, you can use the Cygwin package in order to achieve a linux-like environment with command line tools.


1. Find, or possibly make, a good object to perform the calibration against.
A wall with straight lines, not brick or wood but rather glass/metal frames, plates, etc, or a huge paper print-out, will do.
If the intention is to calibrate a wide angle lens, you probably will have to find a good building somewhere, as the size of the print-out needed will be very, very large...
Please see the examples of used calibration photos below in this thread.

2. Take photos at an appropriate number of focal lengths at a proper distance from the reference object. A proper minimum distance would be 3 meters, possibly a bit more. With some lenses, eg. long-focusing extreme telephoto lenses, this distance will have to be longer than 3 meters. The difference in focal length in each step for a zoom lens should be maximum 15%, and, according to a posting by former Bibble Labs employee Colleen, 10% at the end points.

3. If needed and if possible, enhance the taken photos in order to emphasise the lines - maybe a higher contrast, black and white, etc, will show the lines even clearer. Try to work with high-quality photos that eventually will be saved in a jpg format.


New (added 2012-04-10):
=======================
afx has made some scripts that will make the entire data point collecting procedure much easier. Please see his posting below, where also an attached file with the scripts and instructions is present.

4. Collection and calculation of data points:
* Take your (first) calibration photo, in jpg format, and put in an empty folder. If you have several photos, which will be the case if you are calibrating a zoom lens, name them uniquely without reusing the filenames.
* Start the docal.sh script with the jpg file name given, such as ./docal.sh Example1.jpg
* Click carefully along a number, say at least five, of calibration lines in the photo, the whole width, in the upper and/or lower half of the photo, depending on how the calibration target looks like. In Example1.jpg, see later in this thread, one can use the three first lines at the top, and the three bottom ones. The middle line is more or less straight, so its contribution to the correction parameters will be very small - and can thus be omitted. Make sure that you mark 20 points along each line. If you want to use a smaller or larger amount of data points, then you must change points=20 to the wanted number in the file gens.awk before starting docal.sh. If there is severe (mustache) distortion present, a large numbers of data points will be needed - I have used a couple of hundred points in each line for my Nikkor 28-300 lens, as it has some heavy distortion at some focal lengths.
* Once you have clicked the 20 data points along each lines - check that the total number in the box in g3data is correct - click in g3data on the radio button "Export data to file" and accept the suggested filename.
* Click on the button "Export point data".
* Finish g3data by clicking on File/Quit in the menu.

You will now be given a set of files in the folder, and a screen printout of the a, b and c values that you can test in ASP or Bibble right away - in the lens tab, the manual part. If the correction is acceptable once applied on the test photo and possibly other photos, taken at the same focal length with this lens, proceed with the following step. If the correction parameters are not working well, clean out the produced files and redo the process from the beginning.

In the produced *.lcraw file, the a, b and c parameters for the present focal length are written in the form ASP or Bibble wants to have them, eg cal_abc: 28 0.0010249 -0.0161057 -0.0133131.


Collect these values in a plain text file, which once you are done with the entire calibration and have added lens and sensor data, will look something like in 5. below.

Here, you also have to find out what the multiplier = crop factor is. This value depends on your camera's sensor size, and will be given somewhere in your camera documentation. Typical values are 1.0 (full frame cameras of any brand), 1.5 (Nikon DX cameras, some Canon cameras, Sony, Pentax), 1.6 (some Canon cameras).



5. Lens profile:


begin lens
group: nikonSLR
multiplier: 1.0
aperture: 3.5
calibrated: true
menu_lens: Nikkor 28-100mm f/3.5-5.6G AF Zoom
cal_abc: 28 0.0010249 -0.0161057 -0.0133131
cal_abc: 34 -0.0002409 -0.0101266 -0.0100525
cal_abc: 38 0.0011318 -0.0110745 -0.0000946
cal_abc: 44 0.0004819 -0.0060696 -0.0009483
cal_abc: 50 0.0000239 -0.0019766 -0.0023835
cal_abc: 62 0.0017975 -0.0080446 0.0081529
cal_abc: 75 -0.0010158 0.0041892 -0.0064874
cal_abc: 85 -0.0019801 0.0083656 -0.0111948
cal_abc: 100 -0.0023195 0.0076052 -0.0077958
end



6. Arrange the correction parameters according to the format ASP uses them. Here you have to become familiar with the structure in the /opt/AfterShotPro/supportfiles/Profiles/LensProfiles (Linux) or C:\Program Files (x86)\Corel\Corel AfterShot Pro\supportfiles\Profiles\LensProfiles (Windows 7, 64-bit), how to gain access to edit these files and how to make them readable for all users in the system again. These files can also be edited in such a way that all lenses, and cameras, which you don't have or ever will encounter, can be removed from the according files - which in some cases eases the automatical lens detection quite a bit, as there will not be so many duplicates due to reused lens IDs from some manufacturers (eg Tamron, Sigma, etc).
-------------
jknight (ses his posting) has provided info about the file system structure in MacOSX:
"On Mac the directory structure is as follows. ( ../Applications/Corel AfterShot Pro.app/Contents/Resources/supportfiles/Profiles/LensProfiles )
To get there it is easiest to use Finder

1. Go to Applications folder.
2. Select Corel AfterShot Pro.app and right click and choose Show Package Contents.
3. Navigate from the directory that opens in Finder down to /Contents/Resources/supportfiles/Profiles/LensProfiles"
-------------


I have cleaned out everything not needed from my files, and removed the files not needed (other manufacturers, for instance).

The lens correction = ON preset I have, always works, in batch mode also, with the cameras and lenses I have, even when there are random photos from different cameras and lenses collected in a single folder.



At http://www.rottmerhusen.com/objektives/ ... ensid.html Robert Rottmerhusen has collected a vast amount of LensIDs for F-mount lenses compatible with Nikon. Please have a look at his site if you need additional data in order to help ASP determine what lens you have.

7. Make sure that you to Corel and to this forum upload the correction parameters you calculated, arranged as in 7. above, so that others also can use them and that they can be included in coming releases of ASP.
==================================


If there are good sites which provide information about lensIDs for other than F-mount lenses, please let me know and I will add such information to the guide.




Cheers,

Lars Nilsson
Lund, Sweden




============================================================================================================
============================================================================================================
An alternative method, based on manual data point collection and calculation.

I keep the information about the manual data point collecting method below as is, as it still is valid if you for some reason can't get afx's nice and easy-to-use scripts to run as intended.

1-3 - please see above.

4. Get the program g3data from http://www.frantz.fi/software/g3data.php, and use it to load the photos and collect data pairs (x,y) with simple mouse klicks along the lines in each photo. Modern linux versions all seem to have g3data available as a standard package in their software repositories. There also seem to exist some precompiled binaries for Windows available at http://www.frantz.fi/software/g3data.php.



Please see 4.1 to 4.10 below how to operate g3data.

------------------------------------
4.1. First, find out the size, in number of pixels in the X resp. Y dimension, for your photo to be used. It may be the size of your sensor, or smaller if the photo has been cropped. Try to work with as large photos as possible, as more and longer calibration lines will fit in the photo, thus increasing the reliability in the lens correction.

4.2. Click on "Set point X1 on X axis(1)" and then with the mouse click in the *lower left* corner in your photo, in the very corner itself - as close to the end of the photo as possible. Once the set point has been set completely correctly, you will be rewarded with a magenta coloured corner sign, which is placed along the X and Y axis, down in the very corner of the photo, with no space between the sign and the corner.

4.3. Once you have the set point aligned correctly, you can enter its value in the white box "X1 value:", which will be "1" (one).

4.4. Then click on "Set point X2 on X axis(2)", mark correctly the *lower right* corner of your photo with a mouse click and enter the numerical value of this point in the box "X2 value:". This value will be equal to the size in pixels, in the X dimension, you determined in 4.1 above.

4.5. Then click on "Set point Y1 on Y axis(3)", mark again the *lower left* corner and enter its value, again a "1" (one) in the box.

4.6. Finally, click on "Set point Y2 on Y axis(4)", mark the *upper left* corner and enter the numerical value in the white box. This value will be equal to the size in pixels, in the Y dimension, you determined in 4.1 above.

4.7. Make sure that the radio button for Point ordering is set to "No ordering".

4.8. Set "Export data to file", and here define a file where all data points will be collected.

4.9 . Then you can start to click along the optical calibration lines in the photo. If you make an error when placing a point along aline, press the button "Remove last point". For a regularly distorted line that displays either pincushion distortion or barrel distortion, I would think that anything from 5 to 20 data points will produce a sufficient result. However, if there is mustache distortion present, a larger set of data points will be needed in order to sorten out this type of distortion. Once the entire calibration calculation procedure has been completed, the values you have received should be tested on the actual photos you used for the calibration. You will notice if there are enough datapoints or if additional ones are needed.

4.10. Finallly, you export the data with a click on the "Export point data"-button.
------------------------------------

5. Use the collected data pairs, after having reformatted the ordering of the achived data pairs (can easily be done in Open/LibreOffice in a spreadsheet), with one set of vectors for each line, in the SciLab method (http://www.vintz.fr/lenscal/lenscal.html) recommended by Bibble Labs in 2010. Remember to use the pixel size of the photo given in 4.1 when setting the parameters in the SciLab scripts.

Run the SciLab script and receive shortly very accurate correction parameters a, b and c.


6. Please continue with 5. and onwards in the new guide above.

============================================================================================================
============================================================================================================
Last edited by FotoLars on Wed Jul 10, 2013 9:17 pm, edited 5 times in total.
jknights
Posts: 233
Joined: Mon Jan 16, 2012 8:10 am
operating_system: Mac
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Apple
processor: Intel 3.08GHz Dual processor Quad Core
ram: 24GB
Video Card: ATI Radeon X1600
sound_card: Intel HDA
Hard_Drive_Capacity: 6TB
Monitor/Display Make & Model: Apple Display
Location: Oliva, Valencia, Spain

Re: Lens Calibration: A complete guide how to calibrate a le

Post by jknights »

I'm no expert at this but I think what is below is correct.

On Mac the directory structure is as follows. ( ../Applications/Corel AfterShot Pro.app/Contents/Resources/supportfiles/Profiles/LensProfiles )
To get there it is easiest to use Finder

1. Go to Applications folder.
2. Select Corel AfterShot Pro.app and right click and choose Show Package Contents.
3. Navigate from the directory that opens in Finder down to /Contents/Resources/supportfiles/Profiles/LensProfiles

Follow instructions as above.
Still learning after all these years!
tomsi42
Posts: 126
Joined: Thu Jan 12, 2012 1:53 pm
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit
Location: Norway

Re: Lens Calibration: A complete guide how to calibrate a le

Post by tomsi42 »

Interesting guide. Does anyone have some example photos to show, so we can get an idea of sensible subjects to photograph.
FotoLars
Posts: 35
Joined: Thu Jan 12, 2012 11:58 am
operating_system: Linux
System_Drive: X
32bit or 64bit: 64 Bit
motherboard: Intel D975XBX2
processor: Intel QuadCore Q6700
ram: 8 GB
Video Card: NVIDIA Quadro NVS 295
Hard_Drive_Capacity: 8 TB
Monitor/Display Make & Model: 2xDell 30", 5120x1600 (2x2560x1600)

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FotoLars »

jknights wrote:I'm no expert at this but I think what is below is correct.

On Mac the directory structure is as follows. ( ../Applications/Corel AfterShot Pro.app/Contents/Resources/supportfiles/Profiles/LensProfiles )
To get there it is easiest to use Finder

1. Go to Applications folder.
2. Select Corel AfterShot Pro.app and right click and choose Show Package Contents.
3. Navigate from the directory that opens in Finder down to /Contents/Resources/supportfiles/Profiles/LensProfiles

Follow instructions as above.
Hi jknights!

Thanks for the additional information regarding the OS X file system structure :-) !


Cheers,

Lars Nilsson
Lund, Sweden
FotoLars
Posts: 35
Joined: Thu Jan 12, 2012 11:58 am
operating_system: Linux
System_Drive: X
32bit or 64bit: 64 Bit
motherboard: Intel D975XBX2
processor: Intel QuadCore Q6700
ram: 8 GB
Video Card: NVIDIA Quadro NVS 295
Hard_Drive_Capacity: 8 TB
Monitor/Display Make & Model: 2xDell 30", 5120x1600 (2x2560x1600)

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FotoLars »

tomsi42 wrote:Interesting guide. Does anyone have some example photos to show, so we can get an idea of sensible subjects to photograph.
Hi!

In the very first link in the guide, issued by Bibble Labs, http://bibblelabs.com/products/bibble5/ ... ation.html, there is an example of a useful building - as well as an example of what not to use as a calibration photo.

I managed to find a building outfitted with a ceramic plate facade, and I used that wall in my calibration photos for several lenses, please see the attached example.

Sorry for the lousy quality - these fora seem to only permit pictures at most 950 pixels wide and 800 pixels high...


Cheers,

Lars Nilsson
Lund, Sweden
You do not have the required permissions to view the files attached to this post.
afx
Posts: 1675
Joined: Thu Jan 12, 2012 1:38 pm
operating_system: Linux
System_Drive: N/A
32bit or 64bit: 64 Bit
Video Card: FirePro 4900
Monitor/Display Make & Model: NEC PA301w, ColorMunki
Location: München

Re: Lens Calibration: A complete guide how to calibrate a le

Post by afx »

tomsi42 wrote:Interesting guide. Does anyone have some example photos to show, so we can get an idea of sensible subjects to photograph.
While one could surely find a more accurate pattern, this one worked fine for me:
XZ-1-6.48 mm.jpg
cheers
afx
You do not have the required permissions to view the files attached to this post.
Send bugs to the Monkey // AfterShot Kickstart Guide // sRGB clipping sucks and Adobe RGB is just as bad
Bibble since 2005 // W7 64 on quad Phenom // Ubuntu 14.4 on quad i7 and dualcore AMD // Images
tomsi42
Posts: 126
Joined: Thu Jan 12, 2012 1:53 pm
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit
Location: Norway

Re: Lens Calibration: A complete guide how to calibrate a le

Post by tomsi42 »

Thanks for the samples. Now I only need to find the time to get some profiles for my Olympus ZD 28mm f/2.8
FalCT60
Posts: 153
Joined: Wed Feb 15, 2012 11:29 am
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FalCT60 »

FotoLars wrote:
tomsi42 wrote:Interesting guide. Does anyone have some example photos to show, so we can get an idea of sensible subjects to photograph.
I managed to find a building outfitted with a ceramic plate facade, and I used that wall in my calibration photos for several lenses, please see the attached example.
Hello,

According to Hugin calibration tool, the calibration values for your lens should be :
a= 0.056
b= -0.223
c= 0.257

Could you compare with the values the method you describe return ?

Regards,

J.-Luc
FotoLars
Posts: 35
Joined: Thu Jan 12, 2012 11:58 am
operating_system: Linux
System_Drive: X
32bit or 64bit: 64 Bit
motherboard: Intel D975XBX2
processor: Intel QuadCore Q6700
ram: 8 GB
Video Card: NVIDIA Quadro NVS 295
Hard_Drive_Capacity: 8 TB
Monitor/Display Make & Model: 2xDell 30", 5120x1600 (2x2560x1600)

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FotoLars »

FalCT60 wrote:
FotoLars wrote:
tomsi42 wrote:Interesting guide. Does anyone have some example photos to show, so we can get an idea of sensible subjects to photograph.
I managed to find a building outfitted with a ceramic plate facade, and I used that wall in my calibration photos for several lenses, please see the attached example.
Hello,

According to Hugin calibration tool, the calibration values for your lens should be :
a= 0.056
b= -0.223
c= 0.257

Could you compare with the values the method you describe return ?

Regards,

J.-Luc
Hi!

For what lens and, if applicable, what focal length, are the Hugin values above calculated?

Results for all lenses I have calibrated are published in the profile files distributed with ASP and the last version of B5, so please have a look in those - see above for the exact location of these searchable plain text files in your OS.

As I, and others, have said regarding lens detection in Hugin and its properties, please see http://forum.corel.com/EN/viewtopic.php?f=90&t=45656, I would not trust the values from Hugin very much - but that can always be checked against a photo; if the parameters are OK, the optical distortions will be reduced to more or less no distortion at all.

I have seen, when testing some given calibrations in the B5/ASP files, for example for my little Canon S95 pocket toy camera, that the values, calculated by someone I have no clue of, for this particular camera are not very accurate for the circumstances (eg. distance) I compared against in a real-world photo - but even with the not fully accurate vaules, the result is rather good compared with the uncalibrated photo. I tested at a few different focal lengths and distances, and there are noticable differences.

Remember though, that the correction parameters probably depends quite a bit on the distance to the reference pattern, as discussed in this thread: http://support.bibblelabs.com/forums/vi ... nce#p94867.

If one is to follow the thoughts, formulated as " * Then place it on a flat surface, e.g. a wall. * Mount your camera on a tripod * Set your camera to ISO100, F8 (or similar) * Choose the distance so the target fills the frame (should always give 50-80x focal length) * Take photos at the desired focal lengths (maybe with timer). * Mark ..." in this topic by "Klonk", http://support.bibblelabs.com/forums/vi ... nce#p74952, one must move quite a bit between each shot for a zoom lens - and what should the distance then be?

I have also compared the results with a certain test photo when lens correction has been applied in Nikon Capture NX2 and in Lightroom 3/4 - and there is a HUGE difference for the optical result for this very photo for these two programs! In this matter, I somehow tend to trust the lens manufacturer (Nikon) and their knowledge in optics more than Adobe - but who is right? I don't know, that is for sure!

Correction paramters will most certainly never be fully perfect - but they will at least fix most of the issues with lenses having visible distortion.

What values did you receive for the 50 mm Nikkor lens you calibrated earlier? (http://support.bibblelabs.com/forums/vi ... e&start=15)

If you want, you can PM me and we can calculate, compare and discuss values for this lens of yours :-) !


Cheers,

Lars Nilsson
Lund, Sweden
FalCT60
Posts: 153
Joined: Wed Feb 15, 2012 11:29 am
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FalCT60 »

FotoLars wrote:
FalCT60 wrote:.../...
According to Hugin calibration tool, the calibration values for your lens should be :
.../...
Hi!

For what lens and, if applicable, what focal length, are the Hugin values above calculated?
Hello,
I just used the picture you attached to your post.
From the exif, Hugin reported it as a 42mm.
I then set 50 points, clicked Optimize and copied the results.
If they are very close to the ones you got, then the pictures from which I tried to calibrate my lenses are not suitable.
If they differ much from yours, then I have to bother. :x
FotoLars wrote:Results for all lenses I have calibrated are published in the profile files distributed with ASP and the last version of B5, so please have a look in those - see above for the exact location of these searchable plain text files in your OS.
OK, I'll search for this lens across the files and compare.
FotoLars wrote:As I, and others, have said regarding lens detection in Hugin and its properties, please see http://forum.corel.com/EN/viewtopic.php?f=90&t=45656, I would not trust the values from Hugin very much - but that can always be checked against a photo; if the parameters are OK, the optical distortions will be reduced to more or less no distortion at all.
Well, so far, the results I got from Hugin were really awfully awful! :twisted:
For my Nikkor 20mm f/2.8 AIS, I had to spend much time tuning the values until I could get not too bad results. I'll post an example of what the first values I got resulted in when I have some time.
I then tried to calibrate my 500mm f/8 Reflex and, there again, the final picture was worse than the original : the corrected phto showed highly pronounced barrel distorsion.
FotoLars wrote:.../...
Remember though, that the correction parameters probably depends quite a bit on the distance to the reference pattern, as discussed in this thread: http://support.bibblelabs.com/forums/vi ... nce#p94867.
Yes, that seems obvious. Hence my problems finding a suitable subject for my 500mm... :roll:
FotoLars wrote:If one is to follow the thoughts, formulated as " * Then place it on a flat surface, e.g. a wall. * Mount your camera on a tripod * Set your camera to ISO100, F8 (or similar) * Choose the distance so the target fills the frame (should always give 50-80x focal length) * Take photos at the desired focal lengths (maybe with timer). * Mark ..." in this topic by "Klonk", http://support.bibblelabs.com/forums/vi ... nce#p74952, one must move quite a bit between each shot for a zoom lens - and what should the distance then be?
Same as above
FotoLars wrote:.../...
What values did you receive for the 50 mm Nikkor lens you calibrated earlier? (http://support.bibblelabs.com/forums/vi ... e&start=15)
I didn't try with this one yet.
But I tried something else that I thought would be a rather good idea : as the Nikkor 24-70 f/2.8 AFS I own is calibrated, I tried the GML calibration procedure described there http://graphics.cs.***/en/science/re ... ration/cpp with 3 patterns at 35mm focal length.
Unfortunately, the values it returned were very far from those from B5/ASP.
FotoLars wrote: If you want, you can PM me and we can calculate, compare and discuss values for this lens of yours :-) !
Then, I have to find a suitable pattern first. Thanks.

Regards,

J.-Luc
afx
Posts: 1675
Joined: Thu Jan 12, 2012 1:38 pm
operating_system: Linux
System_Drive: N/A
32bit or 64bit: 64 Bit
Video Card: FirePro 4900
Monitor/Display Make & Model: NEC PA301w, ColorMunki
Location: München

Re: Lens Calibration: A complete guide how to calibrate a le

Post by afx »

FalCT60 wrote:Well, so far, the results I got from Hugin were really awfully awful! :twisted:
Neither the results I got from the old hugin tutorial nor from the new calibrate_lens_gui where particularly trustworthy or encouraging.

I had tried the scilab method previously (as Jeff had pointed me to it ages ago) but always messed up in the point reading&transfer. The tip with g3data by Lars finally made the picture complete.
I now have scripted the whole thing and getting a new lens calibrated is really just a bit of clicking....

cheers
afx
Send bugs to the Monkey // AfterShot Kickstart Guide // sRGB clipping sucks and Adobe RGB is just as bad
Bibble since 2005 // W7 64 on quad Phenom // Ubuntu 14.4 on quad i7 and dualcore AMD // Images
FalCT60
Posts: 153
Joined: Wed Feb 15, 2012 11:29 am
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FalCT60 »

afx wrote:
FalCT60 wrote:Well, so far, the results I got from Hugin were really awfully awful! :twisted:
Neither the results I got from the old hugin tutorial nor from the new calibrate_lens_gui where particularly trustworthy or encouraging.
OK, I see. Thank you.
afx wrote:I had tried the scilab method previously (as Jeff had pointed me to it ages ago) but always messed up in the point reading&transfer. The tip with g3data by Lars finally made the picture complete.
I now have scripted the whole thing and getting a new lens calibrated is really just a bit of clicking....
I think I just understood what was wrong with scilab method for me : I only set 1 pair of points for each line, but maybe one must set as many points as possible for each line. :oops:

Regards,

J.-Luc
FotoLars
Posts: 35
Joined: Thu Jan 12, 2012 11:58 am
operating_system: Linux
System_Drive: X
32bit or 64bit: 64 Bit
motherboard: Intel D975XBX2
processor: Intel QuadCore Q6700
ram: 8 GB
Video Card: NVIDIA Quadro NVS 295
Hard_Drive_Capacity: 8 TB
Monitor/Display Make & Model: 2xDell 30", 5120x1600 (2x2560x1600)

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FotoLars »

FalCT60 wrote:
afx wrote:
FalCT60 wrote:Well, so far, the results I got from Hugin were really awfully awful! :twisted:
Neither the results I got from the old hugin tutorial nor from the new calibrate_lens_gui where particularly trustworthy or encouraging.
OK, I see. Thank you.
afx wrote:I had tried the scilab method previously (as Jeff had pointed me to it ages ago) but always messed up in the point reading&transfer. The tip with g3data by Lars finally made the picture complete.
I now have scripted the whole thing and getting a new lens calibrated is really just a bit of clicking....
I think I just understood what was wrong with scilab method for me : I only set 1 pair of points for each line, but maybe one must set as many points as possible for each line. :oops:

Regards,

J.-Luc
Hi!

Yes, a certain number of datapoints is required in order to get an accurate calibration profile. I tested quite a bit last night how few points that were needed, and I realised that maybe something around 20 datapoints for a regular distortion will be good enough, while for heavy mustache distortion (wave-formed, as a mustache) rather many more than 20 points are needed. For some focal lengths in my Nikkor 28-300 lens I used around 120 datapoints - carefully following the distorted line along its path in the photo.

afx has made some very well-working scripts that start the datapoint sampling program (g3data), arrange the datapoint values, call scilab and finally produce the a, b and c coefficients for that very photo (focal length) that he will publish soon, and I am going to update the guide how to use his very useful scripts - now it will be easier than before; as he said: "...a bit of clicking" :-) !

A good calibration photo is, however, still needed - and a certain degree of accuracy when setting the datapoints.


Cheers,


Lars Nilsson
Lund, Sweden
FalCT60
Posts: 153
Joined: Wed Feb 15, 2012 11:29 am
operating_system: Windows XP Pro
System_Drive: C
32bit or 64bit: 32 Bit

Re: Lens Calibration: A complete guide how to calibrate a le

Post by FalCT60 »

FotoLars wrote:
FalCT60 wrote:.../...
I think I just understood what was wrong with scilab method for me : I only set 1 pair of points for each line, but maybe one must set as many points as possible for each line. :oops:
Hi!

Yes, a certain number of datapoints is required in order to get an accurate calibration profile. I tested quite a bit last night how few points that were needed, and I realised that maybe something around 20 datapoints for a regular distortion will be good enough, while for heavy mustache distortion (wave-formed, as a mustache) rather many more than 20 points are needed. For some focal lengths in my Nikkor 28-300 lens I used around 120 datapoints - carefully following the distorted line along its path in the photo.
That's what I feared... and that explains why I had to spend so much time with the 20mm for not sastisfying results : this lens produces photos with high irregular distortion - the so-called mustache -. :(
Another thing : I always worked on NEF or heavy JPEG files, and got many problems when setting the datapoints across the lines (the view reduces after setting each point, and I have to click on to "fit to window" to restore it). :x Working on your photo, the other night, I noticed those problems didn't occur. I thought that the higher the quality, the better the results, but it seems it's not true. :o Funny. :roll:
FotoLars wrote:afx has made some very well-working scripts that start the datapoint sampling program (g3data), arrange the datapoint values, call scilab and finally produce the a, b and c coefficients for that very photo (focal length) that he will publish soon, and I am going to update the guide how to use his very useful scripts - now it will be easier than before; as he said: "...a bit of clicking" :-) !
Nice. No more excuse for a bad photo because a non-calibrated lens! :lol:
FotoLars wrote:A good calibration photo is, however, still needed - and a certain degree of accuracy when setting the datapoints.
Then, maybe the target Klonk made could be useful, couldn't it ?

J.-Luc
afx
Posts: 1675
Joined: Thu Jan 12, 2012 1:38 pm
operating_system: Linux
System_Drive: N/A
32bit or 64bit: 64 Bit
Video Card: FirePro 4900
Monitor/Display Make & Model: NEC PA301w, ColorMunki
Location: München

Re: Lens Calibration: A complete guide how to calibrate a le

Post by afx »

Ok, here is my itty bitty script.
In the end it is rather trivial.

A shell script takes a JPG name as its sole parameter.
It uses exiftool to find out the image dimensions and then passes those and the JPG name to g3data.
In g3data you have to mark your lines (the script expects 20 points per line), at least three, five seems to be better.
I use lines stretching over the complete width using only the top or bottom half of the image and stay away from lines crossing the center.
When done, save the result with the default name proposed by g3data.

The script will do the rest and give you a line for testing (I mangle that to show "," instead of "." for the decimal point so it can be used in AS directly on non US machines) and one line to include in the AS lens profile DB.

I have modified the original lenscal.sci file to not require the scilab GUI but work with the commandline version.

As this uses bash and awk, it will run out of the box on Linux (your distro should supply scilab-cli, g3data and exiftool) and should run on MacOS when you get scilab and g3data running. If you are on Windows, I suggest getting Cygwin to get a decent command line environment....

enjoy
afx
You do not have the required permissions to view the files attached to this post.
Send bugs to the Monkey // AfterShot Kickstart Guide // sRGB clipping sucks and Adobe RGB is just as bad
Bibble since 2005 // W7 64 on quad Phenom // Ubuntu 14.4 on quad i7 and dualcore AMD // Images