lensfun: lensfun.h Source File

lensfun 0.3.4.0

lensfun.h
Go to the documentation of this file.
1/* -*- mode:c++ -*- */
2/*
3 Lensfun - a library for maintaining a database of photographical lenses,
4 and providing the means to correct some of the typical lens distortions.
5 Copyright (C) 2007 by Andrew Zabolotny
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with this library; if not, write to the Free
19 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/
21
22#ifndef __LENSFUN_H__
23#define __LENSFUN_H__
24
25#include <stddef.h>
26
27#ifdef __cplusplus
28extern "C" {
30# define C_TYPEDEF(t,c)
31#else
32# define C_TYPEDEF(t,c) typedef t c c;
33#endif
34
40/*----------------------------------------------------------------------------*/
41
49#define LF_VERSION_MAJOR 0
51#define LF_VERSION_MINOR 3
53#define LF_VERSION_MICRO 4
55#define LF_VERSION_BUGFIX 0
57#define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
58
60#define LF_MIN_DATABASE_VERSION 0
62#define LF_MAX_DATABASE_VERSION 1
63
64#if defined CONF_LENSFUN_STATIC
66# define LF_EXPORT
67#else
68# ifdef CONF_SYMBOL_VISIBILITY
69# if defined PLATFORM_WINDOWS
70# define LF_EXPORT __declspec(dllexport)
71# elif defined CONF_COMPILER_GCC || __clang__
72# define LF_EXPORT __attribute__((visibility("default")))
73# else
74# error "I don't know how to change symbol visibility for your compiler"
75# endif
76# else
77# if defined PLATFORM_WINDOWS || defined _MSC_VER
78# define LF_EXPORT __declspec(dllimport)
79# else
80# define LF_EXPORT
81# endif
82# endif
83#endif
84
85#ifndef CONF_LENSFUN_INTERNAL
87# ifdef __GNUC__
88# define DEPRECATED __attribute__((deprecated))
89# elif defined(_MSC_VER)
90# define DEPRECATED __declspec(deprecated)
91# else
92# pragma message("WARNING: You need to implement DEPRECATED for this compiler")
93# define DEPRECATED
94# endif
95#else
96# define DEPRECATED
97#endif
98
100#define cbool int
101
110 typedef char *lfMLstr;
111
113 enum lfError
114{
116 LF_NO_ERROR = 0,
118 LF_WRONG_FORMAT,
120 LF_NO_DATABASE
121};
122
123 C_TYPEDEF (enum, lfError)
124
125
126typedef unsigned char lf_u8;
128typedef unsigned short lf_u16;
130typedef unsigned int lf_u32;
132typedef float lf_f32;
134typedef double lf_f64;
135
144 LF_EXPORT void lf_free (void *data);
145
154 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
155
172 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
173
182 LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
183
186/*----------------------------------------------------------------------------*/
187
203struct LF_EXPORT lfMount
204{
210 lfMLstr Name;
212 char **Compat;
213
214#ifdef __cplusplus
218 lfMount ();
219
223 lfMount (const lfMount &other);
224
228 lfMount &operator = (const lfMount &other);
229
233 ~lfMount ();
234
245 void SetName (const char *val, const char *lang = NULL);
246
252 void AddCompat (const char *val);
253
259 bool Check ();
260#endif
261};
262
263 C_TYPEDEF (struct, lfMount)
264
265
272 LF_EXPORT lfMount *lf_mount_new ();
273
283 LF_EXPORT void lf_mount_destroy (lfMount *mount);
284
294 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
295
297 LF_EXPORT cbool lf_mount_check (lfMount *mount);
298
301/*----------------------------------------------------------------------------*/
302
320struct LF_EXPORT lfCamera
321{
323 lfMLstr Maker;
325 lfMLstr Model;
327 lfMLstr Variant;
329 char *Mount;
331 float CropFactor;
333 int Score;
334
335#ifdef __cplusplus
339 lfCamera ();
340
344 lfCamera (const lfCamera &other);
345
349 ~lfCamera ();
350
354 lfCamera &operator = (const lfCamera &other);
355
366 void SetMaker (const char *val, const char *lang = NULL);
367
378 void SetModel (const char *val, const char *lang = NULL);
379
390 void SetVariant (const char *val, const char *lang = NULL);
391
397 void SetMount (const char *val);
398
404 bool Check ();
405#endif
406};
407
408 C_TYPEDEF (struct, lfCamera)
409
410
417 LF_EXPORT lfCamera *lf_camera_new ();
418
428 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
429
439 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
440
442 LF_EXPORT cbool lf_camera_check (lfCamera *camera);
443
446/*----------------------------------------------------------------------------*/
447
468enum lfDistortionModel
469{
471 LF_DIST_MODEL_NONE,
479 LF_DIST_MODEL_POLY3,
488 LF_DIST_MODEL_POLY5,
496 LF_DIST_MODEL_PTLENS,
497};
498
499 C_TYPEDEF (enum, lfDistortionModel)
500
501
507struct lfLensCalibDistortion
508{
510 enum lfDistortionModel Model;
512 float Focal;
514 float Terms [3];
515};
516
517 C_TYPEDEF (struct, lfLensCalibDistortion)
518
519
532enum lfTCAModel
533{
535 LF_TCA_MODEL_NONE,
547 LF_TCA_MODEL_LINEAR,
548
560 LF_TCA_MODEL_POLY3
561};
562
563 C_TYPEDEF (enum, lfTCAModel)
564
565
572struct lfLensCalibTCA
573{
575 enum lfTCAModel Model;
577 float Focal;
579 float Terms [6];
580};
581
582 C_TYPEDEF (struct, lfLensCalibTCA)
583
584
600enum lfVignettingModel
601{
603 LF_VIGNETTING_MODEL_NONE,
613 LF_VIGNETTING_MODEL_PA
614};
615
616 C_TYPEDEF (enum, lfVignettingModel)
617
618
625struct lfLensCalibVignetting
626{
628 enum lfVignettingModel Model;
630 float Focal;
632 float Aperture;
634 float Distance;
636 float Terms [3];
637};
638
639 C_TYPEDEF (struct, lfLensCalibVignetting)
640
641
644enum lfCropMode
645{
647 LF_NO_CROP,
649 LF_CROP_RECTANGLE,
651 LF_CROP_CIRCLE
652};
653
654 C_TYPEDEF(enum, lfCropMode)
655
656
659struct lfLensCalibCrop
660{
662 float Focal;
664 enum lfCropMode CropMode;
673 float Crop [4];
674};
675
676 C_TYPEDEF (struct, lfLensCalibCrop)
677
678
685struct lfLensCalibFov
686{
688 float Focal;
698 float FieldOfView;
699};
700
701 C_TYPEDEF (struct, lfLensCalibFov)
702
703
707struct lfLensCalibRealFocal
708{
710 float Focal;
722 float RealFocal;
723};
724
725 C_TYPEDEF (struct, lfLensCalibRealFocal)
726
727
730struct lfParameter
731{
733 const char *Name;
735 float Min;
737 float Max;
739 float Default;
740};
741
742 C_TYPEDEF (struct, lfParameter)
743
744
747enum lfLensType
748{
750 LF_UNKNOWN,
755 LF_RECTILINEAR,
761 LF_FISHEYE,
768 LF_PANORAMIC,
775 LF_EQUIRECTANGULAR,
777 LF_FISHEYE_ORTHOGRAPHIC,
779 LF_FISHEYE_STEREOGRAPHIC,
781 LF_FISHEYE_EQUISOLID,
787 LF_FISHEYE_THOBY
788};
789
790 C_TYPEDEF (enum, lfLensType)
791
792
801struct LF_EXPORT lfLens
802{
804 lfMLstr Maker;
806 lfMLstr Model;
808 float MinFocal;
810 float MaxFocal;
812 float MinAperture;
814 float MaxAperture;
816 char **Mounts;
826 float CenterX;
828 float CenterY;
830 float CropFactor;
832 float AspectRatio;
834 lfLensType Type;
836 lfLensCalibDistortion **CalibDistortion;
838 lfLensCalibTCA **CalibTCA;
840 lfLensCalibVignetting **CalibVignetting;
842 lfLensCalibCrop **CalibCrop;
844 lfLensCalibFov **CalibFov;
846 lfLensCalibRealFocal **CalibRealFocal;
848 int Score;
849
850#ifdef __cplusplus
854 lfLens ();
855
859 lfLens (const lfLens &other);
860
864 ~lfLens ();
865
869 lfLens &operator = (const lfLens &other);
870
881 void SetMaker (const char *val, const char *lang = NULL);
882
893 void SetModel (const char *val, const char *lang = NULL);
894
902 void AddMount (const char *val);
903
912 void AddCalibDistortion (const lfLensCalibDistortion *dc);
913
919 bool RemoveCalibDistortion (int idx);
920
930 void AddCalibTCA (const lfLensCalibTCA *tcac);
931
937 bool RemoveCalibTCA (int idx);
938
947 void AddCalibVignetting (const lfLensCalibVignetting *vc);
948
954 bool RemoveCalibVignetting (int idx);
955
964 void AddCalibCrop (const lfLensCalibCrop *cc);
965
971 bool RemoveCalibCrop (int idx);
972
984 DEPRECATED void AddCalibFov (const lfLensCalibFov *cf);
985
995 DEPRECATED bool RemoveCalibFov (int idx);
996
1005 void AddCalibRealFocal (const lfLensCalibRealFocal *cf);
1006
1013 bool RemoveCalibRealFocal (int idx);
1014
1023 void GuessParameters ();
1024
1030 bool Check ();
1031
1047 static const char *GetDistortionModelDesc (
1048 lfDistortionModel model, const char **details, const lfParameter ***params);
1064 static const char *GetTCAModelDesc (
1065 lfTCAModel model, const char **details, const lfParameter ***params);
1066
1082 static const char *GetVignettingModelDesc (
1083 lfVignettingModel model, const char **details, const lfParameter ***params);
1084
1100 static const char *GetCropDesc (
1101 lfCropMode mode, const char **details, const lfParameter ***params);
1102
1114 static const char *GetLensTypeDesc (lfLensType type, const char **details);
1115
1123 bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
1124
1132 bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
1133
1147 bool InterpolateVignetting (
1148 float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
1149
1157 bool InterpolateCrop (float focal, lfLensCalibCrop &res) const;
1158
1170 DEPRECATED bool InterpolateFov (float focal, lfLensCalibFov &res) const;
1171
1183 bool InterpolateRealFocal (float focal, lfLensCalibRealFocal &res) const;
1184#endif
1185};
1186
1187 C_TYPEDEF (struct, lfLens)
1188
1189
1196 LF_EXPORT lfLens *lf_lens_new ();
1197
1207 LF_EXPORT void lf_lens_destroy (lfLens *lens);
1208
1218 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
1219
1221 LF_EXPORT cbool lf_lens_check (lfLens *lens);
1222
1224 LF_EXPORT void lf_lens_guess_parameters (lfLens *lens);
1225
1227 LF_EXPORT const char *lf_get_distortion_model_desc (
1228 enum lfDistortionModel model, const char **details, const lfParameter ***params);
1229
1231 LF_EXPORT const char *lf_get_tca_model_desc (
1232 enum lfTCAModel model, const char **details, const lfParameter ***params);
1233
1235 LF_EXPORT const char *lf_get_vignetting_model_desc (
1236 enum lfVignettingModel model, const char **details, const lfParameter ***params);
1237
1239 LF_EXPORT const char *lf_get_crop_desc (
1240 enum lfCropMode mode, const char **details, const lfParameter ***params);
1241
1243 LF_EXPORT const char *lf_get_lens_type_desc (
1244 enum lfLensType type, const char **details);
1245
1247 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
1248 lfLensCalibDistortion *res);
1249
1251 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
1252
1254 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
1255 float distance, lfLensCalibVignetting *res);
1256
1258 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float focal,
1259 lfLensCalibCrop *res);
1260
1262 DEPRECATED LF_EXPORT cbool lf_lens_interpolate_fov (const lfLens *lens, float focal,
1263 lfLensCalibFov *res);
1264
1266 LF_EXPORT cbool lf_lens_interpolate_real_focal (const lfLens *lens, float focal,
1267 lfLensCalibRealFocal *res);
1268
1270 LF_EXPORT void lf_lens_add_calib_distortion (lfLens *lens, const lfLensCalibDistortion *dc);
1271
1273 LF_EXPORT cbool lf_lens_remove_calib_distortion (lfLens *lens, int idx);
1274
1276 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
1277
1279 LF_EXPORT cbool lf_lens_remove_calib_tca (lfLens *lens, int idx);
1280
1282 LF_EXPORT void lf_lens_add_calib_vignetting (lfLens *lens, const lfLensCalibVignetting *vc);
1283
1285 LF_EXPORT cbool lf_lens_remove_calib_vignetting (lfLens *lens, int idx);
1286
1288 LF_EXPORT void lf_lens_add_calib_crop (lfLens *lens, const lfLensCalibCrop *cc);
1289
1291 LF_EXPORT cbool lf_lens_remove_calib_crop (lfLens *lens, int idx);
1292
1294 DEPRECATED LF_EXPORT void lf_lens_add_calib_fov (lfLens *lens, const lfLensCalibFov *cf);
1295
1297 DEPRECATED LF_EXPORT cbool lf_lens_remove_calib_fov (lfLens *lens, int idx);
1298
1300 LF_EXPORT void lf_lens_add_calib_real_focal (lfLens *lens, const lfLensCalibRealFocal *cf);
1301
1303 LF_EXPORT cbool lf_lens_remove_calib_real_focal (lfLens *lens, int idx);
1304
1307/*----------------------------------------------------------------------------*/
1308
1318enum
1319{
1327 LF_SEARCH_LOOSE = 1,
1339 LF_SEARCH_SORT_AND_UNIQUIFY = 2
1340};
1341
1361 struct LF_EXPORT lfDatabase
1362{
1364 char *HomeDataDir;
1367 char *UserUpdatesDir;
1368
1369#ifdef __cplusplus
1370 lfDatabase ();
1371 ~lfDatabase ();
1372
1377 DEPRECATED static lfDatabase *Create ();
1378
1385 DEPRECATED void Destroy ();
1386
1397 bool LoadDirectory (const char *dirname);
1398
1407 lfError Load ();
1408
1421 lfError Load (const char *filename);
1422
1437 lfError Load (const char *errcontext, const char *data, size_t data_size);
1438
1446 lfError Save (const char *filename) const;
1447
1461 lfError Save (const char *filename,
1462 const lfMount *const *mounts,
1463 const lfCamera *const *cameras,
1464 const lfLens *const *lenses) const;
1465
1478 static char *Save (const lfMount *const *mounts,
1479 const lfCamera *const *cameras,
1480 const lfLens *const *lenses);
1481
1506 const lfCamera **FindCameras (const char *maker, const char *model) const;
1507
1528 const lfCamera **FindCamerasExt (const char *maker, const char *model,
1529 int sflags = 0) const;
1530
1538 const lfCamera *const *GetCameras () const;
1539
1577 const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1578 const char *model, int sflags = 0) const;
1579
1597 const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
1598
1606 const lfLens *const *GetLenses () const;
1607
1615 const lfMount *FindMount (const char *mount) const;
1616
1624 const char *MountName (const char *mount) const;
1625
1633 const lfMount *const *GetMounts () const;
1634
1640 void AddMount (lfMount *mount);
1641
1647 void AddCamera (lfCamera *camera);
1648
1654 void AddLens (lfLens *lens);
1655
1656private:
1657#endif
1658 void *Mounts;
1659 void *Cameras;
1660 void *Lenses;
1661};
1662
1663 C_TYPEDEF (struct, lfDatabase)
1664
1665
1675 LF_EXPORT lfDatabase *lf_db_new (void);
1676
1686 LF_EXPORT void lf_db_destroy (lfDatabase *db);
1687
1689 LF_EXPORT lfError lf_db_load (lfDatabase *db);
1690
1692 LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
1693
1695 LF_EXPORT cbool lf_db_load_directory (lfDatabase *db, const char *dirname);
1696
1698 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
1699 const char *data, size_t data_size);
1700
1702 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1703
1705 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
1706 const lfMount *const *mounts,
1707 const lfCamera *const *cameras,
1708 const lfLens *const *lenses);
1709
1711 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
1712 const lfCamera *const *cameras,
1713 const lfLens *const *lenses);
1714
1716 LF_EXPORT const lfCamera **lf_db_find_cameras (
1717 const lfDatabase *db, const char *maker, const char *model);
1718
1720 LF_EXPORT const lfCamera **lf_db_find_cameras_ext (
1721 const lfDatabase *db, const char *maker, const char *model, int sflags);
1722
1724 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
1725
1727 LF_EXPORT const lfLens **lf_db_find_lenses_hd (
1728 const lfDatabase *db, const lfCamera *camera, const char *maker,
1729 const char *lens, int sflags);
1730
1732 LF_EXPORT const lfLens **lf_db_find_lenses (
1733 const lfDatabase *db, const lfLens *lens, int sflags);
1734
1736 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
1737
1739 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1740
1742 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1743
1745 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
1746
1749/*----------------------------------------------------------------------------*/
1750
1759enum
1760{
1762 LF_MODIFY_TCA = 0x00000001,
1764 LF_MODIFY_VIGNETTING = 0x00000002,
1765 /* Value 0x00000004 is deprecated. */
1767 LF_MODIFY_DISTORTION = 0x00000008,
1769 LF_MODIFY_GEOMETRY = 0x00000010,
1771 LF_MODIFY_SCALE = 0x00000020,
1773 LF_MODIFY_ALL = ~0
1774};
1775
1777 enum lfPixelFormat
1778{
1780 LF_PF_U8,
1782 LF_PF_U16,
1784 LF_PF_U32,
1786 LF_PF_F32,
1788 LF_PF_F64
1789};
1790
1791 C_TYPEDEF (enum, lfPixelFormat)
1792
1793
1796enum lfComponentRole
1797{
1802 LF_CR_END = 0,
1809 LF_CR_NEXT,
1811 LF_CR_UNKNOWN,
1813 LF_CR_INTENSITY,
1815 LF_CR_RED,
1817 LF_CR_GREEN,
1819 LF_CR_BLUE
1820};
1821
1822 C_TYPEDEF (enum, lfComponentRole)
1823
1824
1825#define LF_CR_1(a) (LF_CR_ ## a)
1827#define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1829#define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1830 ((LF_CR_ ## c) << 8))
1832#define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1833 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1835#define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1836 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1837 ((LF_CR_ ## e) << 16))
1839#define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1840 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1841 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1843#define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1844 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1845 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1846 ((LF_CR_ ## g) << 24))
1848#define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1849 ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1850 ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1851 ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1852
1868 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
1869
1894 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
1895 void *pixels, int comp_role, int count);
1896
1909 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
1910
1911// @cond
1912#ifdef __cplusplus
1913
1915struct lfCallbackData
1916{
1917 int priority;
1918 void *data;
1919 size_t data_size;
1920
1921 virtual ~lfCallbackData() {};
1922};
1923
1924// A test point in the autoscale algorithm
1925typedef struct { float angle, dist; } lfPoint;
1926
1927#endif
1928// @endcond
1929
2011#ifdef __cplusplus
2012}
2013#endif
2014
2015 struct LF_EXPORT lfModifier
2016{
2017#ifdef __cplusplus
2039 lfModifier (const lfLens *lens, float crop, int width, int height);
2040 ~lfModifier ();
2041
2068 DEPRECATED static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
2069
2115 int Initialize (
2116 const lfLens *lens, lfPixelFormat format, float focal, float aperture,
2117 float distance, float scale, lfLensType targeom, int flags, bool reverse);
2118
2125 DEPRECATED void Destroy ();
2126
2143 void AddCoordCallback (lfModifyCoordFunc callback, int priority,
2144 void *data, size_t data_size);
2145
2163 void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
2164 void *data, size_t data_size);
2165
2182 void AddColorCallback (lfModifyColorFunc callback, int priority,
2183 void *data, size_t data_size);
2184
2199 bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
2200
2215 bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
2216 bool reverse = false);
2217
2231 bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
2232
2247 bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal);
2248
2265 bool AddCoordCallbackScale (float scale, bool reverse = false);
2266
2280 float GetAutoScale (bool reverse);
2281
2311 bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
2312 int comp_role, int row_stride) const;
2313
2344 bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
2345 float *res) const;
2346
2378 bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
2379 float *res) const;
2380
2411 bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
2412 float *res) const;
2413
2414private:
2445 float GetRealFocalLength (const lfLens *lens, float focal);
2446
2447 void AddCallback (void *arr, lfCallbackData *d,
2448 int priority, void *data, size_t data_size);
2449
2463 double AutoscaleResidualDistance (float *coord) const;
2478 float GetTransformedDistance (lfPoint point) const;
2479
2480 static void ModifyCoord_UnTCA_Linear (void *data, float *iocoord, int count);
2481 static void ModifyCoord_TCA_Linear (void *data, float *iocoord, int count);
2482 static void ModifyCoord_UnTCA_Poly3 (void *data, float *iocoord, int count);
2483 static void ModifyCoord_TCA_Poly3 (void *data, float *iocoord, int count);
2484
2485 static void ModifyCoord_UnDist_Poly3 (void *data, float *iocoord, int count);
2486 static void ModifyCoord_Dist_Poly3 (void *data, float *iocoord, int count);
2487#ifdef VECTORIZATION_SSE
2488 static void ModifyCoord_Dist_Poly3_SSE (void *data, float *iocoord, int count);
2489#endif
2490 static void ModifyCoord_UnDist_Poly5 (void *data, float *iocoord, int count);
2491 static void ModifyCoord_Dist_Poly5 (void *data, float *iocoord, int count);
2492 static void ModifyCoord_UnDist_PTLens (void *data, float *iocoord, int count);
2493 static void ModifyCoord_Dist_PTLens (void *data, float *iocoord, int count);
2494#ifdef VECTORIZATION_SSE
2495 static void ModifyCoord_UnDist_PTLens_SSE (void *data, float *iocoord, int count);
2496 static void ModifyCoord_Dist_PTLens_SSE (void *data, float *iocoord, int count);
2497#endif
2498 static void ModifyCoord_Geom_FishEye_Rect (void *data, float *iocoord, int count);
2499 static void ModifyCoord_Geom_Panoramic_Rect (void *data, float *iocoord, int count);
2500 static void ModifyCoord_Geom_ERect_Rect (void *data, float *iocoord, int count);
2501 static void ModifyCoord_Geom_Rect_FishEye (void *data, float *iocoord, int count);
2502 static void ModifyCoord_Geom_Panoramic_FishEye (void *data, float *iocoord, int count);
2503 static void ModifyCoord_Geom_ERect_FishEye (void *data, float *iocoord, int count);
2504 static void ModifyCoord_Geom_Rect_Panoramic (void *data, float *iocoord, int count);
2505 static void ModifyCoord_Geom_FishEye_Panoramic (void *data, float *iocoord, int count);
2506 static void ModifyCoord_Geom_ERect_Panoramic (void *data, float *iocoord, int count);
2507 static void ModifyCoord_Geom_Rect_ERect (void *data, float *iocoord, int count);
2508 static void ModifyCoord_Geom_FishEye_ERect (void *data, float *iocoord, int count);
2509 static void ModifyCoord_Geom_Panoramic_ERect (void *data, float *iocoord, int count);
2510 static void ModifyCoord_Geom_Orthographic_ERect (void *data, float *iocoord, int count);
2511 static void ModifyCoord_Geom_ERect_Orthographic (void *data, float *iocoord, int count);
2512 static void ModifyCoord_Geom_Stereographic_ERect (void *data, float *iocoord, int count);
2513 static void ModifyCoord_Geom_ERect_Stereographic (void *data, float *iocoord, int count);
2514 static void ModifyCoord_Geom_Equisolid_ERect (void *data, float *iocoord, int count);
2515 static void ModifyCoord_Geom_ERect_Equisolid (void *data, float *iocoord, int count);
2516 static void ModifyCoord_Geom_Thoby_ERect (void *data, float *iocoord, int count);
2517 static void ModifyCoord_Geom_ERect_Thoby (void *data, float *iocoord, int count);
2518#ifdef VECTORIZATION_SSE
2519 static void ModifyColor_DeVignetting_PA_SSE (
2520 void *data, float _x, float _y, lf_f32 *pixels, int comp_role, int count);
2521#endif
2522#ifdef VECTORIZATION_SSE2
2523 static void ModifyColor_DeVignetting_PA_SSE2 (
2524 void *data, float _x, float _y, lf_u16 *pixels, int comp_role, int count);
2525#endif
2526
2527 template<typename T> static void ModifyColor_Vignetting_PA (
2528 void *data, float x, float y, T *rgb, int comp_role, int count);
2529 template<typename T> static void ModifyColor_DeVignetting_PA (
2530 void *data, float x, float y, T *rgb, int comp_role, int count);
2531
2532 static void ModifyCoord_Scale (void *data, float *iocoord, int count);
2533#endif
2535 int Width, Height;
2537 double CenterX, CenterY;
2539 double NormScale, NormUnScale;
2542 double NormalizedInMillimeters;
2545 double AspectRatioCorrection;
2546
2548 void *SubpixelCallbacks;
2550 void *ColorCallbacks;
2552 void *CoordCallbacks;
2553
2555 double MaxX, MaxY;
2556};
2557
2558#ifdef __cplusplus
2559extern "C" {
2560#endif
2561
2562 C_TYPEDEF (struct, lfModifier)
2563
2564
2565 LF_EXPORT lfModifier *lf_modifier_new (
2566 const lfLens *lens, float crop, int width, int height);
2567
2569 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
2570
2572 LF_EXPORT int lf_modifier_initialize (
2573 lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
2574 float focal, float aperture, float distance, float scale,
2575 lfLensType targeom, int flags, cbool reverse);
2576
2578 LF_EXPORT void lf_modifier_add_coord_callback (
2579 lfModifier *modifier, lfModifyCoordFunc callback, int priority,
2580 void *data, size_t data_size);
2581
2583 LF_EXPORT void lf_modifier_add_subpixel_callback (
2584 lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
2585 void *data, size_t data_size);
2586
2588 LF_EXPORT void lf_modifier_add_color_callback (
2589 lfModifier *modifier, lfModifyColorFunc callback, int priority,
2590 void *data, size_t data_size);
2591
2593 LF_EXPORT cbool lf_modifier_add_subpixel_callback_TCA (
2594 lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
2595
2597 LF_EXPORT cbool lf_modifier_add_color_callback_vignetting (
2598 lfModifier *modifier, lfLensCalibVignetting *model,
2599 lfPixelFormat format, cbool reverse);
2600
2602 LF_EXPORT cbool lf_modifier_add_coord_callback_distortion (
2603 lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
2604
2606 LF_EXPORT cbool lf_modifier_add_coord_callback_geometry (
2607 lfModifier *modifier, lfLensType from, lfLensType to, float focal);
2608
2610 LF_EXPORT cbool lf_modifier_add_coord_callback_scale (
2611 lfModifier *modifier, float scale, cbool reverse);
2612
2614 LF_EXPORT float lf_modifier_get_auto_scale (
2615 lfModifier *modifier, cbool reverse);
2616
2618 LF_EXPORT cbool lf_modifier_apply_subpixel_distortion (
2619 lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2620
2622 LF_EXPORT cbool lf_modifier_apply_color_modification (
2623 lfModifier *modifier, void *pixels, float x, float y, int width, int height,
2624 int comp_role, int row_stride);
2625
2627 LF_EXPORT cbool lf_modifier_apply_geometry_distortion (
2628 lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2629
2631 LF_EXPORT cbool lf_modifier_apply_subpixel_geometry_distortion (
2632 lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2633
2636#undef cbool
2637
2638#ifdef __cplusplus
2639}
2640#endif
2641
2642#endif /* __LENSFUN_H__ */
lf_mlstr_dup
lfMLstr lf_mlstr_dup(const lfMLstr str)
Create a complete copy of a multi-language string.
lf_u8
unsigned char lf_u8
Definition lensfun.h:126
lfMLstr
char * lfMLstr
Definition lensfun.h:110
lf_free
void lf_free(void *data)
lf_mlstr_get
const char * lf_mlstr_get(const lfMLstr str)
Get a string corresponding to current locale from a multi-language string.
lf_u16
unsigned short lf_u16
Definition lensfun.h:128
LF_EXPORT
#define LF_EXPORT
This macro expands to an appropiate symbol visibility declaration.
Definition lensfun.h:66
lf_f64
double lf_f64
Definition lensfun.h:134
DEPRECATED
#define DEPRECATED
For marking deprecated functions, see http://stackoverflow.com/a/21265197.
Definition lensfun.h:93
lf_u32
unsigned int lf_u32
Definition lensfun.h:130
lf_f32
float lf_f32
Definition lensfun.h:132
cbool
#define cbool
C-compatible bool type; don't bother to define Yet Another Boolean Type.
Definition lensfun.h:100
lf_mlstr_add
lfMLstr lf_mlstr_add(lfMLstr str, const char *lang, const char *trstr)
Add a new translated string to a multi-language string.
lfError
lfError
Definition lensfun.h:114
LF_NO_ERROR
@ LF_NO_ERROR
Definition lensfun.h:116
LF_NO_DATABASE
@ LF_NO_DATABASE
Definition lensfun.h:120
LF_WRONG_FORMAT
@ LF_WRONG_FORMAT
Definition lensfun.h:118
lf_camera_copy
void lf_camera_copy(lfCamera *dest, const lfCamera *source)
Copy the data from one lfCamera structure into another.
lf_camera_check
cbool lf_camera_check(lfCamera *camera)
lf_camera_new
lfCamera * lf_camera_new()
Create a new camera object.
lf_camera_destroy
void lf_camera_destroy(lfCamera *camera)
Destroy a lfCamera object.
lfSubpixelCoordFunc
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:1868
lf_modifier_apply_subpixel_distortion
cbool lf_modifier_apply_subpixel_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
lf_modifier_add_coord_callback
void lf_modifier_add_coord_callback(lfModifier *modifier, lfModifyCoordFunc callback, int priority, void *data, size_t data_size)
lf_modifier_destroy
void lf_modifier_destroy(lfModifier *modifier)
lf_modifier_add_coord_callback_scale
cbool lf_modifier_add_coord_callback_scale(lfModifier *modifier, float scale, cbool reverse)
lf_modifier_apply_color_modification
cbool lf_modifier_apply_color_modification(lfModifier *modifier, void *pixels, float x, float y, int width, int height, int comp_role, int row_stride)
lf_modifier_add_subpixel_callback
void lf_modifier_add_subpixel_callback(lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
lf_modifier_add_color_callback_vignetting
cbool lf_modifier_add_color_callback_vignetting(lfModifier *modifier, lfLensCalibVignetting *model, lfPixelFormat format, cbool reverse)
lf_modifier_get_auto_scale
float lf_modifier_get_auto_scale(lfModifier *modifier, cbool reverse)
lfModifyCoordFunc
void(* lfModifyCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the coordinates of a strip of pixels.
Definition lensfun.h:1909
lf_modifier_apply_geometry_distortion
cbool lf_modifier_apply_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
lf_modifier_add_color_callback
void lf_modifier_add_color_callback(lfModifier *modifier, lfModifyColorFunc callback, int priority, void *data, size_t data_size)
lf_modifier_apply_subpixel_geometry_distortion
cbool lf_modifier_apply_subpixel_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
lf_modifier_add_coord_callback_distortion
cbool lf_modifier_add_coord_callback_distortion(lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
lf_modifier_new
lfModifier * lf_modifier_new(const lfLens *lens, float crop, int width, int height)
lf_modifier_initialize
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)
lf_modifier_add_subpixel_callback_TCA
cbool lf_modifier_add_subpixel_callback_TCA(lfModifier *modifier, lfLensCalibTCA *model, cbool reverse)
lfModifyColorFunc
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.
Definition lensfun.h:1894
lf_modifier_add_coord_callback_geometry
cbool lf_modifier_add_coord_callback_geometry(lfModifier *modifier, lfLensType from, lfLensType to, float focal)
lfComponentRole
lfComponentRole
These constants define the role of every pixel component, four bits each. "pixel" refers here to a se...
Definition lensfun.h:1797
lfPixelFormat
lfPixelFormat
A list of pixel formats supported by internal colour callbacks.
Definition lensfun.h:1778
LF_MODIFY_TCA
@ LF_MODIFY_TCA
Definition lensfun.h:1762
LF_MODIFY_VIGNETTING
@ LF_MODIFY_VIGNETTING
Definition lensfun.h:1764
LF_MODIFY_GEOMETRY
@ LF_MODIFY_GEOMETRY
Definition lensfun.h:1769
LF_MODIFY_DISTORTION
@ LF_MODIFY_DISTORTION
Definition lensfun.h:1767
LF_MODIFY_SCALE
@ LF_MODIFY_SCALE
Definition lensfun.h:1771
LF_MODIFY_ALL
@ LF_MODIFY_ALL
Definition lensfun.h:1773
LF_CR_NEXT
@ LF_CR_NEXT
Definition lensfun.h:1809
LF_CR_END
@ LF_CR_END
Definition lensfun.h:1802
LF_CR_INTENSITY
@ LF_CR_INTENSITY
Definition lensfun.h:1813
LF_CR_RED
@ LF_CR_RED
Definition lensfun.h:1815
LF_CR_UNKNOWN
@ LF_CR_UNKNOWN
Definition lensfun.h:1811
LF_CR_GREEN
@ LF_CR_GREEN
Definition lensfun.h:1817
LF_CR_BLUE
@ LF_CR_BLUE
Definition lensfun.h:1819
LF_PF_U16
@ LF_PF_U16
Definition lensfun.h:1782
LF_PF_F64
@ LF_PF_F64
Definition lensfun.h:1788
LF_PF_U8
@ LF_PF_U8
Definition lensfun.h:1780
LF_PF_U32
@ LF_PF_U32
Definition lensfun.h:1784
LF_PF_F32
@ LF_PF_F32
Definition lensfun.h:1786
lf_db_find_cameras_ext
const lfCamera ** lf_db_find_cameras_ext(const lfDatabase *db, const char *maker, const char *model, int sflags)
lf_db_save
char * lf_db_save(const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
lf_db_mount_name
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
lf_db_find_mount
const lfMount * lf_db_find_mount(const lfDatabase *db, const char *mount)
lf_db_load_data
lfError lf_db_load_data(lfDatabase *db, const char *errcontext, const char *data, size_t data_size)
lf_db_load
lfError lf_db_load(lfDatabase *db)
lf_db_find_lenses
const lfLens ** lf_db_find_lenses(const lfDatabase *db, const lfLens *lens, int sflags)
lf_db_find_lenses_hd
const lfLens ** lf_db_find_lenses_hd(const lfDatabase *db, const lfCamera *camera, const char *maker, const char *lens, int sflags)
lf_db_load_directory
cbool lf_db_load_directory(lfDatabase *db, const char *dirname)
lf_db_save_all
lfError lf_db_save_all(const lfDatabase *db, const char *filename)
lf_db_get_mounts
const lfMount *const * lf_db_get_mounts(const lfDatabase *db)
lf_db_get_cameras
const lfCamera *const * lf_db_get_cameras(const lfDatabase *db)
lf_db_save_file
lfError lf_db_save_file(const lfDatabase *db, const char *filename, const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
lf_db_find_cameras
const lfCamera ** lf_db_find_cameras(const lfDatabase *db, const char *maker, const char *model)
lf_db_new
lfDatabase * lf_db_new(void)
Create a new empty database object.
lf_db_get_lenses
const lfLens *const * lf_db_get_lenses(const lfDatabase *db)
lf_db_load_file
lfError lf_db_load_file(lfDatabase *db, const char *filename)
lf_db_destroy
void lf_db_destroy(lfDatabase *db)
Destroy the database object.
LF_SEARCH_LOOSE
@ LF_SEARCH_LOOSE
This flag selects a looser search algorithm resulting in more results (still sorted by score).
Definition lensfun.h:1327
LF_SEARCH_SORT_AND_UNIQUIFY
@ LF_SEARCH_SORT_AND_UNIQUIFY
This flag makes Lensfun to sort the results by focal length, and remove all double lens names.
Definition lensfun.h:1339
lf_lens_interpolate_vignetting
cbool lf_lens_interpolate_vignetting(const lfLens *lens, float focal, float aperture, float distance, lfLensCalibVignetting *res)
lf_lens_add_calib_crop
void lf_lens_add_calib_crop(lfLens *lens, const lfLensCalibCrop *cc)
lfTCAModel
lfTCAModel
The Lensfun library supports several models for lens lateral chromatic aberrations (also called trans...
Definition lensfun.h:533
lf_lens_remove_calib_real_focal
cbool lf_lens_remove_calib_real_focal(lfLens *lens, int idx)
lf_lens_add_calib_vignetting
void lf_lens_add_calib_vignetting(lfLens *lens, const lfLensCalibVignetting *vc)
lf_lens_check
cbool lf_lens_check(lfLens *lens)
lf_lens_remove_calib_fov
DEPRECATED cbool lf_lens_remove_calib_fov(lfLens *lens, int idx)
lf_lens_remove_calib_crop
cbool lf_lens_remove_calib_crop(lfLens *lens, int idx)
lf_lens_interpolate_crop
cbool lf_lens_interpolate_crop(const lfLens *lens, float focal, lfLensCalibCrop *res)
lf_lens_add_calib_fov
DEPRECATED void lf_lens_add_calib_fov(lfLens *lens, const lfLensCalibFov *cf)
lf_lens_add_calib_distortion
void lf_lens_add_calib_distortion(lfLens *lens, const lfLensCalibDistortion *dc)
lf_lens_destroy
void lf_lens_destroy(lfLens *lens)
Destroy a lfLens object.
lf_lens_remove_calib_vignetting
cbool lf_lens_remove_calib_vignetting(lfLens *lens, int idx)
lf_get_distortion_model_desc
const char * lf_get_distortion_model_desc(enum lfDistortionModel model, const char **details, const lfParameter ***params)
lfVignettingModel
lfVignettingModel
The Lensfun library supports several models for lens vignetting correction.
Definition lensfun.h:601
lf_lens_remove_calib_tca
cbool lf_lens_remove_calib_tca(lfLens *lens, int idx)
lf_lens_guess_parameters
void lf_lens_guess_parameters(lfLens *lens)
lf_lens_interpolate_distortion
cbool lf_lens_interpolate_distortion(const lfLens *lens, float focal, lfLensCalibDistortion *res)
lf_lens_interpolate_tca
cbool lf_lens_interpolate_tca(const lfLens *lens, float focal, lfLensCalibTCA *res)
lfCropMode
lfCropMode
Different crop modes.
Definition lensfun.h:645
lf_lens_interpolate_fov
DEPRECATED cbool lf_lens_interpolate_fov(const lfLens *lens, float focal, lfLensCalibFov *res)
lf_lens_new
lfLens * lf_lens_new()
Create a new lens object.
lfDistortionModel
lfDistortionModel
The Lensfun library implements several lens distortion models. This enum lists them.
Definition lensfun.h:469
lf_get_crop_desc
const char * lf_get_crop_desc(enum lfCropMode mode, const char **details, const lfParameter ***params)
lf_lens_copy
void lf_lens_copy(lfLens *dest, const lfLens *source)
Copy the data from one lfLens structure into another.
lfLensType
lfLensType
Lens type. See Change of projection for further information.
Definition lensfun.h:748
lf_lens_interpolate_real_focal
cbool lf_lens_interpolate_real_focal(const lfLens *lens, float focal, lfLensCalibRealFocal *res)
lf_get_vignetting_model_desc
const char * lf_get_vignetting_model_desc(enum lfVignettingModel model, const char **details, const lfParameter ***params)
lf_lens_add_calib_tca
void lf_lens_add_calib_tca(lfLens *lens, const lfLensCalibTCA *tcac)
lf_get_lens_type_desc
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
lf_get_tca_model_desc
const char * lf_get_tca_model_desc(enum lfTCAModel model, const char **details, const lfParameter ***params)
lf_lens_add_calib_real_focal
void lf_lens_add_calib_real_focal(lfLens *lens, const lfLensCalibRealFocal *cf)
lf_lens_remove_calib_distortion
cbool lf_lens_remove_calib_distortion(lfLens *lens, int idx)
LF_TCA_MODEL_NONE
@ LF_TCA_MODEL_NONE
No TCA correction data is known.
Definition lensfun.h:535
LF_TCA_MODEL_LINEAR
@ LF_TCA_MODEL_LINEAR
Linear lateral chromatic aberrations model.
Definition lensfun.h:547
LF_TCA_MODEL_POLY3
@ LF_TCA_MODEL_POLY3
Third order polynomial.
Definition lensfun.h:560
LF_VIGNETTING_MODEL_PA
@ LF_VIGNETTING_MODEL_PA
Pablo D'Angelo vignetting model (which is a more general variant of the law).
Definition lensfun.h:613
LF_VIGNETTING_MODEL_NONE
@ LF_VIGNETTING_MODEL_NONE
No vignetting correction data is known.
Definition lensfun.h:603
LF_CROP_RECTANGLE
@ LF_CROP_RECTANGLE
use a rectangular crop
Definition lensfun.h:649
LF_CROP_CIRCLE
@ LF_CROP_CIRCLE
use a circular crop, e.g. for circular fisheye images
Definition lensfun.h:651
LF_NO_CROP
@ LF_NO_CROP
no crop at all
Definition lensfun.h:647
LF_DIST_MODEL_POLY5
@ LF_DIST_MODEL_POLY5
5th order polynomial model.
Definition lensfun.h:488
LF_DIST_MODEL_NONE
@ LF_DIST_MODEL_NONE
Distortion parameters are unknown.
Definition lensfun.h:471
LF_DIST_MODEL_PTLENS
@ LF_DIST_MODEL_PTLENS
PTLens model, which is also used by Hugin.
Definition lensfun.h:496
LF_DIST_MODEL_POLY3
@ LF_DIST_MODEL_POLY3
3rd order polynomial model, which is a subset of the PTLens model.
Definition lensfun.h:479
LF_FISHEYE
@ LF_FISHEYE
Equidistant fisheye.
Definition lensfun.h:761
LF_FISHEYE_EQUISOLID
@ LF_FISHEYE_EQUISOLID
Equisolid fisheye.
Definition lensfun.h:781
LF_FISHEYE_THOBY
@ LF_FISHEYE_THOBY
Fisheye as measured by Thoby (for Nikkor 10.5).
Definition lensfun.h:787
LF_UNKNOWN
@ LF_UNKNOWN
Unknown lens type.
Definition lensfun.h:750
LF_FISHEYE_ORTHOGRAPHIC
@ LF_FISHEYE_ORTHOGRAPHIC
Orthographic fisheye.
Definition lensfun.h:777
LF_EQUIRECTANGULAR
@ LF_EQUIRECTANGULAR
Equirectangular.
Definition lensfun.h:775
LF_RECTILINEAR
@ LF_RECTILINEAR
Rectilinear lens.
Definition lensfun.h:755
LF_FISHEYE_STEREOGRAPHIC
@ LF_FISHEYE_STEREOGRAPHIC
Stereographic fisheye.
Definition lensfun.h:779
LF_PANORAMIC
@ LF_PANORAMIC
Panoramic (cylindrical)
Definition lensfun.h:768
lf_mount_new
lfMount * lf_mount_new()
Create a new mount object.
lf_mount_destroy
void lf_mount_destroy(lfMount *mount)
Destroy a lfMount object.
lf_mount_copy
void lf_mount_copy(lfMount *dest, const lfMount *source)
Copy the data from one lfMount structure into another.
lf_mount_check
cbool lf_mount_check(lfMount *mount)
C_TYPEDEF
#define C_TYPEDEF(t, c)
Definition lensfun.h:30
lfCamera
Camera data. Unknown fields are set to NULL.
Definition lensfun.h:321
lfCamera::Model
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition lensfun.h:325
lfCamera::Variant
lfMLstr Variant
Camera variant. Some cameras use same EXIF id for different models.
Definition lensfun.h:327
lfCamera::~lfCamera
~lfCamera()
Destroy a camera object. All allocated fields are freed.
lfCamera::Score
int Score
Camera matching score, used while searching: not actually a camera parameter.
Definition lensfun.h:333
lfCamera::Check
bool Check()
Check if a camera object is valid.
lfCamera::Maker
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition lensfun.h:323
lfCamera::SetVariant
void SetVariant(const char *val, const char *lang=NULL)
Add a string to camera variant.
lfCamera::lfCamera
lfCamera(const lfCamera &other)
lfCamera::lfCamera
lfCamera()
Initialize a new camera object. All fields are set to 0.
lfCamera::SetMaker
void SetMaker(const char *val, const char *lang=NULL)
Add a string to camera maker.
lfCamera::Mount
char * Mount
Camera mount type (ex: "QBM")
Definition lensfun.h:329
lfCamera::SetMount
void SetMount(const char *val)
Set the value for camera Mount.
lfCamera::SetModel
void SetModel(const char *val, const char *lang=NULL)
Add a string to camera model.
lfCamera::CropFactor
float CropFactor
Camera crop factor (ex: 1.0). Must be defined.
Definition lensfun.h:331
lfDatabase
A lens database object.
Definition lensfun.h:1362
lfDatabase::GetLenses
const lfLens *const * GetLenses() const
Retrieve a full list of lenses.
lfDatabase::Save
lfError Save(const char *filename) const
Save the whole database to a file.
lfDatabase::AddMount
void AddMount(lfMount *mount)
Add a mount to the database.
lfDatabase::LoadDirectory
bool LoadDirectory(const char *dirname)
Open and parse all XML files in a given directory.
lfDatabase::FindCamerasExt
const lfCamera ** FindCamerasExt(const char *maker, const char *model, int sflags=0) const
Searches all translations of camera maker and model.
lfDatabase::FindLenses
const lfLens ** FindLenses(const lfCamera *camera, const char *maker, const char *model, int sflags=0) const
Parse a human-friendly lens description (ex: "smc PENTAX-F 35-105mm F4-5.6" or "SIGMA AF 28-300 F3....
lfDatabase::HomeDataDir
char * HomeDataDir
Home lens database directory (something like "~/.local/share/lensfun")
Definition lensfun.h:1364
lfDatabase::FindLenses
const lfLens ** FindLenses(const lfLens *lens, int sflags=0) const
Find a set of lenses that fit certain criteria.
lfDatabase::GetMounts
const lfMount *const * GetMounts() const
Retrieve a full list of mounts.
lfDatabase::Create
static DEPRECATED lfDatabase * Create()
Create a new empty database object. This function is deprecated and will be removed in the future....
lfDatabase::Load
lfError Load(const char *filename)
Load just a specific XML file.
lfDatabase::UserUpdatesDir
char * UserUpdatesDir
Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates")
Definition lensfun.h:1367
lfDatabase::Save
static char * Save(const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
Save a set of camera and lens descriptions into a memory array.
lfDatabase::AddCamera
void AddCamera(lfCamera *camera)
Add a camera to the database.
lfDatabase::FindMount
const lfMount * FindMount(const char *mount) const
Return the lfMount structure given the (basic) mount name.
lfDatabase::Save
lfError Save(const char *filename, const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses) const
Save a set of camera and lens descriptions to a file.
lfDatabase::Destroy
DEPRECATED void Destroy()
Destroy the database object and free all loaded data.
lfDatabase::Load
lfError Load(const char *errcontext, const char *data, size_t data_size)
Load a set of camera/lenses from a memory array.
lfDatabase::AddLens
void AddLens(lfLens *lens)
Add a lens to the database.
lfDatabase::Load
lfError Load()
Find and load the lens database.
lfDatabase::MountName
const char * MountName(const char *mount) const
Get the name of a mount in current locale.
lfDatabase::FindCameras
const lfCamera ** FindCameras(const char *maker, const char *model) const
Find a set of cameras that fit given criteria.
lfDatabase::GetCameras
const lfCamera *const * GetCameras() const
Retrieve a full list of cameras.
lfLensCalibCrop
Struct to save image crop, which can depend on the focal length.
Definition lensfun.h:660
lfLensCalibCrop::CropMode
enum lfCropMode CropMode
crop mode which should be applied to image to get rid of black borders
Definition lensfun.h:664
lfLensCalibCrop::Focal
float Focal
Focal length in mm at which this calibration data was taken.
Definition lensfun.h:662
lfLensCalibDistortion
Lens distortion calibration data.
Definition lensfun.h:508
lfLensCalibDistortion::Model
enum lfDistortionModel Model
The type of distortion model used.
Definition lensfun.h:510
lfLensCalibDistortion::Focal
float Focal
Focal length in mm at which this calibration data was taken.
Definition lensfun.h:512
lfLensCalibFov
Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED)
Definition lensfun.h:686
lfLensCalibFov::FieldOfView
float FieldOfView
Field of view for given images.
Definition lensfun.h:698
lfLensCalibFov::Focal
float Focal
Definition lensfun.h:688
lfLensCalibRealFocal
Struct to save real focal length, which can depends on the (nominal) focal length.
Definition lensfun.h:708
lfLensCalibRealFocal::RealFocal
float RealFocal
Real focal length.
Definition lensfun.h:722
lfLensCalibRealFocal::Focal
float Focal
Definition lensfun.h:710
lfLensCalibTCA
Laterlal chromatic aberrations calibration data.
Definition lensfun.h:573
lfLensCalibTCA::Focal
float Focal
Focal length in mm at which this calibration data was taken.
Definition lensfun.h:577
lfLensCalibTCA::Model
enum lfTCAModel Model
The lateral chromatic aberration model used.
Definition lensfun.h:575
lfLensCalibVignetting
Lens vignetting calibration data.
Definition lensfun.h:626
lfLensCalibVignetting::Distance
float Distance
Focus distance in meters.
Definition lensfun.h:634
lfLensCalibVignetting::Aperture
float Aperture
Aperture (f-number) at which this calibration data was taken.
Definition lensfun.h:632
lfLensCalibVignetting::Model
enum lfVignettingModel Model
The lens vignetting model used.
Definition lensfun.h:628
lfLensCalibVignetting::Focal
float Focal
Focal length in mm at which this calibration data was taken.
Definition lensfun.h:630
lfLens
Lens data. Unknown fields are set to NULL or 0.
Definition lensfun.h:802
lfLens::Mounts
char ** Mounts
Definition lensfun.h:816
lfLens::RemoveCalibCrop
bool RemoveCalibCrop(int idx)
Remove a lens crop entry from the lens crop structure.
lfLens::CalibTCA
lfLensCalibTCA ** CalibTCA
Definition lensfun.h:838
lfLens::Model
lfMLstr Model
Definition lensfun.h:806
lfLens::GetLensTypeDesc
static const char * GetLensTypeDesc(lfLensType type, const char **details)
Get the human-readable lens type name and a short description of this lens type.
lfLens::RemoveCalibFov
DEPRECATED bool RemoveCalibFov(int idx)
Remove a field of view entry from the lens fov structure.
lfLens::GuessParameters
void GuessParameters()
This method fills some fields if they are missing but can be derived from other fields.
lfLens::Check
bool Check()
Check if a lens object is valid.
lfLens::CalibFov
lfLensCalibFov ** CalibFov
Definition lensfun.h:844
lfLens::InterpolateRealFocal
bool InterpolateRealFocal(float focal, lfLensCalibRealFocal &res) const
Interpolate lens real focal length data for given focal length.
lfLens::AddMount
void AddMount(const char *val)
Add a new mount type to this lens.
lfLens::Score
int Score
Definition lensfun.h:848
lfLens::Maker
lfMLstr Maker
Definition lensfun.h:804
lfLens::InterpolateDistortion
bool InterpolateDistortion(float focal, lfLensCalibDistortion &res) const
Interpolate lens geometry distortion data for given focal length.
lfLens::CropFactor
float CropFactor
Definition lensfun.h:830
lfLens::GetDistortionModelDesc
static const char * GetDistortionModelDesc(lfDistortionModel model, const char **details, const lfParameter ***params)
Get the human-readable distortion model name and the descriptions of the parameters required by this ...
lfLens::CenterY
float CenterY
Definition lensfun.h:828
lfLens::lfLens
lfLens(const lfLens &other)
lfLens::CalibRealFocal
lfLensCalibRealFocal ** CalibRealFocal
Definition lensfun.h:846
lfLens::InterpolateVignetting
bool InterpolateVignetting(float focal, float aperture, float distance, lfLensCalibVignetting &res) const
Interpolate lens vignetting model parameters for given focal length, aperture, and focus distance.
lfLens::AddCalibDistortion
void AddCalibDistortion(const lfLensCalibDistortion *dc)
Add a new distortion calibration structure to the pool.
lfLens::RemoveCalibVignetting
bool RemoveCalibVignetting(int idx)
Remove a calibration entry from the vignetting calibration data.
lfLens::GetCropDesc
static const char * GetCropDesc(lfCropMode mode, const char **details, const lfParameter ***params)
Get the human-readable crop name and the descriptions of the parameters required by this model.
lfLens::AddCalibFov
DEPRECATED void AddCalibFov(const lfLensCalibFov *cf)
Add a new lens fov structure to the pool.
lfLens::SetModel
void SetModel(const char *val, const char *lang=NULL)
Add a string to camera model.
lfLens::SetMaker
void SetMaker(const char *val, const char *lang=NULL)
Add a string to camera maker.
lfLens::AddCalibVignetting
void AddCalibVignetting(const lfLensCalibVignetting *vc)
Add a new vignetting calibration structure to the pool.
lfLens::MinFocal
float MinFocal
Definition lensfun.h:808
lfLens::InterpolateCrop
bool InterpolateCrop(float focal, lfLensCalibCrop &res) const
Interpolate lens crop data for given focal length.
lfLens::lfLens
lfLens()
Create a new lens object, initializing all fields to default values.
lfLens::MaxFocal
float MaxFocal
Definition lensfun.h:810
lfLens::CalibCrop
lfLensCalibCrop ** CalibCrop
Definition lensfun.h:842
lfLens::MinAperture
float MinAperture
Definition lensfun.h:812
lfLens::AddCalibCrop
void AddCalibCrop(const lfLensCalibCrop *cc)
Add a new lens crop structure to the pool.
lfLens::CalibDistortion
lfLensCalibDistortion ** CalibDistortion
Definition lensfun.h:836
lfLens::GetTCAModelDesc
static const char * GetTCAModelDesc(lfTCAModel model, const char **details, const lfParameter ***params)
Get the human-readable transversal chromatic aberrations model name and the descriptions of the param...
lfLens::AspectRatio
float AspectRatio
Definition lensfun.h:832
lfLens::AddCalibTCA
void AddCalibTCA(const lfLensCalibTCA *tcac)
Add a new transversal chromatic aberration calibration structure to the pool.
lfLens::InterpolateTCA
bool InterpolateTCA(float focal, lfLensCalibTCA &res) const
Interpolate lens TCA calibration data for given focal length.
lfLens::MaxAperture
float MaxAperture
Definition lensfun.h:814
lfLens::CenterX
float CenterX
Definition lensfun.h:826
lfLens::CalibVignetting
lfLensCalibVignetting ** CalibVignetting
Definition lensfun.h:840
lfLens::RemoveCalibTCA
bool RemoveCalibTCA(int idx)
Remove a calibration entry from the TCA calibration data.
lfLens::~lfLens
~lfLens()
Destroy this and all associated objects.
lfLens::InterpolateFov
DEPRECATED bool InterpolateFov(float focal, lfLensCalibFov &res) const
Interpolate lens fov data for given focal length.
lfLens::GetVignettingModelDesc
static const char * GetVignettingModelDesc(lfVignettingModel model, const char **details, const lfParameter ***params)
Get the human-readable vignetting model name and the descriptions of the parameters required by this ...
lfLens::Type
lfLensType Type
Definition lensfun.h:834
lfLens::RemoveCalibRealFocal
bool RemoveCalibRealFocal(int idx)
Remove a real focal length entry from the lens real focal length structure.
lfLens::AddCalibRealFocal
void AddCalibRealFocal(const lfLensCalibRealFocal *cf)
Add a new lens real focal length structure to the pool.
lfLens::RemoveCalibDistortion
bool RemoveCalibDistortion(int idx)
Remove a calibration entry from the distortion calibration data.
lfModifier
A modifier object contains optimized data required to rectify a image.
Definition lensfun.h:2016
lfModifier::Initialize
int Initialize(const lfLens *lens, lfPixelFormat format, float focal, float aperture, float distance, float scale, lfLensType targeom, int flags, bool reverse)
Initialize the process of correcting aberrations in a image.
lfModifier::AddCoordCallbackScale
bool AddCoordCallbackScale(float scale, bool reverse=false)
Add the stock image scaling callback into the chain.
lfModifier::lfModifier
lfModifier(const lfLens *lens, float crop, int width, int height)
Create an empty image modifier object.
lfModifier::AddColorCallback
void AddColorCallback(lfModifyColorFunc callback, int priority, void *data, size_t data_size)
Add a user-defined callback to the color modification chain.
lfModifier::AddCoordCallbackGeometry
bool AddCoordCallbackGeometry(lfLensType from, lfLensType to, float focal)
Add the stock lens geometry rectification callback into the chain.
lfModifier::AddSubpixelCallback
void AddSubpixelCallback(lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
Add a user-defined callback to the subpixel coordinate rectification chain.
lfModifier::ApplySubpixelGeometryDistortion
bool ApplySubpixelGeometryDistortion(float xu, float yu, int width, int height, float *res) const
Apply stage 2 & 3 in one step.
lfModifier::ApplyColorModification
bool ApplyColorModification(void *pixels, float x, float y, int width, int height, int comp_role, int row_stride) const
Image correction step 1: fix image colors.
lfModifier::AddCoordCallbackDistortion
bool AddCoordCallbackDistortion(lfLensCalibDistortion &model, bool reverse=false)
Add the stock lens distortion correcting callback into the chain.
lfModifier::ApplyGeometryDistortion
bool ApplyGeometryDistortion(float xu, float yu, int width, int height, float *res) const
Image correction step 2: apply the transforms on a block of pixel coordinates.
lfModifier::Destroy
DEPRECATED void Destroy()
Destroy the modifier object.
lfModifier::ApplySubpixelDistortion
bool ApplySubpixelDistortion(float xu, float yu, int width, int height, float *res) const
Image correction step 3: apply subpixel distortions.
lfModifier::AddSubpixelCallbackTCA
bool AddSubpixelCallbackTCA(lfLensCalibTCA &model, bool reverse=false)
Add the stock TCA correcting callback into the chain.
lfModifier::AddColorCallbackVignetting
bool AddColorCallbackVignetting(lfLensCalibVignetting &model, lfPixelFormat format, bool reverse=false)
Add the stock lens vignetting correcting callback into the chain. The vignetting correction callback ...
lfModifier::AddCoordCallback
void AddCoordCallback(lfModifyCoordFunc callback, int priority, void *data, size_t data_size)
Add a user-defined callback to the coordinate correction chain.
lfModifier::GetAutoScale
float GetAutoScale(bool reverse)
Compute the automatic scale factor for the image.
lfModifier::Create
static DEPRECATED lfModifier * Create(const lfLens *lens, float crop, int width, int height)
Create an empty image modifier object.
lfMount
This structure contains everything specific to a camera mount.
Definition lensfun.h:204
lfMount::AddCompat
void AddCompat(const char *val)
Add a mount name to the list of compatible mounts.
lfMount::Check
bool Check()
Check if a mount object is valid.
lfMount::lfMount
lfMount()
Initialize a new mount object. All fields are set to 0.
lfMount::lfMount
lfMount(const lfMount &other)
lfMount::Name
lfMLstr Name
Camera mount name.
Definition lensfun.h:210
lfMount::SetName
void SetName(const char *val, const char *lang=NULL)
Add a string to mount name.
lfMount::Compat
char ** Compat
Definition lensfun.h:212
lfMount::~lfMount
~lfMount()
Destroy a mount object. All allocated fields are freed.
lfParameter
This structure describes a single parameter for some lens model.
Definition lensfun.h:731
lfParameter::Name
const char * Name
Parameter name (something like 'k', 'k3', 'omega' etc.)
Definition lensfun.h:733
lfParameter::Max
float Max
Maximal value that has sense.
Definition lensfun.h:737
lfParameter::Min
float Min
Minimal value that has sense.
Definition lensfun.h:735
lfParameter::Default
float Default
Default value for the parameter.
Definition lensfun.h:739