lensfun  0.2.5
lensfun.h
Go to the documentation of this file.
1 /*
2  LensFun - a library for maintaining a database of photographical lenses,
3  and providing the means to correct some of the typical lens distortions.
4  Copyright (C) 2007 by Andrew Zabolotny
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public
17  License along with this library; if not, write to the Free
18  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 #ifndef __LENSFUN_H__
22 #define __LENSFUN_H__
23 
24 #include <stddef.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
29 # define C_TYPEDEF(t,c)
30 #else
31 # define C_TYPEDEF(t,c) typedef t c c;
32 #endif
33 
39 /*----------------------------------------------------------------------------*/
40 
47 #ifdef CONF_SYMBOL_VISIBILITY
48 # if defined PLATFORM_WINDOWS
49 # define LF_EXPORT __declspec(dllexport)
50 # elif defined CONF_COMPILER_GCC
51 # define LF_EXPORT __attribute__((visibility("default")))
52 # else
53 # error "I don't know how to change symbol visibility for your compiler"
54 # endif
55 #else
56 # if defined CONF_COMPILER_MSVC
57 # define LF_EXPORT __declspec(dllimport)
58 # else
59 # define LF_EXPORT
61 # endif
62 #endif
63 
65 #define cbool int
66 
75 typedef char *lfMLstr;
76 
78 enum lfError
79 {
84 };
85 
86 C_TYPEDEF (enum, lfError)
87 
88 
96 LF_EXPORT void lf_free (void *data);
97 
104 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
105 
121 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
122 
130 LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
131 
134 /*----------------------------------------------------------------------------*/
135 
152 {
154  lfMLstr Name;
156  char **Compat;
157 
158 #ifdef __cplusplus
159 
162  lfMount ();
163 
167  lfMount &operator = (const lfMount &other);
168 
172  ~lfMount ();
173 
182  void SetName (const char *val, const char *lang = NULL);
183 
189  void AddCompat (const char *val);
190 
196  bool Check ();
197 #endif
198 };
199 
200 C_TYPEDEF (struct, lfMount)
201 
202 
210 
219 LF_EXPORT void lf_mount_destroy (lfMount *mount);
220 
230 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
231 
234 
237 /*----------------------------------------------------------------------------*/
238 
258 {
260  lfMLstr Maker;
262  lfMLstr Model;
264  lfMLstr Variant;
266  char *Mount;
268  float CropFactor;
270  int Score;
271 
272 #ifdef __cplusplus
273 
276  lfCamera ();
277 
281  lfCamera (const lfCamera &other);
282 
286  ~lfCamera ();
287 
291  lfCamera &operator = (const lfCamera &other);
292 
301  void SetMaker (const char *val, const char *lang = NULL);
302 
311  void SetModel (const char *val, const char *lang = NULL);
312 
321  void SetVariant (const char *val, const char *lang = NULL);
322 
328  void SetMount (const char *val);
329 
335  bool Check ();
336 #endif
337 };
338 
339 C_TYPEDEF (struct, lfCamera)
340 
341 
349 
358 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
359 
369 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
370 
373 
376 /*----------------------------------------------------------------------------*/
377 
394 {
419 };
420 
422 
423 
429 {
431  enum lfDistortionModel Model;
433  float Focal;
435  float Terms [3];
436 };
437 
439 
440 
450 {
460 
468 };
469 
470 C_TYPEDEF (enum, lfTCAModel)
471 
472 
479 {
481  enum lfTCAModel Model;
483  float Focal;
485  float Terms [6];
486 };
487 
488 C_TYPEDEF (struct, lfLensCalibTCA)
489 
490 
502 {
512 };
513 
515 
516 
524 {
526  enum lfVignettingModel Model;
528  float Focal;
530  float Aperture;
532  float Distance;
534  float Terms [3];
535 };
536 
538 
539 
543 {
545  const char *Name;
547  float Min;
549  float Max;
551  float Default;
552 };
553 
554 C_TYPEDEF (struct, lfParameter)
555 
556 
560 {
577 };
578 
579 C_TYPEDEF (enum, lfLensType)
580 
581 
592 {
594  lfMLstr Maker;
596  lfMLstr Model;
598  float MinFocal;
600  float MaxFocal;
602  float MinAperture;
604  float MaxAperture;
606  char **Mounts;
616  float CenterX;
618  float CenterY;
620  float RedCCI;
622  float GreenCCI;
624  float BlueCCI;
626  float CropFactor;
636  int Score;
637 
638 #ifdef __cplusplus
639 
642  lfLens ();
643 
647  lfLens (const lfLens &other);
648 
652  ~lfLens ();
653 
657  lfLens &operator = (const lfLens &other);
658 
667  void SetMaker (const char *val, const char *lang = NULL);
668 
677  void SetModel (const char *val, const char *lang = NULL);
678 
685  void AddMount (const char *val);
686 
694  void AddCalibDistortion (const lfLensCalibDistortion *dc);
695 
701  bool RemoveCalibDistortion (int idx);
702 
710  void AddCalibTCA (const lfLensCalibTCA *tcac);
711 
717  bool RemoveCalibTCA (int idx);
718 
726  void AddCalibVignetting (const lfLensCalibVignetting *vc);
727 
733  bool RemoveCalibVignetting (int idx);
734 
742  void GuessParameters ();
743 
749  bool Check ();
750 
766  static const char *GetDistortionModelDesc (
767  lfDistortionModel model, const char **details, const lfParameter ***params);
783  static const char *GetTCAModelDesc (
784  lfTCAModel model, const char **details, const lfParameter ***params);
785 
801  static const char *GetVignettingModelDesc (
802  lfVignettingModel model, const char **details, const lfParameter ***params);
803 
815  static const char *GetLensTypeDesc (lfLensType type, const char **details);
816 
824  bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
825 
833  bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
834 
847  bool InterpolateVignetting (
848  float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
849 #endif
850 };
851 
852 C_TYPEDEF (struct, lfLens)
853 
854 
862 
871 LF_EXPORT void lf_lens_destroy (lfLens *lens);
872 
882 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
883 
886 
889 
892  enum lfDistortionModel model, const char **details, const lfParameter ***params);
893 
895 LF_EXPORT const char *lf_get_tca_model_desc (
896  enum lfTCAModel model, const char **details, const lfParameter ***params);
897 
900  enum lfVignettingModel model, const char **details, const lfParameter ***params);
901 
903 LF_EXPORT const char *lf_get_lens_type_desc (
904  enum lfLensType type, const char **details);
905 
907 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
908  lfLensCalibDistortion *res);
909 
911 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
912 
914 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
915  float distance, lfLensCalibVignetting *res);
916 
919 
922 
924 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
925 
928 
931 
934 
937 /*----------------------------------------------------------------------------*/
938 
948 enum
949 {
956 };
957 
981 {
983  char *HomeDataDir;
984 
985 #ifdef __cplusplus
986 
989  static lfDatabase *Create ();
990 
994  void Destroy ();
995 
1004  lfError Load ();
1005 
1017  lfError Load (const char *filename);
1018 
1032  lfError Load (const char *errcontext, const char *data, size_t data_size);
1033 
1041  lfError Save (const char *filename) const;
1042 
1056  lfError Save (const char *filename,
1057  const lfMount *const *mounts,
1058  const lfCamera *const *cameras,
1059  const lfLens *const *lenses) const;
1060 
1073  static char *Save (const lfMount *const *mounts,
1074  const lfCamera *const *cameras,
1075  const lfLens *const *lenses);
1076 
1100  const lfCamera **FindCameras (const char *maker, const char *model) const;
1101 
1121  const lfCamera **FindCamerasExt (const char *maker, const char *model,
1122  int sflags = 0) const;
1123 
1131  const lfCamera *const *GetCameras () const;
1132 
1169  const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1170  const char *model, int sflags = 0) const;
1171 
1189  const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
1190 
1198  const lfLens *const *GetLenses () const;
1199 
1207  const lfMount *FindMount (const char *mount) const;
1208 
1216  const char *MountName (const char *mount) const;
1217 
1225  const lfMount *const *GetMounts () const;
1226 
1227 protected:
1228  /* Prevent user from creating and destroying such objects */
1229  lfDatabase () {}
1230  ~lfDatabase () {}
1231 #endif
1232 };
1233 
1234 C_TYPEDEF (struct, lfDatabase)
1235 
1236 
1246 
1256 
1259 
1261 LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
1262 
1264 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
1265  const char *data, size_t data_size);
1266 
1268 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1269 
1271 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
1272  const lfMount *const *mounts,
1273  const lfCamera *const *cameras,
1274  const lfLens *const *lenses);
1275 
1277 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
1278  const lfCamera *const *cameras,
1279  const lfLens *const *lenses);
1280 
1283  const lfDatabase *db, const char *maker, const char *model);
1284 
1287  const lfDatabase *db, const char *maker, const char *model, int sflags);
1288 
1290 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
1291 
1294  const lfDatabase *db, const lfCamera *camera, const char *maker,
1295  const char *lens, int sflags);
1296 
1299  const lfDatabase *db, const lfLens *lens, int sflags);
1300 
1302 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
1303 
1305 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1306 
1308 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1309 
1311 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
1312 
1315 /*----------------------------------------------------------------------------*/
1316 
1325 enum
1326 {
1328  LF_MODIFY_TCA = 0x00000001,
1330  LF_MODIFY_VIGNETTING = 0x00000002,
1332  LF_MODIFY_CCI = 0x00000004,
1334  LF_MODIFY_DISTORTION = 0x00000008,
1336  LF_MODIFY_GEOMETRY = 0x00000010,
1338  LF_MODIFY_SCALE = 0x00000020,
1341 };
1342 
1345 {
1356 };
1357 
1358 C_TYPEDEF (enum, lfPixelFormat)
1359 
1360 
1362 {
1385 };
1386 
1387 C_TYPEDEF (enum, lfComponentRole)
1388 
1389 
1390 #define LF_CR_1(a) (LF_CR_ ## a)
1391 
1392 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1393 
1394 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1395  ((LF_CR_ ## c) << 8))
1396 
1397 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1398  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1399 
1400 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1401  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1402  ((LF_CR_ ## e) << 16))
1403 
1404 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1405  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1406  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1407 
1408 #define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1409  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1410  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1411  ((LF_CR_ ## g) << 24))
1412 
1413 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1414  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1415  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1416  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1417 
1432 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
1433 
1457 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
1458  void *pixels, int comp_role, int count);
1459 
1471 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
1472 
1533 {
1534 #ifdef __cplusplus
1535 
1555  static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
1556 
1597  int Initialize (
1598  const lfLens *lens, lfPixelFormat format, float focal, float aperture,
1599  float distance, float scale, lfLensType targeom, int flags, bool reverse);
1600 
1605  void Destroy ();
1606 
1623  void AddCoordCallback (lfModifyCoordFunc callback, int priority,
1624  void *data, size_t data_size);
1625 
1643  void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
1644  void *data, size_t data_size);
1645 
1662  void AddColorCallback (lfModifyColorFunc callback, int priority,
1663  void *data, size_t data_size);
1664 
1678  bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
1679 
1694  bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
1695  bool reverse = false);
1696 
1711  bool AddColorCallbackCCI (const lfLens *lens, lfPixelFormat format,
1712  bool reverse = false);
1713 
1726  bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
1727 
1740  bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal);
1741 
1757  bool AddCoordCallbackScale (float scale, bool reverse = false);
1758 
1771  float GetAutoScale (bool reverse);
1772 
1801  bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
1802  float *res) const;
1803 
1832  bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
1833  int comp_role, int row_stride) const;
1834 
1861  bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
1862  float *res) const;
1863 
1891  bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
1892  float *res) const;
1893 
1894 protected:
1895  /* Prevent user from creating and destroying such objects */
1896  lfModifier () {}
1897  ~lfModifier () {}
1898 #elif defined _MSC_VER
1899  /* Sucks, like always */
1900  void *dummy;
1901 #endif
1902 };
1903 
1904 C_TYPEDEF (struct, lfModifier)
1905 
1906 
1908  const lfLens *lens, float crop, int width, int height);
1909 
1911 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
1912 
1915  lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
1916  float focal, float aperture, float distance, float scale,
1917  lfLensType targeom, int flags, cbool reverse);
1918 
1921  lfModifier *modifier, lfModifyCoordFunc callback, int priority,
1922  void *data, size_t data_size);
1923 
1926  lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
1927  void *data, size_t data_size);
1928 
1931  lfModifier *modifier, lfModifyColorFunc callback, int priority,
1932  void *data, size_t data_size);
1933 
1936  lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
1937 
1940  lfModifier *modifier, lfLensCalibVignetting *model,
1941  lfPixelFormat format, cbool reverse);
1942 
1945  lfModifier *modifier, const lfLens *lens,
1946  lfPixelFormat format, cbool reverse);
1947 
1950  lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
1951 
1954  lfModifier *modifier, lfLensType from, lfLensType to, float focal);
1955 
1958  lfModifier *modifier, float scale, cbool reverse);
1959 
1962  lfModifier *modifier, cbool reverse);
1963 
1966  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
1967 
1970  lfModifier *modifier, void *pixels, float x, float y, int width, int height,
1971  int comp_role, int row_stride);
1972 
1975  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
1976 
1979  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
1980 
1983 #undef cbool
1984 
1985 #ifdef __cplusplus
1986 }
1987 #endif
1988 
1989 #endif /* __LENSFUN_H__ */
float RedCCI
Lens colour contribution index (ISO/CCI, ISO 6728:1983).
Definition: lensfun.h:620
Panoramic (cylindrical)
Definition: lensfun.h:571
lfError lf_db_load_file(lfDatabase *db, const char *filename)
Field-of-view lens model: Ru = tg (Rd * omega) / (2 * tg (omega/2)) Ref: ftp://ftp-sop.inria.fr/chir/publis/devernay-faugeras:01.pdf.
Definition: lensfun.h:413
lfDistortionModel
The lensdb library implements several lens distortion models.
Definition: lensfun.h:393
float MinAperture
Aperture at minimum focal distance (ex: 3.5).
Definition: lensfun.h:602
Unsigned 16-bit R,G,B.
Definition: lensfun.h:1349
This component has an unknown/doesn't matter role.
Definition: lensfun.h:1376
cbool lf_modifier_apply_subpixel_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
void lf_lens_add_calib_tca(lfLens *lens, const lfLensCalibTCA *tcac)
const lfCamera ** lf_db_find_cameras(const lfDatabase *db, const char *maker, const char *model)
lfMLstr Maker
Lens maker (ex: "Rollei")
Definition: lensfun.h:594
int lf_modifier_initialize(lfModifier *modifier, const lfLens *lens, lfPixelFormat format, float focal, float aperture, float distance, float scale, lfLensType targeom, int flags, cbool reverse)
lfLensCalibDistortion ** CalibDistortion
Lens distortion calibration data, NULL-terminated (unsorted)
Definition: lensfun.h:630
A rectilinear lens - 99% of all lenses are of this type.
Definition: lensfun.h:564
Correct (or apply) lens distortion.
Definition: lensfun.h:1334
lfLensType Type
Lens type.
Definition: lensfun.h:628
char ** Compat
A list of compatible mounts.
Definition: lensfun.h:156
lfLensCalibVignetting ** CalibVignetting
Lens vignetting calibration data, NULL-terminated (unsorted)
Definition: lensfun.h:634
64-bit floating-point R,G,B
Definition: lensfun.h:1355
Unsigned 8-bit R,G,B.
Definition: lensfun.h:1347
5th order polynomial model: Ru = Rd * (1 + k1 * Rd^2 + k2 * Rd^4)
Definition: lensfun.h:407
lfError
liblensdb error codes: negative codes are -errno, positive are here
Definition: lensfun.h:78
const char * lf_get_distortion_model_desc(enum lfDistortionModel model, const char **details, const lfParameter ***params)
void lf_lens_guess_parameters(lfLens *lens)
float CenterX
The horizontal shift of all lens distortions.
Definition: lensfun.h:616
float CropFactor
Crop factor at which calibration measurements were taken.
Definition: lensfun.h:626
float Focal
Focal distance at which this calibration data was taken (0 - unspecified)
Definition: lensfun.h:528
Laterlal chromatic aberrations calibration data.
Definition: lensfun.h:478
Lens distortion calibration data.
Definition: lensfun.h:428
void lf_modifier_add_subpixel_callback(lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
float BlueCCI
Blue component of lens CCI.
Definition: lensfun.h:624
cbool lf_modifier_add_color_callback_vignetting(lfModifier *modifier, lfLensCalibVignetting *model, lfPixelFormat format, cbool reverse)
void lf_modifier_add_coord_callback(lfModifier *modifier, lfModifyCoordFunc callback, int priority, void *data, size_t data_size)
void lf_lens_copy(lfLens *dest, const lfLens *source)
Copy the data from one lfLens structure into another.
void lf_mount_destroy(lfMount *mount)
Destroy a lfMount object.
cbool lf_lens_remove_calib_tca(lfLens *lens, int idx)
cbool lf_lens_remove_calib_vignetting(lfLens *lens, int idx)
Lens data.
Definition: lensfun.h:591
cbool lf_lens_interpolate_distortion(const lfLens *lens, float focal, lfLensCalibDistortion *res)
lfPixelFormat
A list of pixel formats supported by internal colour callbacks.
Definition: lensfun.h:1344
Additional resize of image.
Definition: lensfun.h:1338
lfVignettingModel
The lensdb library supports several models for lens vignetting correction.
Definition: lensfun.h:501
lfLensCalibTCA ** CalibTCA
Lens TCA calibration data, NULL-terminated (unsorted)
Definition: lensfun.h:632
float CenterY
The vertical shift of all lens distortions.
Definition: lensfun.h:618
float GreenCCI
Green component of lens CCI.
Definition: lensfun.h:622
cbool lf_modifier_add_coord_callback_scale(lfModifier *modifier, float scale, cbool reverse)
This structure contains everything specific to a camera mount.
Definition: lensfun.h:151
float MinFocal
Minimum focal distance, mm (ex: 35).
Definition: lensfun.h:598
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
int Score
Lens matching score, used while searching: not actually a lens parameter.
Definition: lensfun.h:636
Linear lateral chromatic aberrations model: Cd(R) = Cs(R) * kr Cd(B) = Cs(B) * kb Ref: http://cipa...
Definition: lensfun.h:459
Third order polynomial: Cd(R) = Cs(R)^3 * br + Cs(R)^2 * cr + Cs(R) * vr Cd(B) = Cs(B)^3 * bb + Cs(B)...
Definition: lensfun.h:467
Convert image geometry.
Definition: lensfun.h:1336
#define cbool
C-compatible bool type; don't bother to define Yet Another Boolean Type.
Definition: lensfun.h:65
lfMLstr Model
Lens model (ex: "Zoom-Rolleinar")
Definition: lensfun.h:596
cbool lf_modifier_apply_subpixel_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
const lfLens ** lf_db_find_lenses_hd(const lfDatabase *db, const lfCamera *camera, const char *maker, const char *lens, int sflags)
int Score
Camera matching score, used while searching: not actually a camera parameter.
Definition: lensfun.h:270
void lf_free(void *data)
The basics of memory allocation: never free objects allocated by the library yourselves, instead use this function.
cbool lf_mount_check(lfMount *mount)
float lf_modifier_get_auto_scale(lfModifier *modifier, cbool reverse)
const lfCamera *const * lf_db_get_cameras(const lfDatabase *db)
lfModifier * lf_modifier_new(const lfLens *lens, float crop, int width, int height)
lfLensType
Lens type.
Definition: lensfun.h:559
Correct (or apply) lens vignetting.
Definition: lensfun.h:1330
PTLens rectilinear: Ru = Rd * (a * Rd^3 + b * Rd^2 + c * Rd + 1)
Definition: lensfun.h:418
This is the pixel intensity (grayscale)
Definition: lensfun.h:1378
3rd order polynomial model: Ru = Rd * (1 + k1 * Rd^2) Ref: http://www.imatest.com/docs/distortion.html
Definition: lensfun.h:402
const char * lf_get_tca_model_desc(enum lfTCAModel model, const char **details, const lfParameter ***params)
cbool lf_modifier_add_subpixel_callback_TCA(lfModifier *modifier, lfLensCalibTCA *model, cbool reverse)
const lfMount * lf_db_find_mount(const lfDatabase *db, const char *mount)
void(* lfSubpixelCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the separate coordinates for all color components for every pixel ...
Definition: lensfun.h:1432
#define C_TYPEDEF(t, c)
Helper macro to make C/C++ work similarly.
Definition: lensfun.h:29
const lfMount *const * lf_db_get_mounts(const lfDatabase *db)
float Focal
Focal distance at which this calibration data was taken (0 - unspecified)
Definition: lensfun.h:483
This is the Red pixel component.
Definition: lensfun.h:1380
This is the Green pixel component.
Definition: lensfun.h:1382
#define LF_EXPORT
This macro expands to an appropiate symbol visibility declaration.
Definition: lensfun.h:60
void lf_camera_destroy(lfCamera *camera)
Destroy a lfCamera object.
lfLens * lf_lens_new()
Create a new lens object.
float Min
Minimal value that has sense.
Definition: lensfun.h:547
float Max
Maximal value that has sense.
Definition: lensfun.h:549
Unknown lens type.
Definition: lensfun.h:562
cbool lf_modifier_apply_color_modification(lfModifier *modifier, void *pixels, float x, float y, int width, int height, int comp_role, int row_stride)
const lfCamera ** lf_db_find_cameras_ext(const lfDatabase *db, const char *maker, const char *model, int sflags)
A modifier object contains optimized data required to rectify a image.
Definition: lensfun.h:1532
cbool lf_camera_check(lfCamera *camera)
This marks the end of the role list.
Definition: lensfun.h:1367
float CropFactor
Camera crop factor (ex: 1.0).
Definition: lensfun.h:268
const char * lf_mlstr_get(const lfMLstr str)
Get a string corresponding to current locale from a multi-language string.
void lf_camera_copy(lfCamera *dest, const lfCamera *source)
Copy the data from one lfCamera structure into another.
Wrong XML data format.
Definition: lensfun.h:83
This flag selects a looser search algorithm resulting in more results (still sorted by score)...
Definition: lensfun.h:955
float Distance
Distance to subject (important only for vignetting)
Definition: lensfun.h:532
void lf_lens_add_calib_distortion(lfLens *lens, const lfLensCalibDistortion *dc)
void lf_modifier_destroy(lfModifier *modifier)
float Aperture
Aperture at which this calibration data was taken (0 - unspecified)
Definition: lensfun.h:530
This is the Blue pixel component.
Definition: lensfun.h:1384
cbool lf_modifier_apply_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
lfCamera * lf_camera_new()
Create a new camera object.
float MaxFocal
Maximum focal distance, mm (ex: 105).
Definition: lensfun.h:600
Correct (or apply) lens transversal chromatic aberrations.
Definition: lensfun.h:1328
void lf_mount_copy(lfMount *dest, const lfMount *source)
Copy the data from one lfMount structure into another.
lfComponentRole
These constants define the role of every pixel component, four bits each.
Definition: lensfun.h:1361
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
char ** Mounts
Available mounts (NULL-terminated list) (ex: { "QBM", NULL })
Definition: lensfun.h:606
Equirectangular (not that there are such lenses, but useful to convert images TO this type...
Definition: lensfun.h:576
Correct (or apply) lens color contribution index.
Definition: lensfun.h:1332
This value tells that what follows applies to next pixel.
Definition: lensfun.h:1374
float Focal
Focal distance at which this calibration data was taken (0 - unspecified)
Definition: lensfun.h:433
cbool lf_lens_interpolate_tca(const lfLens *lens, float focal, lfLensCalibTCA *res)
void lf_lens_destroy(lfLens *lens)
Destroy a lfLens object.
Apply all possible corrections.
Definition: lensfun.h:1340
const lfLens ** lf_db_find_lenses(const lfDatabase *db, const lfLens *lens, int sflags)
void lf_db_destroy(lfDatabase *db)
Destroy the database object.
cbool lf_modifier_add_color_callback_CCI(lfModifier *modifier, const lfLens *lens, lfPixelFormat format, cbool reverse)
Fisheye lens Ref: http://wiki.panotools.org/Fisheye_Projection.
Definition: lensfun.h:569
lfError lf_db_load_data(lfDatabase *db, const char *errcontext, const char *data, size_t data_size)
cbool lf_modifier_add_coord_callback_geometry(lfModifier *modifier, lfLensType from, lfLensType to, float focal)
void lf_modifier_add_color_callback(lfModifier *modifier, lfModifyColorFunc callback, int priority, void *data, size_t data_size)
Unsigned 32-bit R,G,B.
Definition: lensfun.h:1351
No TCA correction data is known.
Definition: lensfun.h:452
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition: lensfun.h:262
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition: lensfun.h:260
No error occured.
Definition: lensfun.h:81
lfDatabase * lf_db_new(void)
Create a new empty database object.
cbool lf_lens_check(lfLens *lens)
const char * lf_get_vignetting_model_desc(enum lfVignettingModel model, const char **details, const lfParameter ***params)
char * Mount
Camera mount type (ex: "QBM")
Definition: lensfun.h:266
char * lfMLstr
The storage of "multi-language" strings is simple yet flexible, handy and effective.
Definition: lensfun.h:75
A lens database object.
Definition: lensfun.h:980
const lfLens *const * lf_db_get_lenses(const lfDatabase *db)
Pablo D'Angelo vignetting model (which is a more general variant of the cos^4 law): Cd = Cs * (1 + k1...
Definition: lensfun.h:511
Distortion parameters are unknown.
Definition: lensfun.h:396
lfMLstr Name
Camera mount name.
Definition: lensfun.h:154
Lens vignetting calibration data.
Definition: lensfun.h:523
lfMLstr lf_mlstr_add(lfMLstr str, const char *lang, const char *trstr)
Add a new translated string to a multi-language string.
No vignetting correction data is known.
Definition: lensfun.h:504
void lf_lens_add_calib_vignetting(lfLens *lens, const lfLensCalibVignetting *vc)
lfError lf_db_save_all(const lfDatabase *db, const char *filename)
cbool lf_lens_interpolate_vignetting(const lfLens *lens, float focal, float aperture, float distance, lfLensCalibVignetting *res)
lfTCAModel
The lensdb library supports several models for lens lateral chromatic aberrations (also called transv...
Definition: lensfun.h:449
cbool lf_modifier_add_coord_callback_distortion(lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
float Default
Default value for the parameter.
Definition: lensfun.h:551
void(* lfModifyColorFunc)(void *data, float x, float y, void *pixels, int comp_role, int count)
A callback function which modifies the colors of a strip of pixels This kind of callbacks are used in...
Definition: lensfun.h:1457
lfMount * lf_mount_new()
Create a new mount object.
Camera data.
Definition: lensfun.h:257
char * lf_db_save(const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
lfMLstr lf_mlstr_dup(const lfMLstr str)
Create a complete copy of a multi-language string.
lfMLstr Variant
Camera variant.
Definition: lensfun.h:264
void(* lfModifyCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the coordinates of a strip of pixels.
Definition: lensfun.h:1471
32-bit floating-point R,G,B
Definition: lensfun.h:1353
lfError lf_db_save_file(const lfDatabase *db, const char *filename, const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
const char * Name
Parameter name (something like 'k', 'k3', 'omega' etc.
Definition: lensfun.h:545
This structure describes a single parameter for some lens model.
Definition: lensfun.h:542
lfError lf_db_load(lfDatabase *db)
cbool lf_lens_remove_calib_distortion(lfLens *lens, int idx)
char * HomeDataDir
Home lens database directory (something like "~/.local/share/lensfun")
Definition: lensfun.h:983
float MaxAperture
Aperture at maximum focal distance (ex: 4.3).
Definition: lensfun.h:604