lensfun  0.3.2.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 #include <stdbool.h>
27 
28 #ifdef __cplusplus
29 
30 extern "C" {
32 # define C_TYPEDEF(t,c)
33 #else
34 # define C_TYPEDEF(t,c) typedef t c c;
35 #endif
36 
42 /*----------------------------------------------------------------------------*/
43 
50 #define LF_VERSION_MAJOR 0
52 #define LF_VERSION_MINOR 3
54 #define LF_VERSION_MICRO 2
56 #define LF_VERSION_BUGFIX 0
58 #define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
60 
62 #define LF_MIN_DATABASE_VERSION 0
63 #define LF_MAX_DATABASE_VERSION 2
65 
66 #if defined CONF_LENSFUN_STATIC
67 # define LF_EXPORT
69 #else
70 # ifdef CONF_SYMBOL_VISIBILITY
71 # if defined PLATFORM_WINDOWS
72 # define LF_EXPORT __declspec(dllexport)
73 # elif defined CONF_COMPILER_GCC || __clang__
74 # define LF_EXPORT __attribute__((visibility("default")))
75 # else
76 # error "I don't know how to change symbol visibility for your compiler"
77 # endif
78 # else
79 # if defined PLATFORM_WINDOWS || defined _MSC_VER
80 # define LF_EXPORT __declspec(dllimport)
81 # else
82 # define LF_EXPORT
83 # endif
84 # endif
85 #endif
86 
87 #ifndef CONF_LENSFUN_INTERNAL
88 # ifdef __GNUC__
90 # define DEPRECATED __attribute__((deprecated))
91 # elif defined(_MSC_VER)
92 # define DEPRECATED __declspec(deprecated)
93 # else
94 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
95 # define DEPRECATED
96 # endif
97 #else
98 # define DEPRECATED
99 #endif
100 
102 #define cbool int
103 
112 typedef char *lfMLstr;
113 
116 {
123 };
124 
125 C_TYPEDEF (enum, lfError)
126 
127 
128 typedef unsigned char lf_u8;
130 typedef unsigned short lf_u16;
132 typedef unsigned int lf_u32;
134 typedef float lf_f32;
136 typedef double lf_f64;
137 
146 LF_EXPORT void lf_free (void *data);
147 
156 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
157 
174 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
175 
185 
188 /*----------------------------------------------------------------------------*/
189 
206 {
214  char **Compat;
215 
216 #ifdef __cplusplus
217 
220  lfMount ();
221 
225  lfMount (const lfMount &other);
226 
230  lfMount &operator = (const lfMount &other);
231 
235  ~lfMount ();
236 
247  void SetName (const char *val, const char *lang = NULL);
248 
254  void AddCompat (const char *val);
255 
261  bool Check ();
262 #endif
263 };
264 
265 C_TYPEDEF (struct, lfMount)
266 
267 
275 
285 LF_EXPORT void lf_mount_destroy (lfMount *mount);
286 
296 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
297 
300 
303 /*----------------------------------------------------------------------------*/
304 
323 {
331  char *Mount;
333  float CropFactor;
335  int Score;
336 
337 #ifdef __cplusplus
338 
341  lfCamera ();
342 
346  lfCamera (const lfCamera &other);
347 
351  ~lfCamera ();
352 
356  lfCamera &operator = (const lfCamera &other);
357 
368  void SetMaker (const char *val, const char *lang = NULL);
369 
380  void SetModel (const char *val, const char *lang = NULL);
381 
392  void SetVariant (const char *val, const char *lang = NULL);
393 
399  void SetMount (const char *val);
400 
406  bool Check ();
407 #endif
408 };
409 
410 C_TYPEDEF (struct, lfCamera)
411 
412 
420 
430 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
431 
441 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
442 
445 
448 /*----------------------------------------------------------------------------*/
449 
471 {
516 };
517 
519 
520 
527 {
529  enum lfDistortionModel Model;
532  float Focal;
550  float RealFocal;
555  float Terms [5];
556 };
557 
559 
560 
574 {
629 };
630 
631 C_TYPEDEF (enum, lfTCAModel)
632 
633 
641 {
643  enum lfTCAModel Model;
645  float Focal;
647  float Terms [12];
648 };
649 
650 C_TYPEDEF (struct, lfLensCalibTCA)
651 
652 
669 {
693 };
694 
696 
697 
705 {
707  enum lfVignettingModel Model;
709  float Focal;
711  float Aperture;
713  float Distance;
715  float Terms [3];
716 };
717 
719 
720 
724 {
731 };
732 
733 C_TYPEDEF(enum, lfCropMode)
734 
735 
739 {
741  float Focal;
743  enum lfCropMode CropMode;
752  float Crop [4];
753 };
754 
755 C_TYPEDEF (struct, lfLensCalibCrop)
756 
757 
765 {
767  float Focal;
777  float FieldOfView;
778 };
779 
780 C_TYPEDEF (struct, lfLensCalibFov)
781 
782 
786 {
788  const char *Name;
790  float Min;
792  float Max;
794  float Default;
795 };
796 
797 C_TYPEDEF (struct, lfParameter)
798 
799 
803 {
843 };
844 
845 C_TYPEDEF (enum, lfLensType)
846 
847 
857 {
863  float MinFocal;
865  float MaxFocal;
867  float MinAperture;
869  float MaxAperture;
871  char **Mounts;
881  float CenterX;
883  float CenterY;
885  float CropFactor;
887  float AspectRatio;
901  int Score;
902 
903 #ifdef __cplusplus
904 
907  lfLens ();
908 
912  lfLens (const lfLens &other);
913 
917  ~lfLens ();
918 
922  lfLens &operator = (const lfLens &other);
923 
934  void SetMaker (const char *val, const char *lang = NULL);
935 
946  void SetModel (const char *val, const char *lang = NULL);
947 
955  void AddMount (const char *val);
956 
965  void AddCalibDistortion (const lfLensCalibDistortion *dc);
966 
972  bool RemoveCalibDistortion (int idx);
973 
983  void AddCalibTCA (const lfLensCalibTCA *tcac);
984 
990  bool RemoveCalibTCA (int idx);
991 
1000  void AddCalibVignetting (const lfLensCalibVignetting *vc);
1001 
1007  bool RemoveCalibVignetting (int idx);
1008 
1017  void AddCalibCrop (const lfLensCalibCrop *cc);
1018 
1024  bool RemoveCalibCrop (int idx);
1025 
1037  DEPRECATED void AddCalibFov (const lfLensCalibFov *cf);
1038 
1048  DEPRECATED bool RemoveCalibFov (int idx);
1049 
1058  void GuessParameters ();
1059 
1065  bool Check ();
1066 
1082  static const char *GetDistortionModelDesc (
1083  lfDistortionModel model, const char **details, const lfParameter ***params);
1099  static const char *GetTCAModelDesc (
1100  lfTCAModel model, const char **details, const lfParameter ***params);
1101 
1117  static const char *GetVignettingModelDesc (
1118  lfVignettingModel model, const char **details, const lfParameter ***params);
1119 
1135  static const char *GetCropDesc (
1136  lfCropMode mode, const char **details, const lfParameter ***params);
1137 
1149  static const char *GetLensTypeDesc (lfLensType type, const char **details);
1150 
1158  bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
1159 
1167  bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
1168 
1182  bool InterpolateVignetting (
1183  float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
1184 
1192  bool InterpolateCrop (float focal, lfLensCalibCrop &res) const;
1193 
1205  DEPRECATED bool InterpolateFov (float focal, lfLensCalibFov &res) const;
1206 #endif
1207 };
1208 
1209 C_TYPEDEF (struct, lfLens)
1210 
1211 
1219 
1229 LF_EXPORT void lf_lens_destroy (lfLens *lens);
1230 
1240 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
1241 
1244 
1247 
1250  enum lfDistortionModel model, const char **details, const lfParameter ***params);
1251 
1253 LF_EXPORT const char *lf_get_tca_model_desc (
1254  enum lfTCAModel model, const char **details, const lfParameter ***params);
1255 
1258  enum lfVignettingModel model, const char **details, const lfParameter ***params);
1259 
1261 LF_EXPORT const char *lf_get_crop_desc (
1262  enum lfCropMode mode, const char **details, const lfParameter ***params);
1263 
1265 LF_EXPORT const char *lf_get_lens_type_desc (
1266  enum lfLensType type, const char **details);
1267 
1269 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
1270  lfLensCalibDistortion *res);
1271 
1273 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
1274 
1276 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
1277  float distance, lfLensCalibVignetting *res);
1278 
1280 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float focal,
1281  lfLensCalibCrop *res);
1282 
1284 DEPRECATED LF_EXPORT cbool lf_lens_interpolate_fov (const lfLens *lens, float focal,
1285  lfLensCalibFov *res);
1286 
1289 
1292 
1294 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
1295 
1298 
1301 
1304 
1306 LF_EXPORT void lf_lens_add_calib_crop (lfLens *lens, const lfLensCalibCrop *cc);
1307 
1310 
1313 
1316 
1319 /*----------------------------------------------------------------------------*/
1320 
1330 enum
1331 {
1352 };
1353 
1368 {
1373 
1374 #ifdef __cplusplus
1375 
1377  static const char *const UserLocation;
1380  static const char *const UserUpdatesLocation;
1382  static const char *const SystemLocation;
1385  static const char *const SystemUpdatesLocation;
1386 
1387  lfDatabase ();
1388  ~lfDatabase ();
1389 
1396  DEPRECATED static lfDatabase *Create ();
1397 
1404  DEPRECATED void Destroy ();
1405 
1419  static long int ReadTimestamp (const char *dirname);
1420 
1435  DEPRECATED bool LoadDirectory (const char *dirname);
1436 
1445  lfError Load ();
1446 
1460  lfError Load (const char *pathname);
1461 
1476  lfError Load (const char *errcontext, const char *data, size_t data_size);
1477 
1485  lfError Save (const char *filename) const;
1486 
1500  lfError Save (const char *filename,
1501  const lfMount *const *mounts,
1502  const lfCamera *const *cameras,
1503  const lfLens *const *lenses) const;
1504 
1517  static char *Save (const lfMount *const *mounts,
1518  const lfCamera *const *cameras,
1519  const lfLens *const *lenses);
1520 
1545  const lfCamera **FindCameras (const char *maker, const char *model) const;
1546 
1567  const lfCamera **FindCamerasExt (const char *maker, const char *model,
1568  int sflags = 0) const;
1569 
1577  const lfCamera *const *GetCameras () const;
1578 
1616  const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1617  const char *model, int sflags = 0) const;
1618 
1636  const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
1637 
1645  const lfLens *const *GetLenses () const;
1646 
1654  const lfMount *FindMount (const char *mount) const;
1655 
1663  const char *MountName (const char *mount) const;
1664 
1672  const lfMount *const *GetMounts () const;
1673 
1679  void AddMount (lfMount *mount);
1680 
1686  void AddCamera (lfCamera *camera);
1687 
1693  void AddLens (lfLens *lens);
1694 
1695 private:
1696 #endif
1697  void *Mounts;
1698  void *Cameras;
1699  void *Lenses;
1700 };
1701 
1702 C_TYPEDEF (struct, lfDatabase)
1703 
1704 
1705 extern const char* const lf_db_system_location;
1707 extern const char* const lf_db_system_updates_location;
1709 extern const char* const lf_db_user_location;
1711 extern const char* const lf_db_user_updates_location;
1712 
1724 
1735 
1737 LF_EXPORT long int lf_db_read_timestamp (lfDatabase *db, const char *dirname);
1738 
1741 
1743 DEPRECATED LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
1744 
1746 DEPRECATED LF_EXPORT cbool lf_db_load_directory (lfDatabase *db, const char *dirname);
1747 
1749 LF_EXPORT lfError lf_db_load_path (lfDatabase *db, const char *pathname);
1750 
1752 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
1753  const char *data, size_t data_size);
1754 
1756 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1757 
1759 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
1760  const lfMount *const *mounts,
1761  const lfCamera *const *cameras,
1762  const lfLens *const *lenses);
1763 
1765 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
1766  const lfCamera *const *cameras,
1767  const lfLens *const *lenses);
1768 
1771  const lfDatabase *db, const char *maker, const char *model);
1772 
1775  const lfDatabase *db, const char *maker, const char *model, int sflags);
1776 
1778 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
1779 
1782  const lfDatabase *db, const lfCamera *camera, const char *maker,
1783  const char *lens, int sflags);
1784 
1787  const lfDatabase *db, const lfLens *lens, int sflags);
1788 
1790 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
1791 
1793 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1794 
1796 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1797 
1799 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
1800 
1803 /*----------------------------------------------------------------------------*/
1804 
1813 enum
1814 {
1816  LF_MODIFY_TCA = 0x00000001,
1818  LF_MODIFY_VIGNETTING = 0x00000002,
1819  /* Value 0x00000004 is deprecated. */
1821  LF_MODIFY_DISTORTION = 0x00000008,
1823  LF_MODIFY_GEOMETRY = 0x00000010,
1825  LF_MODIFY_SCALE = 0x00000020,
1828 };
1829 
1832 {
1843 };
1844 
1845 C_TYPEDEF (enum, lfPixelFormat)
1846 
1847 
1851 {
1874 };
1875 
1876 C_TYPEDEF (enum, lfComponentRole)
1877 
1878 
1879 #define LF_CR_1(a) (LF_CR_ ## a)
1880 
1881 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1882 
1883 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1884  ((LF_CR_ ## c) << 8))
1885 
1886 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1887  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1888 
1889 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1890  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1891  ((LF_CR_ ## e) << 16))
1892 
1893 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1894  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1895  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1896 
1897 #define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1898  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1899  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1900  ((LF_CR_ ## g) << 24))
1901 
1902 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1903  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1904  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1905  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1906 
1922 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
1923 
1948 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
1949  void *pixels, int comp_role, int count);
1950 
1963 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
1964 
1965 // @cond
1966 #ifdef __cplusplus
1967 
1969 struct lfCallbackData
1970 {
1971  int priority;
1972  void *data;
1973  size_t data_size;
1974 
1975  virtual ~lfCallbackData() {};
1976 };
1977 
1978 // A test point in the autoscale algorithm
1979 typedef struct { float angle, dist; } lfPoint;
1980 
1981 #endif
1982 // @endcond
1983 
2067 #ifdef __cplusplus
2068 }
2069 #endif
2070 
2072 {
2073 #ifdef __cplusplus
2074 
2095  lfModifier (const lfLens *lens, float crop, int width, int height);
2096  ~lfModifier ();
2097 
2124  DEPRECATED static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
2125 
2171  int Initialize (
2172  const lfLens *lens, lfPixelFormat format, float focal, float aperture,
2173  float distance, float scale, lfLensType targeom, int flags, bool reverse);
2174 
2225  bool EnablePerspectiveCorrection (float *x, float *y, int count, float d);
2226 
2233  DEPRECATED void Destroy ();
2234 
2251  void AddCoordCallback (lfModifyCoordFunc callback, int priority,
2252  void *data, size_t data_size);
2253 
2271  void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
2272  void *data, size_t data_size);
2273 
2290  void AddColorCallback (lfModifyColorFunc callback, int priority,
2291  void *data, size_t data_size);
2292 
2307  bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
2308 
2323  bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
2324  bool reverse = false);
2325 
2339  bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
2340 
2355  bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal = 0);
2356 
2373  bool AddCoordCallbackScale (float scale, bool reverse = false);
2374 
2388  float GetAutoScale (bool reverse);
2389 
2419  bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
2420  int comp_role, int row_stride) const;
2421 
2452  bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
2453  float *res) const;
2454 
2486  bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
2487  float *res) const;
2488 
2519  bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
2520  float *res) const;
2521 
2522 private:
2553  float GetRealFocalLength (const lfLens *lens, float focal);
2554 
2555  void AddCallback (void *arr, lfCallbackData *d,
2556  int priority, void *data, size_t data_size);
2557 
2571  double AutoscaleResidualDistance (float *coord) const;
2586  float GetTransformedDistance (lfPoint point) const;
2587 
2588  static void ModifyCoord_UnTCA_Linear (void *data, float *iocoord, int count);
2589  static void ModifyCoord_TCA_Linear (void *data, float *iocoord, int count);
2590  static void ModifyCoord_UnTCA_Poly3 (void *data, float *iocoord, int count);
2591  static void ModifyCoord_TCA_Poly3 (void *data, float *iocoord, int count);
2592  static void ModifyCoord_TCA_ACM (void *data, float *iocoord, int count);
2593 
2594  static void ModifyCoord_UnDist_Poly3 (void *data, float *iocoord, int count);
2595  static void ModifyCoord_Dist_Poly3 (void *data, float *iocoord, int count);
2596 #ifdef VECTORIZATION_SSE
2597  static void ModifyCoord_Dist_Poly3_SSE (void *data, float *iocoord, int count);
2598 #endif
2599  static void ModifyCoord_UnDist_Poly5 (void *data, float *iocoord, int count);
2600  static void ModifyCoord_Dist_Poly5 (void *data, float *iocoord, int count);
2601  static void ModifyCoord_UnDist_PTLens (void *data, float *iocoord, int count);
2602  static void ModifyCoord_Dist_PTLens (void *data, float *iocoord, int count);
2603 #ifdef VECTORIZATION_SSE
2604  static void ModifyCoord_UnDist_PTLens_SSE (void *data, float *iocoord, int count);
2605  static void ModifyCoord_Dist_PTLens_SSE (void *data, float *iocoord, int count);
2606 #endif
2607  static void ModifyCoord_Dist_ACM (void *data, float *iocoord, int count);
2608  static void ModifyCoord_Geom_FishEye_Rect (void *data, float *iocoord, int count);
2609  static void ModifyCoord_Geom_Panoramic_Rect (void *data, float *iocoord, int count);
2610  static void ModifyCoord_Geom_ERect_Rect (void *data, float *iocoord, int count);
2611  static void ModifyCoord_Geom_Rect_FishEye (void *data, float *iocoord, int count);
2612  static void ModifyCoord_Geom_Panoramic_FishEye (void *data, float *iocoord, int count);
2613  static void ModifyCoord_Geom_ERect_FishEye (void *data, float *iocoord, int count);
2614  static void ModifyCoord_Geom_Rect_Panoramic (void *data, float *iocoord, int count);
2615  static void ModifyCoord_Geom_FishEye_Panoramic (void *data, float *iocoord, int count);
2616  static void ModifyCoord_Geom_ERect_Panoramic (void *data, float *iocoord, int count);
2617  static void ModifyCoord_Geom_Rect_ERect (void *data, float *iocoord, int count);
2618  static void ModifyCoord_Geom_FishEye_ERect (void *data, float *iocoord, int count);
2619  static void ModifyCoord_Geom_Panoramic_ERect (void *data, float *iocoord, int count);
2620  static void ModifyCoord_Geom_Orthographic_ERect (void *data, float *iocoord, int count);
2621  static void ModifyCoord_Geom_ERect_Orthographic (void *data, float *iocoord, int count);
2622  static void ModifyCoord_Geom_Stereographic_ERect (void *data, float *iocoord, int count);
2623  static void ModifyCoord_Geom_ERect_Stereographic (void *data, float *iocoord, int count);
2624  static void ModifyCoord_Geom_Equisolid_ERect (void *data, float *iocoord, int count);
2625  static void ModifyCoord_Geom_ERect_Equisolid (void *data, float *iocoord, int count);
2626  static void ModifyCoord_Geom_Thoby_ERect (void *data, float *iocoord, int count);
2627  static void ModifyCoord_Geom_ERect_Thoby (void *data, float *iocoord, int count);
2628  static void ModifyCoord_Perspective_Correction (void *data, float *iocoord, int count);
2629 #ifdef VECTORIZATION_SSE
2630  static void ModifyColor_DeVignetting_PA_SSE (
2631  void *data, float _x, float _y, lf_f32 *pixels, int comp_role, int count);
2632 #endif
2633 #ifdef VECTORIZATION_SSE2
2634  static void ModifyColor_DeVignetting_PA_SSE2 (
2635  void *data, float _x, float _y, lf_u16 *pixels, int comp_role, int count);
2636 #endif
2637 
2638  template<typename T> static void ModifyColor_Vignetting_PA (
2639  void *data, float x, float y, T *rgb, int comp_role, int count);
2640  template<typename T> static void ModifyColor_DeVignetting_PA (
2641  void *data, float x, float y, T *rgb, int comp_role, int count);
2642 
2643  static void ModifyCoord_Scale (void *data, float *iocoord, int count);
2644 #endif
2645  double Width, Height;
2649  double CenterX, CenterY;
2651  double NormScale, NormUnScale;
2655  double NormalizedInMillimeters;
2658  double AspectRatioCorrection;
2659 
2661  void *SubpixelCallbacks;
2663  void *ColorCallbacks;
2665  void *CoordCallbacks;
2666 
2668  double MaxX, MaxY;
2669 
2675  double FocalLengthNormalized;
2677  bool Reverse;
2678 };
2679 
2680 #ifdef __cplusplus
2681 extern "C" {
2682 #endif
2683 
2684 C_TYPEDEF (struct, lfModifier)
2685 
2686 
2688  const lfLens *lens, float crop, int width, int height);
2689 
2691 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
2692 
2695  lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
2696  float focal, float aperture, float distance, float scale,
2697  lfLensType targeom, int flags, cbool reverse);
2698 
2701  lfModifier *modifier, float *x, float *y, int count, float d);
2702 
2705  lfModifier *modifier, lfModifyCoordFunc callback, int priority,
2706  void *data, size_t data_size);
2707 
2710  lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
2711  void *data, size_t data_size);
2712 
2715  lfModifier *modifier, lfModifyColorFunc callback, int priority,
2716  void *data, size_t data_size);
2717 
2720  lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
2721 
2724  lfModifier *modifier, lfLensCalibVignetting *model,
2725  lfPixelFormat format, cbool reverse);
2726 
2729  lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
2730 
2733  lfModifier *modifier, lfLensType from, lfLensType to);
2734 
2737  lfModifier *modifier, float scale, cbool reverse);
2738 
2741  lfModifier *modifier, cbool reverse);
2742 
2745  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2746 
2749  lfModifier *modifier, void *pixels, float x, float y, int width, int height,
2750  int comp_role, int row_stride);
2751 
2754  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2755 
2758  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2759 
2762 #undef cbool
2763 
2764 #ifdef __cplusplus
2765 }
2766 #endif
2767 
2768 #endif /* __LENSFUN_H__ */
Panoramic (cylindrical)
Definition: lensfun.h:823
lfDistortionModel
The Lensfun library implements several lens distortion models. This enum lists them.
Definition: lensfun.h:470
float MinAperture
Definition: lensfun.h:867
void(* lfModifyCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the coordinates of a strip of pixels.
Definition: lensfun.h:1963
Definition: lensfun.h:1836
Definition: lensfun.h:1865
cbool lf_modifier_apply_subpixel_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
Adobe Camera Model. The coordinate system is different here. Everything is measured in units of the f...
Definition: lensfun.h:515
unsigned int lf_u32
Definition: lensfun.h:132
static const char *const UserUpdatesLocation
Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates") ...
Definition: lensfun.h:1380
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)
DEPRECATED void lf_lens_add_calib_fov(lfLens *lens, const lfLensCalibFov *cf)
lfMLstr Maker
Definition: lensfun.h:859
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
Definition: lensfun.h:891
const char *const lf_db_system_location
float FieldOfView
Field of view for given images.
Definition: lensfun.h:777
Rectilinear lens.
Definition: lensfun.h:810
Definition: lensfun.h:1821
lfLensType Type
Definition: lensfun.h:889
cbool lf_modifier_enable_perspective_correction(lfModifier *modifier, float *x, float *y, int count, float d)
This flag makes Lensfun to sort the results by focal length, and remove all double lens names...
Definition: lensfun.h:1351
char ** Compat
Definition: lensfun.h:214
lfLensCalibVignetting ** CalibVignetting
Definition: lensfun.h:895
no crop at all
Definition: lensfun.h:726
Definition: lensfun.h:1842
Definition: lensfun.h:1834
5th order polynomial model.
Definition: lensfun.h:490
lfError
Definition: lensfun.h:115
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
Definition: lensfun.h:881
float CropFactor
Definition: lensfun.h:885
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:709
Laterlal chromatic aberrations calibration data.
Definition: lensfun.h:640
DEPRECATED cbool lf_db_load_directory(lfDatabase *db, const char *dirname)
Definition: lensfun.h:122
Lens distortion calibration data.
Definition: lensfun.h:526
static const char *const SystemLocation
System lens database directory (something like "/usr/share/lensfun")
Definition: lensfun.h:1382
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:1922
void lf_modifier_add_subpixel_callback(lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
double lf_f64
Definition: lensfun.h:136
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. Unknown fields are set to NULL or 0.
Definition: lensfun.h:856
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:1831
Definition: lensfun.h:1825
float AspectRatio
Definition: lensfun.h:887
lfVignettingModel
The Lensfun library supports several models for lens vignetting correction.
Definition: lensfun.h:668
lfLensCalibTCA ** CalibTCA
Definition: lensfun.h:893
float CenterY
Definition: lensfun.h:883
Adobe camera model for TCA. The coordinate system is different here. Everything is measured in units ...
Definition: lensfun.h:628
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:205
float MinFocal
Definition: lensfun.h:863
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
const char *const lf_db_user_location
Stereographic fisheye.
Definition: lensfun.h:834
int Score
Definition: lensfun.h:901
Linear lateral chromatic aberrations model.
Definition: lensfun.h:588
Third order polynomial.
Definition: lensfun.h:600
Definition: lensfun.h:1823
use a circular crop, e.g. for circular fisheye images
Definition: lensfun.h:730
#define cbool
C-compatible bool type; don&#39;t bother to define Yet Another Boolean Type.
Definition: lensfun.h:102
lfMLstr Model
Definition: lensfun.h:861
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:741
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:335
DEPRECATED char * UserUpdatesDir
Home lens database directory for automatic updates (deprecated). Replaced by lfDatabase::UserUpdatesL...
Definition: lensfun.h:1372
void lf_free(void *data)
const char *const lf_db_system_updates_location
cbool lf_mount_check(lfMount *mount)
float lf_modifier_get_auto_scale(lfModifier *modifier, cbool reverse)
Orthographic fisheye.
Definition: lensfun.h:832
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. See Change of projection for further information.
Definition: lensfun.h:802
Definition: lensfun.h:1818
cbool lf_lens_remove_calib_crop(lfLens *lens, int idx)
PTLens model, which is also used by Hugin.
Definition: lensfun.h:498
Definition: lensfun.h:1867
3rd order polynomial model, which is a subset of the PTLens model.
Definition: lensfun.h:481
use a rectangular crop
Definition: lensfun.h:728
lfError lf_db_load_path(lfDatabase *db, const char *pathname)
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)
#define C_TYPEDEF(t, c)
Definition: lensfun.h:32
Equisolid fisheye.
Definition: lensfun.h:836
Fisheye as measured by Thoby (for Nikkor 10.5).
Definition: lensfun.h:842
const lfMount *const * lf_db_get_mounts(const lfDatabase *db)
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:645
cbool lf_lens_interpolate_crop(const lfLens *lens, float focal, lfLensCalibCrop *res)
Definition: lensfun.h:1869
unsigned char lf_u8
Definition: lensfun.h:128
Definition: lensfun.h:1871
#define LF_EXPORT
This macro expands to an appropiate symbol visibility declaration.
Definition: lensfun.h:68
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:790
float Max
Maximal value that has sense.
Definition: lensfun.h:792
Unknown lens type.
Definition: lensfun.h:805
cbool RealFocalMeasured
Whether the real focal length was actually measured.
Definition: lensfun.h:553
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)
float RealFocal
Real focal length in mm for this nominal focal length.
Definition: lensfun.h:550
A modifier object contains optimized data required to rectify a image.
Definition: lensfun.h:2071
cbool lf_camera_check(lfCamera *camera)
Definition: lensfun.h:1856
float CropFactor
Camera crop factor (ex: 1.0). Must be defined.
Definition: lensfun.h:333
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.
Definition: lensfun.h:120
long int lf_db_read_timestamp(lfDatabase *db, const char *dirname)
This flag selects a looser search algorithm resulting in more results (still sorted by score)...
Definition: lensfun.h:1339
float Distance
Focus distance in meters.
Definition: lensfun.h:713
void lf_lens_add_calib_distortion(lfLens *lens, const lfLensCalibDistortion *dc)
void lf_modifier_destroy(lfModifier *modifier)
float Aperture
Aperture (f-number) at which this calibration data was taken.
Definition: lensfun.h:711
#define DEPRECATED
For marking deprecated functions, see http://stackoverflow.com/a/21265197.
Definition: lensfun.h:95
static const char *const SystemUpdatesLocation
System lens database directory for automatic updates (something like "/var/lib/lensfun-updates") ...
Definition: lensfun.h:1385
Definition: lensfun.h:1873
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
Definition: lensfun.h:865
Definition: lensfun.h:1816
void lf_mount_copy(lfMount *dest, const lfMount *source)
Copy the data from one lfMount structure into another.
unsigned short lf_u16
Definition: lensfun.h:130
lfComponentRole
These constants define the role of every pixel component, four bits each. "pixel" refers here to a se...
Definition: lensfun.h:1850
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
char ** Mounts
Definition: lensfun.h:871
Equirectangular.
Definition: lensfun.h:830
Definition: lensfun.h:1863
float Focal
Nominal focal length in mm at which this calibration data was taken.
Definition: lensfun.h:532
const char *const lf_db_user_updates_location
float Focal
Definition: lensfun.h:767
cbool lf_lens_interpolate_tca(const lfLens *lens, float focal, lfLensCalibTCA *res)
void lf_lens_destroy(lfLens *lens)
Destroy a lfLens object.
Definition: lensfun.h:1827
const lfLens ** lf_db_find_lenses(const lfDatabase *db, const lfLens *lens, int sflags)
void lf_db_destroy(lfDatabase *db)
Destroy the database object.
Equidistant fisheye.
Definition: lensfun.h:816
lfError lf_db_load_data(lfDatabase *db, const char *errcontext, const char *data, size_t data_size)
void lf_modifier_add_color_callback(lfModifier *modifier, lfModifyColorFunc callback, int priority, void *data, size_t data_size)
Definition: lensfun.h:1838
No TCA correction data is known.
Definition: lensfun.h:576
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition: lensfun.h:327
const char * lf_get_crop_desc(enum lfCropMode mode, const char **details, const lfParameter ***params)
lfLensCalibFov ** CalibFov
Definition: lensfun.h:899
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition: lensfun.h:325
DEPRECATED cbool lf_lens_remove_calib_fov(lfLens *lens, int idx)
Definition: lensfun.h:118
lfDatabase * lf_db_new(void)
Create a new empty database object.
cbool lf_lens_check(lfLens *lens)
DEPRECATED char * HomeDataDir
Home lens database directory (deprecated). Replaced by lfDatabase::UserLocation.
Definition: lensfun.h:1370
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:331
char * lfMLstr
Definition: lensfun.h:112
A lens database object.
Definition: lensfun.h:1367
void lf_lens_add_calib_crop(lfLens *lens, const lfLensCalibCrop *cc)
const lfLens *const * lf_db_get_lenses(const lfDatabase *db)
Pablo D&#39;Angelo vignetting model (which is a more general variant of the law).
Definition: lensfun.h:681
Distortion parameters are unknown.
Definition: lensfun.h:473
lfMLstr Name
Camera mount name.
Definition: lensfun.h:212
Lens vignetting calibration data.
Definition: lensfun.h:704
float lf_f32
Definition: lensfun.h:134
static const char *const UserLocation
Home lens database directory (something like "~/.local/share/lensfun")
Definition: lensfun.h:1377
DEPRECATED cbool lf_lens_interpolate_fov(const lfLens *lens, float focal, lfLensCalibFov *res)
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:671
DEPRECATED lfError lf_db_load_file(lfDatabase *db, const char *filename)
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 Lensfun library supports several models for lens lateral chromatic aberrations (also called trans...
Definition: lensfun.h:573
cbool lf_modifier_add_coord_callback_distortion(lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
float Default
Default value for the parameter.
Definition: lensfun.h:794
Adobe&#39;s vignetting model. It differs from D&#39;Angelo&#39;s model only in the coordinate system...
Definition: lensfun.h:692
lfMount * lf_mount_new()
Create a new mount object.
lfCropMode
Different crop modes.
Definition: lensfun.h:723
Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED) ...
Definition: lensfun.h:764
lfLensCalibCrop ** CalibCrop
Definition: lensfun.h:897
Camera data. Unknown fields are set to NULL.
Definition: lensfun.h:322
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. Some cameras use same EXIF id for different models.
Definition: lensfun.h:329
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:1948
Struct to save image crop, which can depend on the focal length.
Definition: lensfun.h:738
cbool lf_modifier_add_coord_callback_geometry(lfModifier *modifier, lfLensType from, lfLensType to)
Definition: lensfun.h:1840
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 &#39;k&#39;, &#39;k3&#39;, &#39;omega&#39; etc.)
Definition: lensfun.h:788
This structure describes a single parameter for some lens model.
Definition: lensfun.h:785
lfError lf_db_load(lfDatabase *db)
cbool lf_lens_remove_calib_distortion(lfLens *lens, int idx)
float MaxAperture
Definition: lensfun.h:869