-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlensfun.h
2419 lines (2183 loc) · 85.5 KB
/
lensfun.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- mode:c++ -*- */
/*
LensFun - a library for maintaining a database of photographical lenses,
and providing the means to correct some of the typical lens distortions.
Copyright (C) 2007 by Andrew Zabolotny
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __LENSFUN_H__
#define __LENSFUN_H__
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
/** Helper macro to make C/C++ work similarly */
# define C_TYPEDEF(t,c)
#else
# define C_TYPEDEF(t,c) typedef t c c;
#endif
/**
* @file lensfun.h
* This file defines the interface to the lensfun library.
*/
/*----------------------------------------------------------------------------*/
/**
* @defgroup Auxiliary Auxiliary definitions and functions
* @brief These functions will help handling basic structures of the library.
* @{
*/
/// Major library version number
#define LF_VERSION_MAJOR 0
/// Minor library version number
#define LF_VERSION_MINOR 3
/// Library micro version number
#define LF_VERSION_MICRO 0
/// Library bugfix number
#define LF_VERSION_BUGFIX 0
/// Full library version
#define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
/// Latest database version supported by this release
#define LF_MAX_DATABASE_VERSION 1
#if defined CONF_LENSFUN_STATIC
/// This macro expands to an appropiate symbol visibility declaration
# define LF_EXPORT
#else
# ifdef CONF_SYMBOL_VISIBILITY
# if defined PLATFORM_WINDOWS
# define LF_EXPORT __declspec(dllexport)
# elif defined CONF_COMPILER_GCC || __clang__
# define LF_EXPORT __attribute__((visibility("default")))
# else
# error "I don't know how to change symbol visibility for your compiler"
# endif
# else
# if defined PLATFORM_WINDOWS || defined _MSC_VER
# define LF_EXPORT __declspec(dllimport)
# else
# define LF_EXPORT
# endif
# endif
#endif
#ifndef CONF_LENSFUN_INTERNAL
/// For marking deprecated functions, see http://stackoverflow.com/a/21265197
# ifdef __GNUC__
# define DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER)
# define DEPRECATED __declspec(deprecated)
# else
# pragma message("WARNING: You need to implement DEPRECATED for this compiler")
# define DEPRECATED
# endif
#else
# define DEPRECATED
#endif
/// C-compatible bool type; don't bother to define Yet Another Boolean Type
#define cbool int
/**
* The storage of "multi-language" strings is simple yet flexible,
* handy and effective. The first (default) string comes first, terminated
* by \\0 as usual, after that a language code follows, then \\0 again,
* then the translated value and so on. The list terminates as soon as
* a \\0 is encountered instead of next string, e.g. last string in list
* is terminated with two null characters.
*/
typedef char *lfMLstr;
/** liblensfun error codes: negative codes are -errno, positive are here */
enum lfError
{
/** No error occured */
LF_NO_ERROR = 0,
/** Wrong XML data format */
LF_WRONG_FORMAT
};
C_TYPEDEF (enum, lfError)
/**
* The basics of memory allocation: never free objects allocated by the
* library yourselves, instead use this function. It is a direct
* equivalent of standard C free(), however you should not use free()
* in the event that the library uses a separate heap.
* @param data
* A pointer to memory to be freed.
*/
LF_EXPORT void lf_free (void *data);
/**
* @brief Get a string corresponding to current locale from a multi-language
* string.
*
* Current locale is determined from LC_MESSAGES category at the time of
* the call, e.g. if you change LC_MESSAGES at runtime, next calls to
* lf_mlstr_get() will return the string for the new locale.
*/
LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
/**
* @brief Add a new translated string to a multi-language string.
*
* This uses realloc() so returned value may differ from input.
* @param str
* The string to append to. Can be NULL.
* @param lang
* The language for the new added string. If NULL, the default
* string is replaced (the first one in list, without a language
* designator).
* @param trstr
* The translated string
* @return
* The reallocated multi-language string. To free a multi-language
* string, use lf_free().
*/
LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
/**
* @brief Create a complete copy of a multi-language string.
*
* @param str
* The string to create a copy of
* @return
* A new allocated multi-language string
*/
LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
/** @} */
/*----------------------------------------------------------------------------*/
/**
* @defgroup Mount Structures and functions for camera mounts
* @brief These structures and functions allow to define and examine
* the properties of camera mounts.
* @{
*/
/**
* @brief This structure contains everything specific to a camera mount.
*
* Objects of this type are usually retrieved from the database
* by using queries (see lfDatabase::FindMount() / lf_db_find_mount()),
* and can be created manually in which case it is application's
* responsability to destroy the object when it is not needed anymore.
*/
struct LF_EXPORT lfMount
{
/** @brief Camera mount name.
*
* Mount names for fixed-lens cameras -- and only they -- must start with a
* lower case letter.
*/
lfMLstr Name;
/** A list of compatible mounts */
char **Compat;
#ifdef __cplusplus
/**
* @brief Initialize a new mount object. All fields are set to 0.
*/
lfMount ();
/**
* Assignment operator
*/
lfMount &operator = (const lfMount &other);
/**
* @brief Destroy a mount object. All allocated fields are freed.
*/
~lfMount ();
/**
* @brief Add a string to mount name.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Name field.
* @param lang
* The language this field is in.
*/
void SetName (const char *val, const char *lang = NULL);
/**
* @brief Add a mount name to the list of compatible mounts.
* @param val
* The identifier of the compatible mount.
*/
void AddCompat (const char *val);
/**
* @brief Check if a mount object is valid.
* @return
* true if required fields are ok.
*/
bool Check ();
#endif
};
C_TYPEDEF (struct, lfMount)
/**
* @brief Create a new mount object.
* @return
* A new empty mount object.
* @sa
* lfMount::lfMount()
*/
LF_EXPORT lfMount *lf_mount_new ();
/**
* @brief Destroy a lfMount object.
*
* This is equivalent to C++ "delete mount".
* @param mount
* The mount object to destroy.
* @sa
* lfMount::~lfMount()
*/
LF_EXPORT void lf_mount_destroy (lfMount *mount);
/**
* @brief Copy the data from one lfMount structure into another.
* @param dest
* The destination object
* @param source
* The source object
* @sa
* lfMount::operator = (const lfMount &)
*/
LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
/** @sa lfMount::Check */
LF_EXPORT cbool lf_mount_check (lfMount *mount);
/** @} */
/*----------------------------------------------------------------------------*/
/**
* @defgroup Camera Structures and functions for cameras
* @brief These structures and functions allow to define and examine
* the properties of a camera model.
* @{
*/
/**
* @brief Camera data. Unknown fields are set to NULL.
*
* The Maker and Model fields must be filled EXACTLY as they appear in the EXIF
* data, since this is the only means to detect camera automatically
* (upper/lowercase is not important, though). Some different cameras
* (e.g. Sony Cybershot) are using same EXIF id info for different models, in
* which case the Variant field should contain the exact model name, but, alas,
* we cannot automatically choose between such "twin" cameras.
*/
struct LF_EXPORT lfCamera
{
/** @brief Camera maker (ex: "Rollei") -- same as in EXIF */
lfMLstr Maker;
/** @brief Model name (ex: "Rolleiflex SL35") -- same as in EXIF */
lfMLstr Model;
/** @brief Camera variant. Some cameras use same EXIF id for different models */
lfMLstr Variant;
/** @brief Camera mount type (ex: "QBM") */
char *Mount;
/** @brief Camera crop factor (ex: 1.0). Must be defined. */
float CropFactor;
/** @brief Camera matching score, used while searching: not actually a camera parameter */
int Score;
#ifdef __cplusplus
/**
* @brief Initialize a new camera object. All fields are set to 0.
*/
lfCamera ();
/**
* Copy constructor.
*/
lfCamera (const lfCamera &other);
/**
* @brief Destroy a camera object. All allocated fields are freed.
*/
~lfCamera ();
/**
* Assignment operator
*/
lfCamera &operator = (const lfCamera &other);
/**
* @brief Add a string to camera maker.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Maker field.
* @param lang
* The language this field is in.
*/
void SetMaker (const char *val, const char *lang = NULL);
/**
* @brief Add a string to camera model.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Model field.
* @param lang
* The language this field is in.
*/
void SetModel (const char *val, const char *lang = NULL);
/**
* @brief Add a string to camera variant.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Variant field.
* @param lang
* The language this field is in.
*/
void SetVariant (const char *val, const char *lang = NULL);
/**
* @brief Set the value for camera Mount.
* @param val
* The new value for Mount.
*/
void SetMount (const char *val);
/**
* @brief Check if a camera object is valid.
* @return
* true if the required fields are ok.
*/
bool Check ();
#endif
};
C_TYPEDEF (struct, lfCamera)
/**
* @brief Create a new camera object.
* @return
* A new empty camera object.
* @sa
* lfCamera::lfCamera
*/
LF_EXPORT lfCamera *lf_camera_new ();
/**
* @brief Destroy a lfCamera object.
*
* This is equivalent to C++ "delete camera".
* @param camera
* The camera object to destroy.
* @sa
* lfCamera::~lfCamera
*/
LF_EXPORT void lf_camera_destroy (lfCamera *camera);
/**
* @brief Copy the data from one lfCamera structure into another.
* @param dest
* The destination object
* @param source
* The source object
* @sa
* lfCamera::operator = (const lfCamera &)
*/
LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
/** @sa lfCamera::Check */
LF_EXPORT cbool lf_camera_check (lfCamera *camera);
/** @} */
/*----------------------------------------------------------------------------*/
/**
* @defgroup Lens Structures and functions for lenses
* @brief These structures and functions allow to define and examine
* the properties of a lens.
* @{
*/
/**
* @brief The lensfun library implements several lens distortion models.
* This enum lists them.
*
* Distortion usually heavily depends on the focal length, but does not depend
* on the aperture. In the following, \f$r_d\f$ refers to the distorted radius
* (normalised distance to image center), and \f$r_u\f$ refers to the
* undistorted, corrected radius. See section \ref actualorder for further
* information.
*
* For a popular explanation of lens distortion see
* http://www.vanwalree.com/optics/distortion.html
*/
enum lfDistortionModel
{
/** @brief Distortion parameters are unknown */
LF_DIST_MODEL_NONE,
/**
* @brief 3rd order polynomial model, which is a subset of the PTLens
* model.
*
* \f[r_d = r_u \cdot (1 - k_1 + k_1 r_u^2)\f]
* The corresponding XML attribute is called “k1”. It defaults to 0.
* Ref: http://www.imatest.com/docs/distortion.html
*/
LF_DIST_MODEL_POLY3,
/**
* @brief 5th order polynomial model.
*
* \f[r_d = r_u \cdot (1 + k_1 r_u^2 + k_2 r_u^4)\f]
* The corresponding XML attributes are called “k1” and “k2”. They default
* to 0.
*/
LF_DIST_MODEL_POLY5,
/**
* @brief PTLens model, which is also used by Hugin.
*
* \f[r_d = r_u \cdot (a r_u^3 + b r_u^2 + c r_u + 1 - a - b - c)\f]
* The corresponding XML attributes are called “a”, “b”, and “c”. They
* default to 0.
*/
LF_DIST_MODEL_PTLENS,
};
C_TYPEDEF (enum, lfDistortionModel)
/**
* @brief Lens distortion calibration data.
* Lens distortion depends only of focal length. The library will interpolate
* the coefficients values if data for the exact focal length is not available.
*/
struct lfLensCalibDistortion
{
/** @brief The type of distortion model used */
enum lfDistortionModel Model;
/** @brief Focal length in mm at which this calibration data was taken */
float Focal;
/** @brief Distortion coefficients, dependent on model (a,b,c or k1 or k1,k2) */
float Terms [3];
};
C_TYPEDEF (struct, lfLensCalibDistortion)
/**
* @brief The lensfun library supports several models for lens lateral
* chromatic aberrations (also called transversal chromatic
* aberrations, TCA).
*
* TCAs depend on focal length, but does not depend of the aperture. In the
* following, \f$r_d\f$ refers to the distorted radius (normalised distance to
* image center), and \f$r_u\f$ refers to the undistorted, corrected radius.
* See section \ref actualorder for further information.
*
* For a popular explanation of chromatic aberrations see
* http://www.vanwalree.com/optics/chromatic.html
*/
enum lfTCAModel
{
/** @brief No TCA correction data is known */
LF_TCA_MODEL_NONE,
/**
* @brief Linear lateral chromatic aberrations model.
*
* \f[\begin{aligned}
* r_{d,R} &= r_{u,R} k_R \\
* r_{d,B} &= r_{u,B} k_B
* \end{aligned}\f]
* The corresponding XML attributes are called “kr” and “kb”. They default
* to 1.
* Ref: http://cipa.icomos.org/fileadmin/template/doc/TURIN/403.pdf
*/
LF_TCA_MODEL_LINEAR,
/**
* @brief Third order polynomial.
*
* \f[\begin{aligned}
* r_{d,R} &= r_{u,R} \cdot (b_R r_{u,R}^2 + c_R r_{u,R} + v_R) \\
* r_{d,B} &= r_{u,B} \cdot (b_B r_{u,B}^2 + c_B r_{u,B} + v_B)
* \end{aligned}\f]
* The corresponding XML attributes are called “br”, “cr”,
* “vr”, “bb”, “cb”, and “vb”. vr and vb default to 1, the rest to 0.
* Ref: http://wiki.panotools.org/Tca_correct
*/
LF_TCA_MODEL_POLY3
};
C_TYPEDEF (enum, lfTCAModel)
/**
* @brief Laterlal chromatic aberrations calibration data.
*
* Chromatic aberrations depend on focal length and aperture value. The library
* will interpolate the coefficients if data for the exact focal length and
* aperture value is not available with priority for a more exact focal length.
*/
struct lfLensCalibTCA
{
/** @brief The lateral chromatic aberration model used */
enum lfTCAModel Model;
/** @brief Focal length in mm at which this calibration data was taken */
float Focal;
/** @brief The coefficients for TCA, dependent on model; separate for R and B */
float Terms [6];
};
C_TYPEDEF (struct, lfLensCalibTCA)
/**
* @brief The lensfun library supports several models for lens vignetting
* correction.
*
* We focus on optical and natural vignetting since they can be generalized for
* all lenses of a certain type; mechanical vignetting is out of the scope of
* this library.
*
* Vignetting is dependent on focal length and aperture. There is
* also a slight dependence on focus distance. In the following,
* \f$C_d\f$ refers to the corrected destination image pixel brightness, and
* \f$C_s\f$ refers to the uncorrected source image pixel brightness.
*
* For a popular explanation of vignetting see
* http://www.vanwalree.com/optics/vignetting.html
*/
enum lfVignettingModel
{
/** @brief No vignetting correction data is known */
LF_VIGNETTING_MODEL_NONE,
/**
* @brief Pablo D'Angelo vignetting model
* (which is a more general variant of the \f$\cos^4\f$ law).
*
* \f[C_d = C_s \cdot (1 + k_1 r^2 + k_2 r^4 + k_3 r^6)\f]
* The corresponding XML attributes are called “k1”, “k2”, and “k3”. They
* default to 0.
* Ref: http://hugin.sourceforge.net/tech/
*/
LF_VIGNETTING_MODEL_PA
};
C_TYPEDEF (enum, lfVignettingModel)
/**
* @brief Lens vignetting calibration data.
*
* Vignetting depends on focal length, aperture and focus distance. The library
* will interpolate the coefficients if data for the exact focal length,
* aperture, and focus distance is not available.
*/
struct lfLensCalibVignetting
{
/** @brief The lens vignetting model used */
enum lfVignettingModel Model;
/** @brief Focal length in mm at which this calibration data was taken */
float Focal;
/** @brief Aperture (f-number) at which this calibration data was taken */
float Aperture;
/** @brief Focus distance in meters */
float Distance;
/** @brief Lens vignetting model coefficients (depending on model) */
float Terms [3];
};
C_TYPEDEF (struct, lfLensCalibVignetting)
/**
* @brief Different crop modes
*/
enum lfCropMode
{
/** @brief no crop at all */
LF_NO_CROP,
/** @brief use a rectangular crop */
LF_CROP_RECTANGLE,
/** @brief use a circular crop, e.g. for circular fisheye images */
LF_CROP_CIRCLE
};
C_TYPEDEF(enum, lfCropMode)
/**
* @brief Struct to save image crop, which can depend on the focal length
*/
struct lfLensCalibCrop
{
/** @brief Focal length in mm at which this calibration data was taken */
float Focal;
/** @brief crop mode which should be applied to image to get rid of black borders */
enum lfCropMode CropMode;
/** @brief Crop coordinates, relative to image corresponding image dimension
*
* Crop goes left - 0, right - 1, top - 2, bottom - 3
* Left/right refers always to long side (width in landscape mode),
* top bottom to short side (height in landscape).
* Also negative values are allowed for cropping of fisheye images,
* where the crop circle can extend above the image border.
*/
float Crop [4];
};
C_TYPEDEF (struct, lfLensCalibCrop)
/**
* @brief Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED)
*
* The Field of View (FOV) database entry is deprecated since lensfun
* version 0.3 and will be removed in future releases.
*
*/
struct lfLensCalibFov
{
/** Focal length in mm at which this calibration data was taken */
float Focal;
/** @brief Field of view for given images
*
* The Field of View (FOV) database entry is deprecated since lensfun
* version 0.3 and will be removed in future releases.
*
* Especially for fisheye images the field of view calculated from the (EXIF) focal
* length differs slightly from the real field of view. The real field of view can be
* stored in this field
*/
float FieldOfView;
};
C_TYPEDEF (struct, lfLensCalibFov)
/**
* @brief Struct to save real focal length, which can depends on the (nominal)
* focal length
*/
struct lfLensCalibRealFocal
{
/** Nominal focal length in mm at which this calibration data was taken */
float Focal;
/** @brief Real focal length
*
* When Lensfun speaks of “focal length”, the *nominal* focal length from
* the EXIF data or the gravure on the lens barrel is meant. However,
* especially for fisheye lenses, the real focal length generally differs
* from that nominal focal length. With “real focal length” I mean the
* focal length in the paraxial approximation, see
* <http://en.wikipedia.org/wiki/Paraxial_approximation>. Note that Hugin
* (as of 2014) implements the calculation of the real focal length
* wrongly, see <http://article.gmane.org/gmane.comp.misc.ptx/34865>.
*/
float RealFocal;
};
C_TYPEDEF (struct, lfLensCalibRealFocal)
/**
* @brief This structure describes a single parameter for some lens model.
*/
struct lfParameter
{
/** @brief Parameter name (something like 'k', 'k3', 'omega' etc.) */
const char *Name;
/** @brief Minimal value that has sense */
float Min;
/** @brief Maximal value that has sense */
float Max;
/** @brief Default value for the parameter */
float Default;
};
C_TYPEDEF (struct, lfParameter)
/**
* @brief Lens type. See \ref changeofprojection for further information.
*/
enum lfLensType
{
/** @brief Unknown lens type */
LF_UNKNOWN,
/** @brief Rectilinear lens
*
* Straight lines remain stright; 99% of all lenses are of this type.
*/
LF_RECTILINEAR,
/**
* @brief Equidistant fisheye
*
* Ref: http://wiki.panotools.org/Fisheye_Projection
*/
LF_FISHEYE,
/**
* @brief Panoramic (cylindrical)
*
* Not that there are such lenses, but useful to convert images \a to this
* type, especially fish-eye images.
*/
LF_PANORAMIC,
/**
* @brief Equirectangular
*
* Not that there are such lenses, but useful to convert images \a to this
* type, especially fish-eye images.
*/
LF_EQUIRECTANGULAR,
/** @brief Orthographic fisheye */
LF_FISHEYE_ORTHOGRAPHIC,
/** @brief Stereographic fisheye */
LF_FISHEYE_STEREOGRAPHIC,
/** @brief Equisolid fisheye */
LF_FISHEYE_EQUISOLID,
/**
* @brief Fisheye as measured by Thoby (for Nikkor 10.5).
*
* Ref: http://michel.thoby.free.fr/Blur_Panorama/Nikkor10-5mm_or_Sigma8mm/Sigma_or_Nikkor/Comparison_Short_Version_Eng.html
*/
LF_FISHEYE_THOBY
};
C_TYPEDEF (enum, lfLensType)
/**
* @brief Lens data.
* Unknown fields are set to NULL or 0.
*
* To create a new lens object, use the lfLens::Create() or lf_lens_new()
* functions. After that fill the fields for which you have data, and
* invoke the lfLens::Check or lf_lens_check() function, which will
* check if existing data is enough and will fill some fields using
* information extracted from lens name.
*/
struct LF_EXPORT lfLens
{
/** Lens maker (ex: "Rollei") */
lfMLstr Maker;
/** Lens model (ex: "Zoom-Rolleinar") */
lfMLstr Model;
/** Minimum focal length, mm (ex: 35). */
float MinFocal;
/** Maximum focal length, mm (ex: 105). Can be equal to MinFocal. */
float MaxFocal;
/** Smallest f-number possible (ex: 3.5). */
float MinAperture;
/** Biggest f-number possible (ex: 22). Can be equal to MinAperture. */
float MaxAperture;
/** Available mounts (NULL-terminated list) (ex: { "QBM", NULL }) */
char **Mounts;
/**
* The horizontal shift of all lens distortions.
* Note that distortion and TCA uses same geometrical lens center.
* It is given as a relative value to avoide dependency on the
* image and/or sensor sizes. The calibrated delta X and Y values are
* numbers in the -0.5 .. +0.5 range. For 1 we take the maximal image
* dimension (width or height) - this is related to the fact that the
* lens has a circular field of projection disregarding sensor size.
*/
float CenterX;
/** The vertical shift of all lens distortions. (0,0) for geometric center */
float CenterY;
/** Crop factor at which calibration measurements were taken. Must be defined. */
float CropFactor;
/** Aspect ratio of the images used for calibration measurements. */
float AspectRatio;
/** Lens type */
lfLensType Type;
/** Lens distortion calibration data, NULL-terminated (unsorted) */
lfLensCalibDistortion **CalibDistortion;
/** Lens TCA calibration data, NULL-terminated (unsorted) */
lfLensCalibTCA **CalibTCA;
/** Lens vignetting calibration data, NULL-terminated (unsorted) */
lfLensCalibVignetting **CalibVignetting;
/** Crop data, NULL-terminated (unsorted) */
lfLensCalibCrop **CalibCrop;
/** Field of view calibration data, NULL-terminated (unsorted) */
lfLensCalibFov **CalibFov;
/** Real focal length calibration data, NULL-terminated (unsorted) */
lfLensCalibRealFocal **CalibRealFocal;
/** Lens matching score, used while searching: not actually a lens parameter */
int Score;
#ifdef __cplusplus
/**
* @brief Create a new lens object, initializing all fields to default values.
*/
lfLens ();
/**
* Copy constructor.
*/
lfLens (const lfLens &other);
/**
* @brief Destroy this and all associated objects.
*/
~lfLens ();
/**
* Assignment operator
*/
lfLens &operator = (const lfLens &other);
/**
* @brief Add a string to camera maker.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Maker field.
* @param lang
* The language this field is in.
*/
void SetMaker (const char *val, const char *lang = NULL);
/**
* @brief Add a string to camera model.
*
* If lang is NULL, this replaces the default value, otherwise a new
* language value is appended.
* @param val
* The new value for the Model field.
* @param lang
* The language this field is in.
*/
void SetModel (const char *val, const char *lang = NULL);
/**
* @brief Add a new mount type to this lens.
*
* This is not a multi-language string, this it's just plain replaced.
* @param val
* The new value to add to the Mounts array.
*/
void AddMount (const char *val);
/**
* @brief Add a new distortion calibration structure to the pool.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param dc
* The distortion calibration structure.
*/
void AddCalibDistortion (const lfLensCalibDistortion *dc);
/**
* @brief Remove a calibration entry from the distortion calibration data.
* @param idx
* The calibration data index (zero-based).
*/
bool RemoveCalibDistortion (int idx);
/**
* @brief Add a new transversal chromatic aberration calibration structure
* to the pool.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param tcac
* The transversal chromatic aberration calibration structure.
*/
void AddCalibTCA (const lfLensCalibTCA *tcac);
/**
* @brief Remove a calibration entry from the TCA calibration data.
* @param idx
* The calibration data index (zero-based).
*/
bool RemoveCalibTCA (int idx);
/**
* @brief Add a new vignetting calibration structure to the pool.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param vc
* The vignetting calibration structure.
*/
void AddCalibVignetting (const lfLensCalibVignetting *vc);
/**
* @brief Remove a calibration entry from the vignetting calibration data.
* @param idx
* The calibration data index (zero-based).
*/
bool RemoveCalibVignetting (int idx);
/**
* @brief Add a new lens crop structure to the pool.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param cc
* The lens crop structure.
*/
void AddCalibCrop (const lfLensCalibCrop *cc);
/**
* @brief Remove a lens crop entry from the lens crop structure.
* @param idx
* The lens crop data index (zero-based).
*/
bool RemoveCalibCrop (int idx);
/**
* @brief Add a new lens fov structure to the pool.
*
* The Field of View (FOV) database entry is deprecated since lensfun
* version 0.3 and will be removed in future releases.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param cf
* The lens fov structure.
*/
DEPRECATED void AddCalibFov (const lfLensCalibFov *cf);
/**
* @brief Remove a field of view entry from the lens fov structure.
*
* The Field of View (FOV) database entry is deprecated since lensfun
* version 0.3 and will be removed in future releases.
*
* @param idx
* The lens information data index (zero-based).
*/
DEPRECATED bool RemoveCalibFov (int idx);
/**
* @brief Add a new lens real focal length structure to the pool.
*
* The objects is copied, thus you can reuse it as soon as
* this function returns.
* @param cf
* The lens real focal length structure.
*/
void AddCalibRealFocal (const lfLensCalibRealFocal *cf);
/**
* @brief Remove a real focal length entry from the lens real focal length
* structure.
* @param idx
* The lens information data index (zero-based).
*/
bool RemoveCalibRealFocal (int idx);
/**
* @brief This method fills some fields if they are missing but
* can be derived from other fields.
*
* This includes such non-obvious parameters like the range of focal