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 
29 #include <vector>
30 
32 typedef std::vector<float> fvector;
33 
34 extern "C" {
36 # define C_TYPEDEF(t,c)
37 #else
38 # define C_TYPEDEF(t,c) typedef t c c;
39 #endif
40 
46 /*----------------------------------------------------------------------------*/
47 
54 #define LF_VERSION_MAJOR 0
56 #define LF_VERSION_MINOR 3
58 #define LF_VERSION_MICRO 2
60 #define LF_VERSION_BUGFIX 0
62 #define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
64 
66 #define LF_MAX_DATABASE_VERSION 2
67 
68 #if defined CONF_LENSFUN_STATIC
69 # define LF_EXPORT
71 #else
72 # ifdef CONF_SYMBOL_VISIBILITY
73 # if defined PLATFORM_WINDOWS
74 # define LF_EXPORT __declspec(dllexport)
75 # elif defined CONF_COMPILER_GCC || __clang__
76 # define LF_EXPORT __attribute__((visibility("default")))
77 # else
78 # error "I don't know how to change symbol visibility for your compiler"
79 # endif
80 # else
81 # if defined PLATFORM_WINDOWS || defined _MSC_VER
82 # define LF_EXPORT __declspec(dllimport)
83 # else
84 # define LF_EXPORT
85 # endif
86 # endif
87 #endif
88 
89 #ifndef CONF_LENSFUN_INTERNAL
90 # ifdef __GNUC__
92 # define DEPRECATED __attribute__((deprecated))
93 # elif defined(_MSC_VER)
94 # define DEPRECATED __declspec(deprecated)
95 # else
96 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
97 # define DEPRECATED
98 # endif
99 #else
100 # define DEPRECATED
101 #endif
102 
104 #define cbool int
105 
114 typedef char *lfMLstr;
115 
118 {
125 };
126 
127 C_TYPEDEF (enum, lfError)
128 
129 
130 typedef unsigned char lf_u8;
132 typedef unsigned short lf_u16;
134 typedef unsigned int lf_u32;
136 typedef float lf_f32;
138 typedef double lf_f64;
139 
148 LF_EXPORT void lf_free (void *data);
149 
158 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
159 
176 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
177 
186 LF_EXPORT lfMLstr lf_mlstr_dup (const lfMLstr str);
187 
190 /*----------------------------------------------------------------------------*/
191 
208 {
214  lfMLstr Name;
216  char **Compat;
217 
218 #ifdef __cplusplus
219 
222  lfMount ();
223 
227  lfMount (const lfMount &other);
228 
232  lfMount &operator = (const lfMount &other);
233 
237  ~lfMount ();
238 
249  void SetName (const char *val, const char *lang = NULL);
250 
256  void AddCompat (const char *val);
257 
263  bool Check ();
264 #endif
265 };
266 
267 C_TYPEDEF (struct, lfMount)
268 
269 
277 
287 LF_EXPORT void lf_mount_destroy (lfMount *mount);
288 
298 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
299 
302 
305 /*----------------------------------------------------------------------------*/
306 
325 {
327  lfMLstr Maker;
329  lfMLstr Model;
331  lfMLstr Variant;
333  char *Mount;
335  float CropFactor;
337  int Score;
338 
339 #ifdef __cplusplus
340 
343  lfCamera ();
344 
348  lfCamera (const lfCamera &other);
349 
353  ~lfCamera ();
354 
358  lfCamera &operator = (const lfCamera &other);
359 
370  void SetMaker (const char *val, const char *lang = NULL);
371 
382  void SetModel (const char *val, const char *lang = NULL);
383 
394  void SetVariant (const char *val, const char *lang = NULL);
395 
401  void SetMount (const char *val);
402 
408  bool Check ();
409 #endif
410 };
411 
412 C_TYPEDEF (struct, lfCamera)
413 
414 
422 
432 LF_EXPORT void lf_camera_destroy (lfCamera *camera);
433 
443 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
444 
447 
450 /*----------------------------------------------------------------------------*/
451 
473 {
518 };
519 
521 
522 
529 {
531  enum lfDistortionModel Model;
533  float Focal;
535  float Terms [5];
536 };
537 
539 
540 
554 {
609 };
610 
611 C_TYPEDEF (enum, lfTCAModel)
612 
613 
621 {
623  enum lfTCAModel Model;
625  float Focal;
627  float Terms [12];
628 };
629 
630 C_TYPEDEF (struct, lfLensCalibTCA)
631 
632 
649 {
673 };
674 
676 
677 
685 {
687  enum lfVignettingModel Model;
689  float Focal;
691  float Aperture;
693  float Distance;
695  float Terms [3];
696 };
697 
699 
700 
704 {
711 };
712 
713 C_TYPEDEF(enum, lfCropMode)
714 
715 
719 {
721  float Focal;
723  enum lfCropMode CropMode;
732  float Crop [4];
733 };
734 
735 C_TYPEDEF (struct, lfLensCalibCrop)
736 
737 
745 {
747  float Focal;
757  float FieldOfView;
758 };
759 
760 C_TYPEDEF (struct, lfLensCalibFov)
761 
762 
767 {
769  float Focal;
781  float RealFocal;
782 };
783 
785 
786 
790 {
792  const char *Name;
794  float Min;
796  float Max;
798  float Default;
799 };
800 
801 C_TYPEDEF (struct, lfParameter)
802 
803 
807 {
847 };
848 
849 C_TYPEDEF (enum, lfLensType)
850 
851 
861 {
863  lfMLstr Maker;
865  lfMLstr Model;
867  float MinFocal;
869  float MaxFocal;
871  float MinAperture;
873  float MaxAperture;
875  char **Mounts;
885  float CenterX;
887  float CenterY;
889  float CropFactor;
891  float AspectRatio;
907  int Score;
908 
909 #ifdef __cplusplus
910 
913  lfLens ();
914 
918  lfLens (const lfLens &other);
919 
923  ~lfLens ();
924 
928  lfLens &operator = (const lfLens &other);
929 
940  void SetMaker (const char *val, const char *lang = NULL);
941 
952  void SetModel (const char *val, const char *lang = NULL);
953 
961  void AddMount (const char *val);
962 
971  void AddCalibDistortion (const lfLensCalibDistortion *dc);
972 
978  bool RemoveCalibDistortion (int idx);
979 
989  void AddCalibTCA (const lfLensCalibTCA *tcac);
990 
996  bool RemoveCalibTCA (int idx);
997 
1006  void AddCalibVignetting (const lfLensCalibVignetting *vc);
1007 
1013  bool RemoveCalibVignetting (int idx);
1014 
1023  void AddCalibCrop (const lfLensCalibCrop *cc);
1024 
1030  bool RemoveCalibCrop (int idx);
1031 
1043  DEPRECATED void AddCalibFov (const lfLensCalibFov *cf);
1044 
1054  DEPRECATED bool RemoveCalibFov (int idx);
1055 
1064  void AddCalibRealFocal (const lfLensCalibRealFocal *cf);
1065 
1072  bool RemoveCalibRealFocal (int idx);
1073 
1082  void GuessParameters ();
1083 
1089  bool Check ();
1090 
1106  static const char *GetDistortionModelDesc (
1107  lfDistortionModel model, const char **details, const lfParameter ***params);
1123  static const char *GetTCAModelDesc (
1124  lfTCAModel model, const char **details, const lfParameter ***params);
1125 
1141  static const char *GetVignettingModelDesc (
1142  lfVignettingModel model, const char **details, const lfParameter ***params);
1143 
1159  static const char *GetCropDesc (
1160  lfCropMode mode, const char **details, const lfParameter ***params);
1161 
1173  static const char *GetLensTypeDesc (lfLensType type, const char **details);
1174 
1182  bool InterpolateDistortion (float focal, lfLensCalibDistortion &res) const;
1183 
1191  bool InterpolateTCA (float focal, lfLensCalibTCA &res) const;
1192 
1206  bool InterpolateVignetting (
1207  float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
1208 
1216  bool InterpolateCrop (float focal, lfLensCalibCrop &res) const;
1217 
1229  DEPRECATED bool InterpolateFov (float focal, lfLensCalibFov &res) const;
1230 
1242  bool InterpolateRealFocal (float focal, lfLensCalibRealFocal &res) const;
1243 #endif
1244 };
1245 
1246 C_TYPEDEF (struct, lfLens)
1247 
1248 
1256 
1266 LF_EXPORT void lf_lens_destroy (lfLens *lens);
1267 
1277 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
1278 
1281 
1284 
1287  enum lfDistortionModel model, const char **details, const lfParameter ***params);
1288 
1290 LF_EXPORT const char *lf_get_tca_model_desc (
1291  enum lfTCAModel model, const char **details, const lfParameter ***params);
1292 
1295  enum lfVignettingModel model, const char **details, const lfParameter ***params);
1296 
1298 LF_EXPORT const char *lf_get_crop_desc (
1299  enum lfCropMode mode, const char **details, const lfParameter ***params);
1300 
1302 LF_EXPORT const char *lf_get_lens_type_desc (
1303  enum lfLensType type, const char **details);
1304 
1306 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float focal,
1307  lfLensCalibDistortion *res);
1308 
1310 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float focal, lfLensCalibTCA *res);
1311 
1313 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float focal, float aperture,
1314  float distance, lfLensCalibVignetting *res);
1315 
1317 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float focal,
1318  lfLensCalibCrop *res);
1319 
1321 DEPRECATED LF_EXPORT cbool lf_lens_interpolate_fov (const lfLens *lens, float focal,
1322  lfLensCalibFov *res);
1323 
1325 LF_EXPORT cbool lf_lens_interpolate_real_focal (const lfLens *lens, float focal,
1326  lfLensCalibRealFocal *res);
1327 
1330 
1333 
1335 LF_EXPORT void lf_lens_add_calib_tca (lfLens *lens, const lfLensCalibTCA *tcac);
1336 
1339 
1342 
1345 
1347 LF_EXPORT void lf_lens_add_calib_crop (lfLens *lens, const lfLensCalibCrop *cc);
1348 
1351 
1354 
1357 
1360 
1363 
1366 /*----------------------------------------------------------------------------*/
1367 
1377 enum
1378 {
1399 };
1400 
1421 {
1427 
1428 #ifdef __cplusplus
1429  lfDatabase ();
1430  ~lfDatabase ();
1431 
1436  DEPRECATED static lfDatabase *Create ();
1437 
1444  DEPRECATED void Destroy ();
1445 
1456  bool LoadDirectory (const char *dirname);
1457 
1466  lfError Load ();
1467 
1480  lfError Load (const char *filename);
1481 
1496  lfError Load (const char *errcontext, const char *data, size_t data_size);
1497 
1505  lfError Save (const char *filename) const;
1506 
1520  lfError Save (const char *filename,
1521  const lfMount *const *mounts,
1522  const lfCamera *const *cameras,
1523  const lfLens *const *lenses) const;
1524 
1537  static char *Save (const lfMount *const *mounts,
1538  const lfCamera *const *cameras,
1539  const lfLens *const *lenses);
1540 
1565  const lfCamera **FindCameras (const char *maker, const char *model) const;
1566 
1587  const lfCamera **FindCamerasExt (const char *maker, const char *model,
1588  int sflags = 0) const;
1589 
1597  const lfCamera *const *GetCameras () const;
1598 
1636  const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1637  const char *model, int sflags = 0) const;
1638 
1656  const lfLens **FindLenses (const lfLens *lens, int sflags = 0) const;
1657 
1665  const lfLens *const *GetLenses () const;
1666 
1674  const lfMount *FindMount (const char *mount) const;
1675 
1683  const char *MountName (const char *mount) const;
1684 
1692  const lfMount *const *GetMounts () const;
1693 
1699  void AddMount (lfMount *mount);
1700 
1706  void AddCamera (lfCamera *camera);
1707 
1713  void AddLens (lfLens *lens);
1714 
1715 private:
1716 #endif
1717  void *Mounts;
1718  void *Cameras;
1719  void *Lenses;
1720 };
1721 
1722 C_TYPEDEF (struct, lfDatabase)
1723 
1724 
1735 
1746 
1749 
1751 LF_EXPORT lfError lf_db_load_file (lfDatabase *db, const char *filename);
1752 
1754 LF_EXPORT cbool lf_db_load_directory (lfDatabase *db, const char *dirname);
1755 
1757 LF_EXPORT lfError lf_db_load_data (lfDatabase *db, const char *errcontext,
1758  const char *data, size_t data_size);
1759 
1761 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1762 
1764 LF_EXPORT lfError lf_db_save_file (const lfDatabase *db, const char *filename,
1765  const lfMount *const *mounts,
1766  const lfCamera *const *cameras,
1767  const lfLens *const *lenses);
1768 
1770 LF_EXPORT char *lf_db_save (const lfMount *const *mounts,
1771  const lfCamera *const *cameras,
1772  const lfLens *const *lenses);
1773 
1776  const lfDatabase *db, const char *maker, const char *model);
1777 
1780  const lfDatabase *db, const char *maker, const char *model, int sflags);
1781 
1783 LF_EXPORT const lfCamera *const *lf_db_get_cameras (const lfDatabase *db);
1784 
1787  const lfDatabase *db, const lfCamera *camera, const char *maker,
1788  const char *lens, int sflags);
1789 
1792  const lfDatabase *db, const lfLens *lens, int sflags);
1793 
1795 LF_EXPORT const lfLens *const *lf_db_get_lenses (const lfDatabase *db);
1796 
1798 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1799 
1801 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1802 
1804 LF_EXPORT const lfMount *const *lf_db_get_mounts (const lfDatabase *db);
1805 
1808 /*----------------------------------------------------------------------------*/
1809 
1818 enum
1819 {
1821  LF_MODIFY_TCA = 0x00000001,
1823  LF_MODIFY_VIGNETTING = 0x00000002,
1824  /* Value 0x00000004 is deprecated. */
1826  LF_MODIFY_DISTORTION = 0x00000008,
1828  LF_MODIFY_GEOMETRY = 0x00000010,
1830  LF_MODIFY_SCALE = 0x00000020,
1833 };
1834 
1837 {
1848 };
1849 
1850 C_TYPEDEF (enum, lfPixelFormat)
1851 
1852 
1856 {
1879 };
1880 
1881 C_TYPEDEF (enum, lfComponentRole)
1882 
1883 
1884 #define LF_CR_1(a) (LF_CR_ ## a)
1885 
1886 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
1887 
1888 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1889  ((LF_CR_ ## c) << 8))
1890 
1891 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1892  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
1893 
1894 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1895  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1896  ((LF_CR_ ## e) << 16))
1897 
1898 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1899  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1900  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
1901 
1902 #define LF_CR_7(a,b,c,d,e,f,g) ((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))
1906 
1907 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
1908  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
1909  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
1910  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
1911 
1927 typedef void (*lfSubpixelCoordFunc) (void *data, float *iocoord, int count);
1928 
1953 typedef void (*lfModifyColorFunc) (void *data, float x, float y,
1954  void *pixels, int comp_role, int count);
1955 
1968 typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
1969 
1970 // @cond
1971 
1973 struct lfCallbackData
1974 {
1975  int priority;
1976  void *data;
1977  size_t data_size;
1978 };
1979 
1980 // A test point in the autoscale algorithm
1981 typedef struct { float angle, dist; } lfPoint;
1982 
1983 // @endcond
1984 
2068 #ifdef __cplusplus
2069 }
2070 #endif
2071 
2073 {
2074 #ifdef __cplusplus
2075 
2096  lfModifier (const lfLens *lens, float crop, int width, int height);
2097  ~lfModifier ();
2098 
2125  DEPRECATED static lfModifier *Create (const lfLens *lens, float crop, int width, int height);
2126 
2172  int Initialize (
2173  const lfLens *lens, lfPixelFormat format, float focal, float aperture,
2174  float distance, float scale, lfLensType targeom, int flags, bool reverse);
2175 
2224  bool EnablePerspectiveCorrection (fvector x, fvector y, float d);
2225 
2232  DEPRECATED void Destroy ();
2233 
2250  void AddCoordCallback (lfModifyCoordFunc callback, int priority,
2251  void *data, size_t data_size);
2252 
2270  void AddSubpixelCallback (lfSubpixelCoordFunc callback, int priority,
2271  void *data, size_t data_size);
2272 
2289  void AddColorCallback (lfModifyColorFunc callback, int priority,
2290  void *data, size_t data_size);
2291 
2306  bool AddSubpixelCallbackTCA (lfLensCalibTCA &model, bool reverse = false);
2307 
2322  bool AddColorCallbackVignetting (lfLensCalibVignetting &model, lfPixelFormat format,
2323  bool reverse = false);
2324 
2338  bool AddCoordCallbackDistortion (lfLensCalibDistortion &model, bool reverse = false);
2339 
2354  bool AddCoordCallbackGeometry (lfLensType from, lfLensType to, float focal = 0);
2355 
2372  bool AddCoordCallbackScale (float scale, bool reverse = false);
2373 
2387  float GetAutoScale (bool reverse);
2388 
2418  bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
2419  int comp_role, int row_stride) const;
2420 
2451  bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
2452  float *res) const;
2453 
2485  bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
2486  float *res) const;
2487 
2518  bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
2519  float *res) const;
2520 
2521 private:
2552  float GetRealFocalLength (const lfLens *lens, float focal);
2553 
2554  void AddCallback (void *arr, lfCallbackData *d,
2555  int priority, void *data, size_t data_size);
2556 
2570  double AutoscaleResidualDistance (float *coord) const;
2585  float GetTransformedDistance (lfPoint point) const;
2586 
2587  static void ModifyCoord_UnTCA_Linear (void *data, float *iocoord, int count);
2588  static void ModifyCoord_TCA_Linear (void *data, float *iocoord, int count);
2589  static void ModifyCoord_UnTCA_Poly3 (void *data, float *iocoord, int count);
2590  static void ModifyCoord_TCA_Poly3 (void *data, float *iocoord, int count);
2591  static void ModifyCoord_TCA_ACM (void *data, float *iocoord, int count);
2592 
2593  static void ModifyCoord_UnDist_Poly3 (void *data, float *iocoord, int count);
2594  static void ModifyCoord_Dist_Poly3 (void *data, float *iocoord, int count);
2595 #ifdef VECTORIZATION_SSE
2596  static void ModifyCoord_Dist_Poly3_SSE (void *data, float *iocoord, int count);
2597 #endif
2598  static void ModifyCoord_UnDist_Poly5 (void *data, float *iocoord, int count);
2599  static void ModifyCoord_Dist_Poly5 (void *data, float *iocoord, int count);
2600  static void ModifyCoord_UnDist_PTLens (void *data, float *iocoord, int count);
2601  static void ModifyCoord_Dist_PTLens (void *data, float *iocoord, int count);
2602 #ifdef VECTORIZATION_SSE
2603  static void ModifyCoord_UnDist_PTLens_SSE (void *data, float *iocoord, int count);
2604  static void ModifyCoord_Dist_PTLens_SSE (void *data, float *iocoord, int count);
2605 #endif
2606  static void ModifyCoord_Dist_ACM (void *data, float *iocoord, int count);
2607  static void ModifyCoord_Geom_FishEye_Rect (void *data, float *iocoord, int count);
2608  static void ModifyCoord_Geom_Panoramic_Rect (void *data, float *iocoord, int count);
2609  static void ModifyCoord_Geom_ERect_Rect (void *data, float *iocoord, int count);
2610  static void ModifyCoord_Geom_Rect_FishEye (void *data, float *iocoord, int count);
2611  static void ModifyCoord_Geom_Panoramic_FishEye (void *data, float *iocoord, int count);
2612  static void ModifyCoord_Geom_ERect_FishEye (void *data, float *iocoord, int count);
2613  static void ModifyCoord_Geom_Rect_Panoramic (void *data, float *iocoord, int count);
2614  static void ModifyCoord_Geom_FishEye_Panoramic (void *data, float *iocoord, int count);
2615  static void ModifyCoord_Geom_ERect_Panoramic (void *data, float *iocoord, int count);
2616  static void ModifyCoord_Geom_Rect_ERect (void *data, float *iocoord, int count);
2617  static void ModifyCoord_Geom_FishEye_ERect (void *data, float *iocoord, int count);
2618  static void ModifyCoord_Geom_Panoramic_ERect (void *data, float *iocoord, int count);
2619  static void ModifyCoord_Geom_Orthographic_ERect (void *data, float *iocoord, int count);
2620  static void ModifyCoord_Geom_ERect_Orthographic (void *data, float *iocoord, int count);
2621  static void ModifyCoord_Geom_Stereographic_ERect (void *data, float *iocoord, int count);
2622  static void ModifyCoord_Geom_ERect_Stereographic (void *data, float *iocoord, int count);
2623  static void ModifyCoord_Geom_Equisolid_ERect (void *data, float *iocoord, int count);
2624  static void ModifyCoord_Geom_ERect_Equisolid (void *data, float *iocoord, int count);
2625  static void ModifyCoord_Geom_Thoby_ERect (void *data, float *iocoord, int count);
2626  static void ModifyCoord_Geom_ERect_Thoby (void *data, float *iocoord, int count);
2627  static void ModifyCoord_Perspective_Correction (void *data, float *iocoord, int count);
2628 #ifdef VECTORIZATION_SSE
2629  static void ModifyColor_DeVignetting_PA_SSE (
2630  void *data, float _x, float _y, lf_f32 *pixels, int comp_role, int count);
2631 #endif
2632 #ifdef VECTORIZATION_SSE2
2633  static void ModifyColor_DeVignetting_PA_SSE2 (
2634  void *data, float _x, float _y, lf_u16 *pixels, int comp_role, int count);
2635 #endif
2636 
2637  template<typename T> static void ModifyColor_Vignetting_PA (
2638  void *data, float x, float y, T *rgb, int comp_role, int count);
2639  template<typename T> static void ModifyColor_DeVignetting_PA (
2640  void *data, float x, float y, T *rgb, int comp_role, int count);
2641 
2642  static void ModifyCoord_Scale (void *data, float *iocoord, int count);
2643 #endif
2644  double Width, Height;
2648  double CenterX, CenterY;
2650  double NormScale, NormUnScale;
2654  double NormalizedInMillimeters;
2657  double AspectRatioCorrection;
2658 
2660  void *SubpixelCallbacks;
2662  void *ColorCallbacks;
2664  void *CoordCallbacks;
2665 
2667  double MaxX, MaxY;
2668 
2674  double FocalLengthNormalized;
2676  bool Reverse;
2677 };
2678 
2679 #ifdef __cplusplus
2680 extern "C" {
2681 #endif
2682 
2683 C_TYPEDEF (struct, lfModifier)
2684 
2685 
2687  const lfLens *lens, float crop, int width, int height);
2688 
2690 LF_EXPORT void lf_modifier_destroy (lfModifier *modifier);
2691 
2694  lfModifier *modifier, const lfLens *lens, lfPixelFormat format,
2695  float focal, float aperture, float distance, float scale,
2696  lfLensType targeom, int flags, cbool reverse);
2697 
2700  lfModifier *modifier, float *x, float *y, int count, float d);
2701 
2704  lfModifier *modifier, lfModifyCoordFunc callback, int priority,
2705  void *data, size_t data_size);
2706 
2709  lfModifier *modifier, lfSubpixelCoordFunc callback, int priority,
2710  void *data, size_t data_size);
2711 
2714  lfModifier *modifier, lfModifyColorFunc callback, int priority,
2715  void *data, size_t data_size);
2716 
2719  lfModifier *modifier, lfLensCalibTCA *model, cbool reverse);
2720 
2723  lfModifier *modifier, lfLensCalibVignetting *model,
2724  lfPixelFormat format, cbool reverse);
2725 
2728  lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse);
2729 
2732  lfModifier *modifier, lfLensType from, lfLensType to);
2733 
2736  lfModifier *modifier, float scale, cbool reverse);
2737 
2740  lfModifier *modifier, cbool reverse);
2741 
2744  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2745 
2748  lfModifier *modifier, void *pixels, float x, float y, int width, int height,
2749  int comp_role, int row_stride);
2750 
2753  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2754 
2757  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2758 
2761 #undef cbool
2762 
2763 #ifdef __cplusplus
2764 }
2765 #endif
2766 
2767 #endif /* __LENSFUN_H__ */
Panoramic (cylindrical)
Definition: lensfun.h:827
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:472
float MinAperture
Definition: lensfun.h:871
Definition: lensfun.h:1841
Definition: lensfun.h:1870
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:517
unsigned int lf_u32
Definition: lensfun.h:134
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:863
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:895
float FieldOfView
Field of view for given images.
Definition: lensfun.h:757
Rectilinear lens.
Definition: lensfun.h:814
Definition: lensfun.h:1826
lfLensType Type
Definition: lensfun.h:893
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:1398
char ** Compat
Definition: lensfun.h:216
lfLensCalibVignetting ** CalibVignetting
Definition: lensfun.h:899
char * UserUpdatesDir
Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates") ...
Definition: lensfun.h:1426
no crop at all
Definition: lensfun.h:706
Definition: lensfun.h:1847
Definition: lensfun.h:1839
5th order polynomial model.
Definition: lensfun.h:492
lfError
Definition: lensfun.h:117
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:885
float CropFactor
Definition: lensfun.h:889
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:689
Laterlal chromatic aberrations calibration data.
Definition: lensfun.h:620
Definition: lensfun.h:124
Lens distortion calibration data.
Definition: lensfun.h:528
void lf_modifier_add_subpixel_callback(lfModifier *modifier, lfSubpixelCoordFunc callback, int priority, void *data, size_t data_size)
double lf_f64
Definition: lensfun.h:138
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:860
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:1836
Definition: lensfun.h:1830
float AspectRatio
Definition: lensfun.h:891
lfVignettingModel
The Lensfun library supports several models for lens vignetting correction.
Definition: lensfun.h:648
lfLensCalibTCA ** CalibTCA
Definition: lensfun.h:897
float CenterY
Definition: lensfun.h:887
Adobe camera model for TCA. The coordinate system is different here. Everything is measured in units ...
Definition: lensfun.h:608
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:207
float MinFocal
Definition: lensfun.h:867
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
Stereographic fisheye.
Definition: lensfun.h:838
int Score
Definition: lensfun.h:907
Linear lateral chromatic aberrations model.
Definition: lensfun.h:568
Third order polynomial.
Definition: lensfun.h:580
Definition: lensfun.h:1828
use a circular crop, e.g. for circular fisheye images
Definition: lensfun.h:710
#define cbool
C-compatible bool type; don't bother to define Yet Another Boolean Type.
Definition: lensfun.h:104
lfMLstr Model
Definition: lensfun.h:865
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:721
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:337
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:836
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:806
Definition: lensfun.h:1823
cbool lf_lens_remove_calib_crop(lfLens *lens, int idx)
float Focal
Definition: lensfun.h:769
PTLens model, which is also used by Hugin.
Definition: lensfun.h:500
Definition: lensfun.h:1872
3rd order polynomial model, which is a subset of the PTLens model.
Definition: lensfun.h:483
use a rectangular crop
Definition: lensfun.h:708
std::vector< float > fvector
Definition: lensfun.h:32
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:1927
#define C_TYPEDEF(t, c)
Definition: lensfun.h:36
Equisolid fisheye.
Definition: lensfun.h:840
Fisheye as measured by Thoby (for Nikkor 10.5).
Definition: lensfun.h:846
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:625
cbool lf_lens_interpolate_crop(const lfLens *lens, float focal, lfLensCalibCrop *res)
Definition: lensfun.h:1874
unsigned char lf_u8
Definition: lensfun.h:130
Definition: lensfun.h:1876
#define LF_EXPORT
This macro expands to an appropiate symbol visibility declaration.
Definition: lensfun.h:70
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:794
float Max
Maximal value that has sense.
Definition: lensfun.h:796
Unknown lens type.
Definition: lensfun.h:809
Struct to save real focal length, which can depends on the (nominal) focal length.
Definition: lensfun.h:766
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:781
A modifier object contains optimized data required to rectify a image.
Definition: lensfun.h:2072
cbool lf_camera_check(lfCamera *camera)
Definition: lensfun.h:1861
float CropFactor
Camera crop factor (ex: 1.0). Must be defined.
Definition: lensfun.h:335
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:122
This flag selects a looser search algorithm resulting in more results (still sorted by score)...
Definition: lensfun.h:1386
float Distance
Focus distance in meters.
Definition: lensfun.h:693
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:691
#define DEPRECATED
For marking deprecated functions, see http://stackoverflow.com/a/21265197.
Definition: lensfun.h:97
Definition: lensfun.h:1878
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:869
Definition: lensfun.h:1821
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:132
lfComponentRole
These constants define the role of every pixel component, four bits each. "pixel" refers here to a se...
Definition: lensfun.h:1855
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
char ** Mounts
Definition: lensfun.h:875
Equirectangular.
Definition: lensfun.h:834
Definition: lensfun.h:1868
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:533
float Focal
Definition: lensfun.h:747
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:1832
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:820
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:1843
No TCA correction data is known.
Definition: lensfun.h:556
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition: lensfun.h:329
const char * lf_get_crop_desc(enum lfCropMode mode, const char **details, const lfParameter ***params)
lfLensCalibFov ** CalibFov
Definition: lensfun.h:903
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition: lensfun.h:327
DEPRECATED cbool lf_lens_remove_calib_fov(lfLens *lens, int idx)
Definition: lensfun.h:120
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:333
char * lfMLstr
Definition: lensfun.h:114
A lens database object.
Definition: lensfun.h:1420
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:661
Distortion parameters are unknown.
Definition: lensfun.h:475
lfMLstr Name
Camera mount name.
Definition: lensfun.h:214
Lens vignetting calibration data.
Definition: lensfun.h:684
cbool lf_lens_remove_calib_real_focal(lfLens *lens, int idx)
float lf_f32
Definition: lensfun.h:136
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:651
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:553
cbool lf_modifier_add_coord_callback_distortion(lfModifier *modifier, lfLensCalibDistortion *model, cbool reverse)
float Default
Default value for the parameter.
Definition: lensfun.h:798
Adobe's vignetting model. It differs from D'Angelo's model only in the coordinate system...
Definition: lensfun.h:672
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:1953
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:703
Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED) ...
Definition: lensfun.h:744
lfLensCalibCrop ** CalibCrop
Definition: lensfun.h:901
Camera data. Unknown fields are set to NULL.
Definition: lensfun.h:324
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:331
void(* lfModifyCoordFunc)(void *data, float *iocoord, int count)
A callback function which modifies the coordinates of a strip of pixels.
Definition: lensfun.h:1968
Struct to save image crop, which can depend on the focal length.
Definition: lensfun.h:718
cbool lf_modifier_add_coord_callback_geometry(lfModifier *modifier, lfLensType from, lfLensType to)
Definition: lensfun.h:1845
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:792
This structure describes a single parameter for some lens model.
Definition: lensfun.h:789
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:1423
cbool lf_db_load_directory(lfDatabase *db, const char *dirname)
lfLensCalibRealFocal ** CalibRealFocal
Definition: lensfun.h:905
float MaxAperture
Definition: lensfun.h:873