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 
27 #ifdef __cplusplus
28 extern "C" {
30 # define C_TYPEDEF(t,c)
31 #else
32 # define C_TYPEDEF(t,c) typedef t c c;
33 #endif
34 
40 /*----------------------------------------------------------------------------*/
41 
48 #define LF_VERSION_MAJOR 0
50 #define LF_VERSION_MINOR 3
52 #define LF_VERSION_MICRO 2
54 #define LF_VERSION_BUGFIX 0
56 #define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
58 
60 #define LF_MAX_DATABASE_VERSION 1
61 
62 #if defined CONF_LENSFUN_STATIC
63 # define LF_EXPORT
65 #else
66 # ifdef CONF_SYMBOL_VISIBILITY
67 # if defined PLATFORM_WINDOWS
68 # define LF_EXPORT __declspec(dllexport)
69 # elif defined CONF_COMPILER_GCC || __clang__
70 # define LF_EXPORT __attribute__((visibility("default")))
71 # else
72 # error "I don't know how to change symbol visibility for your compiler"
73 # endif
74 # else
75 # if defined PLATFORM_WINDOWS || defined _MSC_VER
76 # define LF_EXPORT __declspec(dllimport)
77 # else
78 # define LF_EXPORT
79 # endif
80 # endif
81 #endif
82 
83 #ifndef CONF_LENSFUN_INTERNAL
84 # ifdef __GNUC__
86 # define DEPRECATED __attribute__((deprecated))
87 # elif defined(_MSC_VER)
88 # define DEPRECATED __declspec(deprecated)
89 # else
90 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
91 # define DEPRECATED
92 # endif
93 #else
94 # define DEPRECATED
95 #endif
96 
98 #define cbool int
99 
108 typedef char *lfMLstr;
109 
112 {
119 };
120 
121 C_TYPEDEF (enum, lfError)
122 
123 
124 typedef unsigned char lf_u8;
126 typedef unsigned short lf_u16;
128 typedef unsigned int lf_u32;
130 typedef float lf_f32;
132 typedef double lf_f64;
133 
142 LF_EXPORT void lf_free (void *data);
143 
152 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
153 
170 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
171 
180 LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
181 
184 /*----------------------------------------------------------------------------*/
185 
202 {
208  lfMLstr Name;
210  char **Compat;
211 
212 #ifdef __cplusplus
213 
216  lfMount ();
217 
221  lfMount &operator = (const lfMount &other);
222 
226  ~lfMount ();
227 
238  void SetName (const char *val, const char *lang = NULL);
239 
245  void AddCompat (const char *val);
246 
252  bool Check ();
253 #endif
254 };
255 
256 C_TYPEDEF (struct, lfMount)
257 
258 
266 
276 LF_EXPORT void lf_mount_destroy (lfMount *mount);
277 
287 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
288 
291 
294 /*----------------------------------------------------------------------------*/
295 
314 {
316  lfMLstr Maker;
318  lfMLstr Model;
320  lfMLstr Variant;
322  char *Mount;
324  float CropFactor;
326  int Score;
327 
328 #ifdef __cplusplus
329 
332  lfCamera ();
333 
337  lfCamera (const lfCamera &other);
338 
342  ~lfCamera ();
343 
347  lfCamera &operator = (const lfCamera &other);
348 
359  void SetMaker (const char *val, const char *lang = NULL);
360 
371  void SetModel (const char *val, const char *lang = NULL);
372 
383  void SetVariant (const char *val, const char *lang = NULL);
384 
390  void SetMount (const char *val);
391 
397  bool Check ();
398 #endif
399 };
400 
401 C_TYPEDEF (struct, lfCamera)
402 
403 
411 
421 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
422 
432 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
433 
436 
439 /*----------------------------------------------------------------------------*/
440 
462 {
490 };
491 
493 
494 
501 {
503  enum lfDistortionModel Model;
505  float Focal;
507  float Terms [3];
508 };
509 
511 
512 
526 {
541 
554 };
555 
556 C_TYPEDEF (enum, lfTCAModel)
557 
558 
566 {
568  enum lfTCAModel Model;
570  float Focal;
572  float Terms [6];
573 };
574 
575 C_TYPEDEF (struct, lfLensCalibTCA)
576 
577 
594 {
607 };
608 
610 
611 
619 {
621  enum lfVignettingModel Model;
623  float Focal;
625  float Aperture;
627  float Distance;
629  float Terms [3];
630 };
631 
633 
634 
638 {
645 };
646 
647 C_TYPEDEF(enum, lfCropMode)
648 
649 
653 {
655  float Focal;
657  enum lfCropMode CropMode;
666  float Crop [4];
667 };
668 
669 C_TYPEDEF (struct, lfLensCalibCrop)
670 
671 
679 {
681  float Focal;
691  float FieldOfView;
692 };
693 
694 C_TYPEDEF (struct, lfLensCalibFov)
695 
696 
701 {
703  float Focal;
715  float RealFocal;
716 };
717 
719 
720 
724 {
726  const char *Name;
728  float Min;
730  float Max;
732  float Default;
733 };
734 
735 C_TYPEDEF (struct, lfParameter)
736 
737 
741 {
781 };
782 
783 C_TYPEDEF (enum, lfLensType)
784 
785 
796 {
798  lfMLstr Maker;
800  lfMLstr Model;
802  float MinFocal;
804  float MaxFocal;
806  float MinAperture;
808  float MaxAperture;
810  char **Mounts;
820  float CenterX;
822  float CenterY;
824  float CropFactor;
826  float AspectRatio;
842  int Score;
843 
844 #ifdef __cplusplus
845 
848  lfLens ();
849 
853  lfLens (const lfLens &other);
854 
858  ~lfLens ();
859 
863  lfLens &operator = (const lfLens &other);
864 
875  void SetMaker (const char *val, const char *lang = NULL);
876 
887  void SetModel (const char *val, const char *lang = NULL);
888 
896  void AddMount (const char *val);
897 
906  void AddCalibDistortion (const lfLensCalibDistortion *dc);
907 
913  bool RemoveCalibDistortion (int idx);
914 
924  void AddCalibTCA (const lfLensCalibTCA *tcac);
925 
931  bool RemoveCalibTCA (int idx);
932 
941  void AddCalibVignetting (const lfLensCalibVignetting *vc);
942 
948  bool RemoveCalibVignetting (int idx);
949 
958  void AddCalibCrop (const lfLensCalibCrop *cc);
959 
965  bool RemoveCalibCrop (int idx);
966 
978  DEPRECATED void AddCalibFov (const lfLensCalibFov *cf);
979 
989  DEPRECATED bool RemoveCalibFov (int idx);
990 
999  void AddCalibRealFocal (const lfLensCalibRealFocal *cf);
1000 
1007  bool RemoveCalibRealFocal (int idx);
1008 
1017  void GuessParameters ();
1018 
1024  bool Check ();
1025 
1041  static const char *GetDistortionModelDesc (
1042  lfDistortionModel model, const char **details, const lfParameter ***params);
1058  static const char *GetTCAModelDesc (
1059  lfTCAModel model, const char **details, const lfParameter ***params);
1060 
1076  static const char *GetVignettingModelDesc (
1077  lfVignettingModel model, const char **details, const lfParameter ***params);
1078 
1094  static const char *GetCropDesc (
1095  lfCropMode mode, const char **details, const lfParameter ***params);
1096 
1108  static const char *GetLensTypeDesc (lfLensType type, const char **details);
1109 
1117  bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
1118 
1126  bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
1127 
1141  bool InterpolateVignetting (
1142  float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
1143 
1151  bool InterpolateCrop (float focal, lfLensCalibCrop &res) const;
1152 
1164  DEPRECATED bool InterpolateFov (float focal, lfLensCalibFov &res) const;
1165 
1177  bool InterpolateRealFocal (float focal, lfLensCalibRealFocal &res) const;
1178 #endif
1179 };
1180 
1181 C_TYPEDEF (struct, lfLens)
1182 
1183 
1191 
1201 LF_EXPORT void lf_lens_destroy (lfLens *lens);
1202 
1212 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
1213 
1216 
1219 
1222  enum lfDistortionModel model, const char **details, const lfParameter ***params);
1223 
1225 LF_EXPORT const char *lf_get_tca_model_desc (
1226  enum lfTCAModel model, const char **details, const lfParameter ***params);
1227 
1230  enum lfVignettingModel model, const char **details, const lfParameter ***params);
1231 
1233 LF_EXPORT const char *lf_get_crop_desc (
1234  enum lfCropMode mode, const char **details, const lfParameter ***params);
1235 
1237 LF_EXPORT const char *lf_get_lens_type_desc (
1238  enum lfLensType type, const char **details);
1239 
1241 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
1242  lfLensCalibDistortion *res);
1243 
1245 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
1246 
1248 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
1249  float distance, lfLensCalibVignetting *res);
1250 
1252 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float focal,
1253  lfLensCalibCrop *res);
1254 
1256 DEPRECATED LF_EXPORT cbool lf_lens_interpolate_fov (const lfLens *lens, float focal,
1257  lfLensCalibFov *res);
1258 
1260 LF_EXPORT cbool lf_lens_interpolate_real_focal (const lfLens *lens, float focal,
1261  lfLensCalibRealFocal *res);
1262 
1265 
1268 
1270 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
1271 
1274 
1277 
1280 
1282 LF_EXPORT void lf_lens_add_calib_crop (lfLens *lens, const lfLensCalibCrop *cc);
1283 
1286 
1289 
1292 
1295 
1298 
1301 /*----------------------------------------------------------------------------*/
1302 
1312 enum
1313 {
1334 };
1335 
1359 {
1365 
1366 #ifdef __cplusplus
1367  lfDatabase ();
1368  ~lfDatabase ();
1369 
1373  static lfDatabase *Create ();
1374 
1378  void Destroy ();
1379 
1390  bool LoadDirectory (const char *dirname);
1391 
1399  lfError Load ();
1400 
1413  lfError Load (const char *filename);
1414 
1429  lfError Load (const char *errcontext, const char *data, size_t data_size);
1430 
1438  lfError Save (const char *filename) const;
1439 
1453  lfError Save (const char *filename,
1454  const lfMount *const *mounts,
1455  const lfCamera *const *cameras,
1456  const lfLens *const *lenses) const;
1457 
1470  static char *Save (const lfMount *const *mounts,
1471  const lfCamera *const *cameras,
1472  const lfLens *const *lenses);
1473 
1498  const lfCamera **FindCameras (const char *maker, const char *model) const;
1499 
1520  const lfCamera **FindCamerasExt (const char *maker, const char *model,
1521  int sflags = 0) const;
1522 
1530  const lfCamera *const *GetCameras () const;
1531 
1569  const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1570  const char *model, int sflags = 0) const;
1571 
1589  const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
1590 
1598  const lfLens *const *GetLenses () const;
1599 
1607  const lfMount *FindMount (const char *mount) const;
1608 
1616  const char *MountName (const char *mount) const;
1617 
1625  const lfMount *const *GetMounts () const;
1626 
1632  void AddMount (lfMount *mount);
1633 
1639  void AddCamera (lfCamera *camera);
1640 
1646  void AddLens (lfLens *lens);
1647 
1648 private:
1649 #endif
1650  void *Mounts;
1651  void *Cameras;
1652  void *Lenses;
1653 };
1654 
1655 C_TYPEDEF (struct, lfDatabase)
1656 
1657 
1668 
1679 
1682 
1684 LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
1685 
1687 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
1688  const char *data, size_t data_size);
1689 
1691 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1692 
1694 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
1695  const lfMount *const *mounts,
1696  const lfCamera *const *cameras,
1697  const lfLens *const *lenses);
1698 
1700 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
1701  const lfCamera *const *cameras,
1702  const lfLens *const *lenses);
1703 
1706  const lfDatabase *db, const char *maker, const char *model);
1707 
1710  const lfDatabase *db, const char *maker, const char *model, int sflags);
1711 
1713 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
1714 
1717  const lfDatabase *db, const lfCamera *camera, const char *maker,
1718  const char *lens, int sflags);
1719 
1722  const lfDatabase *db, const lfLens *lens, int sflags);
1723 
1725 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
1726 
1728 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1729 
1731 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1732 
1734 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
1735 
1738 /*----------------------------------------------------------------------------*/
1739 
1748 enum
1749 {
1751  LF_MODIFY_TCA = 0x00000001,
1753  LF_MODIFY_VIGNETTING = 0x00000002,
1754  /* Value 0x00000004 is deprecated. */
1756  LF_MODIFY_DISTORTION = 0x00000008,
1758  LF_MODIFY_GEOMETRY = 0x00000010,
1760  LF_MODIFY_SCALE = 0x00000020,
1763 };
1764 
1767 {
1778 };
1779 
1780 C_TYPEDEF (enum, lfPixelFormat)
1781 
1782 
1786 {
1809 };
1810 
1811 C_TYPEDEF (enum, lfComponentRole)
1812 
1813 
1814 #define LF_CR_1(a) (LF_CR_ ## a)
1815 
1816 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1817 
1818 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1819  ((LF_CR_ ## c) << 8))
1820 
1821 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1822  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1823 
1824 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1825  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1826  ((LF_CR_ ## e) << 16))
1827 
1828 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1829  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1830  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1831 
1832 #define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1833  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1834  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1835  ((LF_CR_ ## g) << 24))
1836 
1837 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1838  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1839  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1840  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1841 
1857 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
1858 
1883 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
1884  void *pixels, int comp_role, int count);
1885 
1898 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
1899 
1900 // @cond
1901 
1903 struct lfCallbackData
1904 {
1905  int priority;
1906  void *data;
1907  size_t data_size;
1908 };
1909 
1910 // A test point in the autoscale algorithm
1911 typedef struct { float angle, dist; } lfPoint;
1912 
1913 // @endcond
1914 
1994 #ifdef __cplusplus
1995 }
1996 #endif
1997 
1999 {
2000 #ifdef __cplusplus
2001 
2022  lfModifier (const lfLens *lens, float crop, int width, int height);
2023  ~lfModifier ();
2024 
2048  static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
2049 
2095  int Initialize (
2096  const lfLens *lens, lfPixelFormat format, float focal, float aperture,
2097  float distance, float scale, lfLensType targeom, int flags, bool reverse);
2098 
2104  void Destroy ();
2105 
2122  void AddCoordCallback (lfModifyCoordFunc callback, int priority,
2123  void *data, size_t data_size);
2124 
2142  void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
2143  void *data, size_t data_size);
2144 
2161  void AddColorCallback (lfModifyColorFunc callback, int priority,
2162  void *data, size_t data_size);
2163 
2178  bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
2179 
2194  bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
2195  bool reverse = false);
2196 
2210  bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
2211 
2226  bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal);
2227 
2244  bool AddCoordCallbackScale (float scale, bool reverse = false);
2245 
2259  float GetAutoScale (bool reverse);
2260 
2290  bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
2291  int comp_role, int row_stride) const;
2292 
2323  bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
2324  float *res) const;
2325 
2357  bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
2358  float *res) const;
2359 
2390  bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
2391  float *res) const;
2392 
2393 private:
2424  float GetRealFocalLength (const lfLens *lens, float focal);
2425 
2426  void AddCallback (void *arr, lfCallbackData *d,
2427  int priority, void *data, size_t data_size);
2428 
2442  double AutoscaleResidualDistance (float *coord) const;
2457  float GetTransformedDistance (lfPoint point) const;
2458 
2459  static void ModifyCoord_UnTCA_Linear (void *data, float *iocoord, int count);
2460  static void ModifyCoord_TCA_Linear (void *data, float *iocoord, int count);
2461  static void ModifyCoord_UnTCA_Poly3 (void *data, float *iocoord, int count);
2462  static void ModifyCoord_TCA_Poly3 (void *data, float *iocoord, int count);
2463 
2464  static void ModifyCoord_UnDist_Poly3 (void *data, float *iocoord, int count);
2465  static void ModifyCoord_Dist_Poly3 (void *data, float *iocoord, int count);
2466 #ifdef VECTORIZATION_SSE
2467  static void ModifyCoord_Dist_Poly3_SSE (void *data, float *iocoord, int count);
2468 #endif
2469  static void ModifyCoord_UnDist_Poly5 (void *data, float *iocoord, int count);
2470  static void ModifyCoord_Dist_Poly5 (void *data, float *iocoord, int count);
2471  static void ModifyCoord_UnDist_PTLens (void *data, float *iocoord, int count);
2472  static void ModifyCoord_Dist_PTLens (void *data, float *iocoord, int count);
2473 #ifdef VECTORIZATION_SSE
2474  static void ModifyCoord_UnDist_PTLens_SSE (void *data, float *iocoord, int count);
2475  static void ModifyCoord_Dist_PTLens_SSE (void *data, float *iocoord, int count);
2476 #endif
2477  static void ModifyCoord_Geom_FishEye_Rect (void *data, float *iocoord, int count);
2478  static void ModifyCoord_Geom_Panoramic_Rect (void *data, float *iocoord, int count);
2479  static void ModifyCoord_Geom_ERect_Rect (void *data, float *iocoord, int count);
2480  static void ModifyCoord_Geom_Rect_FishEye (void *data, float *iocoord, int count);
2481  static void ModifyCoord_Geom_Panoramic_FishEye (void *data, float *iocoord, int count);
2482  static void ModifyCoord_Geom_ERect_FishEye (void *data, float *iocoord, int count);
2483  static void ModifyCoord_Geom_Rect_Panoramic (void *data, float *iocoord, int count);
2484  static void ModifyCoord_Geom_FishEye_Panoramic (void *data, float *iocoord, int count);
2485  static void ModifyCoord_Geom_ERect_Panoramic (void *data, float *iocoord, int count);
2486  static void ModifyCoord_Geom_Rect_ERect (void *data, float *iocoord, int count);
2487  static void ModifyCoord_Geom_FishEye_ERect (void *data, float *iocoord, int count);
2488  static void ModifyCoord_Geom_Panoramic_ERect (void *data, float *iocoord, int count);
2489  static void ModifyCoord_Geom_Orthographic_ERect (void *data, float *iocoord, int count);
2490  static void ModifyCoord_Geom_ERect_Orthographic (void *data, float *iocoord, int count);
2491  static void ModifyCoord_Geom_Stereographic_ERect (void *data, float *iocoord, int count);
2492  static void ModifyCoord_Geom_ERect_Stereographic (void *data, float *iocoord, int count);
2493  static void ModifyCoord_Geom_Equisolid_ERect (void *data, float *iocoord, int count);
2494  static void ModifyCoord_Geom_ERect_Equisolid (void *data, float *iocoord, int count);
2495  static void ModifyCoord_Geom_Thoby_ERect (void *data, float *iocoord, int count);
2496  static void ModifyCoord_Geom_ERect_Thoby (void *data, float *iocoord, int count);
2497 #ifdef VECTORIZATION_SSE
2498  static void ModifyColor_DeVignetting_PA_SSE (
2499  void *data, float _x, float _y, lf_f32 *pixels, int comp_role, int count);
2500 #endif
2501 #ifdef VECTORIZATION_SSE2
2502  static void ModifyColor_DeVignetting_PA_SSE2 (
2503  void *data, float _x, float _y, lf_u16 *pixels, int comp_role, int count);
2504 #endif
2505 
2506  template<typename T> static void ModifyColor_Vignetting_PA (
2507  void *data, float x, float y, T *rgb, int comp_role, int count);
2508  template<typename T> static void ModifyColor_DeVignetting_PA (
2509  void *data, float x, float y, T *rgb, int comp_role, int count);
2510 
2511  static void ModifyCoord_Scale (void *data, float *iocoord, int count);
2512 #endif
2513  int Width, Height;
2516  double CenterX, CenterY;
2518  double NormScale, NormUnScale;
2521  double NormalizedInMillimeters;
2524  double AspectRatioCorrection;
2525 
2527  void *SubpixelCallbacks;
2529  void *ColorCallbacks;
2531  void *CoordCallbacks;
2532 
2534  double MaxX, MaxY;
2535 };
2536 
2537 #ifdef __cplusplus
2538 extern "C" {
2539 #endif
2540 
2541 C_TYPEDEF (struct, lfModifier)
2542 
2543 
2545  const lfLens *lens, float crop, int width, int height);
2546 
2548 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
2549 
2552  lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
2553  float focal, float aperture, float distance, float scale,
2554  lfLensType targeom, int flags, cbool reverse);
2555 
2558  lfModifier *modifier, lfModifyCoordFunc callback, int priority,
2559  void *data, size_t data_size);
2560 
2563  lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
2564  void *data, size_t data_size);
2565 
2568  lfModifier *modifier, lfModifyColorFunc callback, int priority,
2569  void *data, size_t data_size);
2570 
2573  lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
2574 
2577  lfModifier *modifier, lfLensCalibVignetting *model,
2578  lfPixelFormat format, cbool reverse);
2579 
2582  lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
2583 
2586  lfModifier *modifier, lfLensType from, lfLensType to, float focal);
2587 
2590  lfModifier *modifier, float scale, cbool reverse);
2591 
2594  lfModifier *modifier, cbool reverse);
2595 
2598  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2599 
2602  lfModifier *modifier, void *pixels, float x, float y, int width, int height,
2603  int comp_role, int row_stride);
2604 
2607  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2608 
2611  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2612 
2615 #undef cbool
2616 
2617 #ifdef __cplusplus
2618 }
2619 #endif
2620 
2621 #endif /* __LENSFUN_H__ */
Panoramic (cylindrical)
Definition: lensfun.h:761
lfError lf_db_load_file(lfDatabase *db, const char *filename)
lfDistortionModel
The Lensfun library implements several lens distortion models. This enum lists them.
Definition: lensfun.h:461
float MinAperture
Definition: lensfun.h:806
Definition: lensfun.h:1771
Definition: lensfun.h:1800
cbool lf_modifier_apply_subpixel_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
unsigned int lf_u32
Definition: lensfun.h:128
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:798
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:830
float FieldOfView
Field of view for given images.
Definition: lensfun.h:691
Rectilinear lens.
Definition: lensfun.h:748
Definition: lensfun.h:1756
lfLensType Type
Definition: lensfun.h:828
This flag makes Lensfun to sort the results by focal length, and remove all double lens names...
Definition: lensfun.h:1333
char ** Compat
Definition: lensfun.h:210
lfLensCalibVignetting ** CalibVignetting
Definition: lensfun.h:834
char * UserUpdatesDir
Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates") ...
Definition: lensfun.h:1364
no crop at all
Definition: lensfun.h:640
Definition: lensfun.h:1777
Definition: lensfun.h:1769
5th order polynomial model.
Definition: lensfun.h:481
lfError
Definition: lensfun.h:111
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:820
float CropFactor
Definition: lensfun.h:824
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:623
Laterlal chromatic aberrations calibration data.
Definition: lensfun.h:565
Definition: lensfun.h:118
Lens distortion calibration data.
Definition: lensfun.h:500
void lf_modifier_add_subpixel_callback(lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
double lf_f64
Definition: lensfun.h:132
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:795
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:1766
Definition: lensfun.h:1760
float AspectRatio
Definition: lensfun.h:826
lfVignettingModel
The Lensfun library supports several models for lens vignetting correction.
Definition: lensfun.h:593
lfLensCalibTCA ** CalibTCA
Definition: lensfun.h:832
float CenterY
Definition: lensfun.h:822
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:201
float MinFocal
Definition: lensfun.h:802
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
Stereographic fisheye.
Definition: lensfun.h:772
int Score
Definition: lensfun.h:842
Linear lateral chromatic aberrations model.
Definition: lensfun.h:540
Third order polynomial.
Definition: lensfun.h:553
Definition: lensfun.h:1758
use a circular crop, e.g. for circular fisheye images
Definition: lensfun.h:644
#define cbool
C-compatible bool type; don't bother to define Yet Another Boolean Type.
Definition: lensfun.h:98
lfMLstr Model
Definition: lensfun.h:800
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:655
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:326
void lf_free(void *data)
cbool lf_mount_check(lfMount *mount)
float lf_modifier_get_auto_scale(lfModifier *modifier, cbool reverse)
Orthographic fisheye.
Definition: lensfun.h:770
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:740
Definition: lensfun.h:1753
cbool lf_lens_remove_calib_crop(lfLens *lens, int idx)
float Focal
Definition: lensfun.h:703
PTLens model, which is also used by Hugin.
Definition: lensfun.h:489
Definition: lensfun.h:1802
3rd order polynomial model, which is a subset of the PTLens model.
Definition: lensfun.h:472
use a rectangular crop
Definition: lensfun.h:642
const char * lf_get_tca_model_desc(enum lfTCAModel model, const char **details, const lfParameter ***params)
cbool lf_modifier_add_subpixel_callback_TCA(lfModifier *modifier, lfLensCalibTCA *model, cbool reverse)
const lfMount * lf_db_find_mount(const lfDatabase *db, const char *mount)
void(* lfSubpixelCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the separate coordinates for all color components for every pixel ...
Definition: lensfun.h:1857
#define C_TYPEDEF(t, c)
Definition: lensfun.h:30
Equisolid fisheye.
Definition: lensfun.h:774
Fisheye as measured by Thoby (for Nikkor 10.5).
Definition: lensfun.h:780
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:570
cbool lf_lens_interpolate_crop(const lfLens *lens, float focal, lfLensCalibCrop *res)
Definition: lensfun.h:1804
unsigned char lf_u8
Definition: lensfun.h:124
Definition: lensfun.h:1806
#define LF_EXPORT
This macro expands to an appropiate symbol visibility declaration.
Definition: lensfun.h:64
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:728
float Max
Maximal value that has sense.
Definition: lensfun.h:730
Unknown lens type.
Definition: lensfun.h:743
Struct to save real focal length, which can depends on the (nominal) focal length.
Definition: lensfun.h:700
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.
Definition: lensfun.h:715
A modifier object contains optimized data required to rectify a image.
Definition: lensfun.h:1998
cbool lf_camera_check(lfCamera *camera)
Definition: lensfun.h:1791
float CropFactor
Camera crop factor (ex: 1.0). Must be defined.
Definition: lensfun.h:324
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:116
This flag selects a looser search algorithm resulting in more results (still sorted by score)...
Definition: lensfun.h:1321
float Distance
Focus distance in meters.
Definition: lensfun.h:627
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:625
#define DEPRECATED
For marking deprecated functions, see http://stackoverflow.com/a/21265197.
Definition: lensfun.h:91
Definition: lensfun.h:1808
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:804
Definition: lensfun.h:1751
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:126
lfComponentRole
These constants define the role of every pixel component, four bits each. "pixel" refers here to a se...
Definition: lensfun.h:1785
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
char ** Mounts
Definition: lensfun.h:810
Equirectangular.
Definition: lensfun.h:768
Definition: lensfun.h:1798
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:505
float Focal
Definition: lensfun.h:681
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:1762
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:754
lfError lf_db_load_data(lfDatabase *db, const char *errcontext, const char *data, size_t data_size)
cbool lf_modifier_add_coord_callback_geometry(lfModifier *modifier, lfLensType from, lfLensType to, float focal)
void lf_modifier_add_color_callback(lfModifier *modifier, lfModifyColorFunc callback, int priority, void *data, size_t data_size)
Definition: lensfun.h:1773
No TCA correction data is known.
Definition: lensfun.h:528
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition: lensfun.h:318
const char * lf_get_crop_desc(enum lfCropMode mode, const char **details, const lfParameter ***params)
lfLensCalibFov ** CalibFov
Definition: lensfun.h:838
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition: lensfun.h:316
DEPRECATED cbool lf_lens_remove_calib_fov(lfLens *lens, int idx)
Definition: lensfun.h:114
lfDatabase * lf_db_new(void)
Create a new empty database object.
cbool lf_lens_check(lfLens *lens)
const char * lf_get_vignetting_model_desc(enum lfVignettingModel model, const char **details, const lfParameter ***params)
char * Mount
Camera mount type (ex: "QBM")
Definition: lensfun.h:322
char * lfMLstr
Definition: lensfun.h:108
A lens database object.
Definition: lensfun.h:1358
cbool lf_lens_interpolate_real_focal(const lfLens *lens, float focal, lfLensCalibRealFocal *res)
void lf_lens_add_calib_crop(lfLens *lens, const lfLensCalibCrop *cc)
const lfLens *const * lf_db_get_lenses(const lfDatabase *db)
Pablo D'Angelo vignetting model (which is a more general variant of the law).
Definition: lensfun.h:606
Distortion parameters are unknown.
Definition: lensfun.h:464
lfMLstr Name
Camera mount name.
Definition: lensfun.h:208
Lens vignetting calibration data.
Definition: lensfun.h:618
cbool lf_lens_remove_calib_real_focal(lfLens *lens, int idx)
float lf_f32
Definition: lensfun.h:130
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:596
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:525
cbool lf_modifier_add_coord_callback_distortion(lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
float Default
Default value for the parameter.
Definition: lensfun.h:732
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:1883
void lf_lens_add_calib_real_focal(lfLens *lens, const lfLensCalibRealFocal *cf)
lfMount * lf_mount_new()
Create a new mount object.
lfCropMode
Different crop modes.
Definition: lensfun.h:637
Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED) ...
Definition: lensfun.h:678
lfLensCalibCrop ** CalibCrop
Definition: lensfun.h:836
Camera data. Unknown fields are set to NULL.
Definition: lensfun.h:313
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:320
void(* lfModifyCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the coordinates of a strip of pixels.
Definition: lensfun.h:1898
Struct to save image crop, which can depend on the focal length.
Definition: lensfun.h:652
Definition: lensfun.h:1775
lfError lf_db_save_file(const lfDatabase *db, const char *filename, const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses)
const char * Name
Parameter name (something like 'k', 'k3', 'omega' etc.)
Definition: lensfun.h:726
This structure describes a single parameter for some lens model.
Definition: lensfun.h:723
lfError lf_db_load(lfDatabase *db)
cbool lf_lens_remove_calib_distortion(lfLens *lens, int idx)
char * HomeDataDir
Home lens database directory (something like "~/.local/share/lensfun")
Definition: lensfun.h:1361
lfLensCalibRealFocal ** CalibRealFocal
Definition: lensfun.h:840
float MaxAperture
Definition: lensfun.h:808