lensfun  0.3.99.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 #ifndef __cplusplus
28  #if (defined(_MSC_VER) && (_MSC_VER < 1800)) // Visual studio up to VS2013 does not have stdbool.h
29  typedef int bool;
30  #define true 1
31  #define false 0
32  #else
33  #include <stdbool.h>
34  #endif
35 #endif
36 
37 #ifdef __cplusplus
38 
39 #include <string>
40 #include <vector>
41 #include <set>
42 
43 extern "C" {
45 # define C_TYPEDEF(t,c)
46 #else
47 # define C_TYPEDEF(t,c) typedef t c c;
48 #endif
49 
55 /*----------------------------------------------------------------------------*/
56 
64 #define LF_VERSION_MAJOR 0
66 #define LF_VERSION_MINOR 3
68 #define LF_VERSION_MICRO 99
70 #define LF_VERSION_BUGFIX 0
72 #define LF_VERSION ((LF_VERSION_MAJOR << 24) | (LF_VERSION_MINOR << 16) | (LF_VERSION_MICRO << 8) | LF_VERSION_BUGFIX)
73 
75 #define LF_MIN_DATABASE_VERSION 0
77 #define LF_MAX_DATABASE_VERSION 2
78 
79 #if defined CONF_LENSFUN_STATIC
81 # define LF_EXPORT
82 #else
83 # ifdef CONF_SYMBOL_VISIBILITY
84 # if defined PLATFORM_WINDOWS
85 # define LF_EXPORT __declspec(dllexport)
86 # elif defined CONF_COMPILER_GCC || __clang__
87 # define LF_EXPORT __attribute__((visibility("default")))
88 # else
89 # error "I don't know how to change symbol visibility for your compiler"
90 # endif
91 # else
92 # if defined PLATFORM_WINDOWS || defined _MSC_VER
93 # define LF_EXPORT __declspec(dllimport)
94 # else
95 # define LF_EXPORT
96 # endif
97 # endif
98 #endif
99 
100 #ifndef CONF_LENSFUN_INTERNAL
102 # ifdef __GNUC__
103 # define DEPRECATED __attribute__((deprecated))
104 # elif defined(_MSC_VER)
105 # define DEPRECATED __declspec(deprecated)
106 # else
107 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
108 # define DEPRECATED
109 # endif
110 #else
111 # define DEPRECATED
112 #endif
113 
115 #define cbool int
116 
125 typedef char *lfMLstr;
126 
129 {
136 };
137 
138 C_TYPEDEF (enum, lfError)
139 
140 
141 typedef unsigned char lf_u8;
143 typedef unsigned short lf_u16;
145 typedef unsigned int lf_u32;
147 typedef float lf_f32;
149 typedef double lf_f64;
150 
159 LF_EXPORT void lf_free (void *data);
160 
169 LF_EXPORT const char *lf_mlstr_get (const lfMLstr str);
170 
187 LF_EXPORT lfMLstr lf_mlstr_add (lfMLstr str, const char *lang, const char *trstr);
188 
198 
201 /*----------------------------------------------------------------------------*/
202 
219 {
228 
229 #ifdef __cplusplus
234 
238  lfMount (const lfMount &other);
239 
243  lfMount &operator = (const lfMount &other);
244 
248  bool operator == (const lfMount& other);
249 
254 
265  void SetName (const char *val, const char *lang = NULL);
266 
272  void AddCompat (const char *val);
273 
277  const char* const* GetCompats () const;
278 
284  bool Check ();
285 
286 private:
287  std::vector<char*> MountCompat;
288 #endif
289 };
290 
291 C_TYPEDEF (struct, lfMount)
292 
293 
301 
312 
322 LF_EXPORT void lf_mount_copy (lfMount *dest, const lfMount *source);
323 
326 
328 LF_EXPORT void lf_mount_add_compat (lfMount *mount, const char *val);
329 
331 LF_EXPORT const char* const* lf_mount_get_compats (lfMount *mount);
332 
335 /*----------------------------------------------------------------------------*/
336 
355 {
363  char *Mount;
365  float CropFactor;
367  int Score;
368 
369 #ifdef __cplusplus
374 
378  lfCamera (const lfCamera &other);
379 
384 
388  lfCamera &operator = (const lfCamera &other);
389 
400  void SetMaker (const char *val, const char *lang = NULL);
401 
412  void SetModel (const char *val, const char *lang = NULL);
413 
424  void SetVariant (const char *val, const char *lang = NULL);
425 
431  void SetMount (const char *val);
432 
438  bool Check ();
439 #endif
440 };
441 
442 C_TYPEDEF (struct, lfCamera)
443 
444 
453 
464 
474 LF_EXPORT void lf_camera_copy (lfCamera *dest, const lfCamera *source);
475 
478 
481 /*----------------------------------------------------------------------------*/
482 
497 {
499  float CropFactor;
501  float AspectRatio;
502 
503  #ifdef __cplusplus
504  bool operator==(const lfLensCalibAttributes& other)
505  {
506  return CropFactor == other.CropFactor &&
507  AspectRatio == other.AspectRatio;
508  }
509  #endif
510 };
511 
513 
514 
528 {
573 };
574 
576 
577 
584 {
586  enum lfDistortionModel Model;
589  float Focal;
619  float RealFocal;
624  float Terms [5];
627 };
628 
630 
631 
645 {
700 };
701 
702 C_TYPEDEF (enum, lfTCAModel)
703 
704 
712 {
714  enum lfTCAModel Model;
716  float Focal;
718  float Terms [12];
721 };
722 
723 C_TYPEDEF (struct, lfLensCalibTCA)
724 
725 
742 {
766 };
767 
769 
770 
778 {
780  enum lfVignettingModel Model;
782  float Focal;
784  float Aperture;
786  float Distance;
788  float Terms [3];
791 };
792 
794 
795 
799 {
806 };
807 
808 C_TYPEDEF(enum, lfCropMode)
809 
810 
814 {
816  float Focal;
818  enum lfCropMode CropMode;
827  float Crop [4];
830 };
831 
832 C_TYPEDEF (struct, lfLensCalibCrop)
833 
834 
842 {
844  float Focal;
854  float FieldOfView;
857 };
858 
859 C_TYPEDEF (struct, lfLensCalibFov)
860 
861 
869 {
872 
873 #ifdef __cplusplus
874  lfLensCalibrationSet(lfLensCalibAttributes attributes) : Attributes(attributes) {}
875 
877  {
878  Attributes = other.Attributes;
879  for (auto *cb : other.CalibDistortion)
880  CalibDistortion.push_back(new lfLensCalibDistortion(*cb));
881  for (auto *cb : other.CalibVignetting)
882  CalibVignetting.push_back(new lfLensCalibVignetting(*cb));
883  for (auto *cb : other.CalibTCA)
884  CalibTCA.push_back(new lfLensCalibTCA(*cb));
885  for (auto *cb : other.CalibCrop)
886  CalibCrop.push_back(new lfLensCalibCrop(*cb));
887  for (auto *cb : other.CalibFov)
888  CalibFov.push_back(new lfLensCalibFov(*cb));
889  }
890 
892  {
893  for (auto cb : CalibDistortion)
894  delete cb;
895  for (auto cb : CalibVignetting)
896  delete cb;
897  for (auto cb : CalibTCA)
898  delete cb;
899  for (auto cb : CalibCrop)
900  delete cb;
901  for (auto cb : CalibFov)
902  delete cb;
903  }
904 
905  bool Empty() const
906  {
907  return CalibDistortion.empty() && CalibTCA.empty() && CalibVignetting.empty() &&
908  CalibCrop.empty() && CalibFov.empty();
909  }
910 
911  bool HasDistortion() const { return !CalibDistortion.empty(); }
912  bool HasTCA() const { return !CalibTCA.empty(); }
913  bool HasVignetting() const { return !CalibVignetting.empty(); }
914  bool HasCrop() const { return !CalibCrop.empty(); }
915  bool HasFov() const { return !CalibFov.empty(); }
916 
917  private:
918 
920  std::vector<lfLensCalibDistortion*> CalibDistortion;
922  std::vector<lfLensCalibTCA*> CalibTCA;
924  std::vector<lfLensCalibVignetting*> CalibVignetting;
926  std::vector<lfLensCalibCrop*> CalibCrop;
928  std::vector<lfLensCalibFov*> CalibFov;
929 
930  friend struct lfDatabase;
931  friend struct lfLens;
932 #endif
933 };
934 
935 
940 {
942  const char *Name;
944  float Min;
946  float Max;
948  float Default;
949 };
950 
951 C_TYPEDEF (struct, lfParameter)
952 
953 
957 {
997 };
998 
999 C_TYPEDEF (enum, lfLensType)
1000 
1001 
1011 {
1017  float MinFocal;
1019  float MaxFocal;
1037  float CenterX;
1039  float CenterY;
1055  int Score;
1056 
1057 #ifdef __cplusplus
1058 
1063 
1067  lfLens (const lfLens &other);
1068 
1073 
1077  lfLens &operator = (const lfLens &other);
1078 
1089  void SetMaker (const char *val, const char *lang = NULL);
1090 
1101  void SetModel (const char *val, const char *lang = NULL);
1102 
1110  void AddMount (const char *val);
1111 
1121 
1131  void AddCalibTCA (const lfLensCalibTCA *lctca);
1132 
1142 
1151  void AddCalibCrop (const lfLensCalibCrop *lcc);
1152 
1165 
1171 
1181 
1187  bool Check ();
1188 
1204  static const char *GetDistortionModelDesc (
1205  lfDistortionModel model, const char **details, const lfParameter ***params);
1221  static const char *GetTCAModelDesc (
1222  lfTCAModel model, const char **details, const lfParameter ***params);
1223 
1239  static const char *GetVignettingModelDesc (
1240  lfVignettingModel model, const char **details, const lfParameter ***params);
1241 
1257  static const char *GetCropDesc (
1258  lfCropMode mode, const char **details, const lfParameter ***params);
1259 
1271  static const char *GetLensTypeDesc (lfLensType type, const char **details);
1272 
1286  bool InterpolateDistortion (float crop, float focal, lfLensCalibDistortion &res) const;
1287 
1300  bool InterpolateTCA (float crop, float focal, lfLensCalibTCA &res) const;
1301 
1321  float crop, float focal, float aperture, float distance, lfLensCalibVignetting &res) const;
1322 
1335  bool InterpolateCrop (float crop, float focal, lfLensCalibCrop &res) const;
1336 
1355  int AvailableModifications(float crop) const;
1356 
1364 
1371  const char* const* GetMountNames() const;
1372 
1373  private:
1374  void UpdateLegacyCalibPointers();
1375 
1376  std::vector<lfLensCalibrationSet*> Calibrations;
1377  std::vector<char*> MountNames;
1378 
1379  lfLensCalibrationSet* GetClosestCalibrationSet(const float crop) const;
1380  lfLensCalibrationSet* GetCalibrationSetForAttributes(const lfLensCalibAttributes lcattr);
1381 
1382  friend struct lfDatabase;
1383 #endif
1384 };
1385 
1386 C_TYPEDEF (struct, lfLens)
1387 
1388 
1397 
1408 
1418 LF_EXPORT void lf_lens_copy (lfLens *dest, const lfLens *source);
1419 
1422 
1425 
1427 LF_EXPORT void lf_lens_add_mount (lfLens *lens, const char *val);
1428 
1430 LF_EXPORT const char* const* lf_lens_get_mount_names (const lfLens *lens);
1431 
1434  enum lfDistortionModel model, const char **details, const lfParameter ***params);
1435 
1438  enum lfTCAModel model, const char **details, const lfParameter ***params);
1439 
1442  enum lfVignettingModel model, const char **details, const lfParameter ***params);
1443 
1446  enum lfCropMode mode, const char **details, const lfParameter ***params);
1447 
1450  enum lfLensType type, const char **details);
1451 
1453 LF_EXPORT cbool lf_lens_interpolate_distortion (const lfLens *lens, float crop, float focal,
1454  lfLensCalibDistortion *res);
1455 
1457 LF_EXPORT cbool lf_lens_interpolate_tca (const lfLens *lens, float crop, float focal, lfLensCalibTCA *res);
1458 
1460 LF_EXPORT cbool lf_lens_interpolate_vignetting (const lfLens *lens, float crop, float focal, float aperture,
1461  float distance, lfLensCalibVignetting *res);
1462 
1464 LF_EXPORT cbool lf_lens_interpolate_crop (const lfLens *lens, float crop, float focal,
1465  lfLensCalibCrop *res);
1466 
1469 
1472 
1475 
1478 
1481 
1484 
1487 /*----------------------------------------------------------------------------*/
1488 
1498 enum
1499 {
1520 };
1521 
1536 {
1541 
1542 #ifdef __cplusplus
1543 
1545  static const char *const UserLocation;
1548  static const char *const UserUpdatesLocation;
1550  static const char *const SystemLocation;
1553  static const char *const SystemUpdatesLocation;
1554 
1559 
1573  static long int ReadTimestamp (const char *dirname);
1574 
1584 
1598  lfError Load (const char *pathname);
1599 
1610  lfError Load (const char *xml, size_t data_size);
1611 
1619  lfError Save (const char *filename) const;
1620 
1631  lfError Save (char*& xml, size_t& data_size) const;
1632 
1657  const lfCamera **FindCameras (const char *maker, const char *model) const;
1658 
1679  const lfCamera **FindCamerasExt (const char *maker, const char *model,
1680  int sflags = 0) const;
1681 
1689  const lfCamera *const *GetCameras ();
1690 
1728  const lfLens **FindLenses (const lfCamera *camera, const char *maker,
1729  const char *model, int sflags = 0) const;
1730 
1738  const lfLens *const *GetLenses ();
1739 
1747  const lfMount *FindMount (const char *mount) const;
1748 
1756  const char *MountName (const char *mount) const;
1757 
1765  const lfMount *const *GetMounts ();
1766 
1775  void AddMount (lfMount *mount);
1776 
1785  void AddCamera (lfCamera *camera);
1786 
1795  void AddLens (lfLens *lens);
1796 
1797 private:
1798 
1825  int MatchScore (const lfLens *pattern, const lfLens *match, const lfCamera *camera,
1826  void *fuzzycmp, const char* const* compat_mounts) const;
1827 
1828  lfError Load (const char *errcontext, const char *data, size_t data_size);
1829 
1830  std::vector<lfMount*> Mounts;
1831  std::vector<lfCamera*> Cameras;
1832  std::vector<lfLens*> Lenses;
1833 #endif
1834 };
1835 
1836 C_TYPEDEF (struct, lfDatabase)
1837 
1838 
1839 extern const char* const lf_db_system_location;
1841 extern const char* const lf_db_system_updates_location;
1843 extern const char* const lf_db_user_location;
1845 extern const char* const lf_db_user_updates_location;
1846 
1858 
1869 
1871 LF_EXPORT long int lf_db_read_timestamp (const char *dirname);
1872 
1875 
1877 LF_EXPORT lfError lf_db_load_path (lfDatabase *db, const char *pathname);
1878 
1880 LF_EXPORT lfError lf_db_load_str (lfDatabase *db, const char *xml, size_t data_size);
1881 
1883 LF_EXPORT lfError lf_db_save_all (const lfDatabase *db, const char *filename);
1884 
1886 LF_EXPORT lfError lf_db_save_str (const lfDatabase *db, char **xml, size_t* data_size);
1887 
1890  const lfDatabase *db, const char *maker, const char *model);
1891 
1894  const lfDatabase *db, const char *maker, const char *model, int sflags);
1895 
1898 
1901  const lfDatabase *db, const lfCamera *camera,
1902  const char *maker, const char *lens, int sflags);
1903 
1906 
1908 LF_EXPORT const lfMount *lf_db_find_mount (const lfDatabase *db, const char *mount);
1909 
1911 LF_EXPORT const char *lf_db_mount_name (const lfDatabase *db, const char *mount);
1912 
1915 
1918 /*----------------------------------------------------------------------------*/
1919 
1928 enum
1929 {
1931  LF_MODIFY_TCA = 0x00000001,
1933  LF_MODIFY_VIGNETTING = 0x00000002,
1934  /* Value 0x00000004 is deprecated. */
1936  LF_MODIFY_DISTORTION = 0x00000008,
1938  LF_MODIFY_GEOMETRY = 0x00000010,
1940  LF_MODIFY_SCALE = 0x00000020,
1944  LF_MODIFY_ALL = ~0
1945 };
1946 
1949 {
1959  LF_PF_F64
1960 };
1961 
1962 C_TYPEDEF (enum, lfPixelFormat)
1963 
1964 
1968 {
1990  LF_CR_BLUE
1991 };
1992 
1993 C_TYPEDEF (enum, lfComponentRole)
1994 
1995 
1996 #define LF_CR_1(a) (LF_CR_ ## a)
1998 #define LF_CR_2(a,b) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4))
2000 #define LF_CR_3(a,b,c) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2001  ((LF_CR_ ## c) << 8))
2003 #define LF_CR_4(a,b,c,d) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2004  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12))
2006 #define LF_CR_5(a,b,c,d,e) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2007  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
2008  ((LF_CR_ ## e) << 16))
2010 #define LF_CR_6(a,b,c,d,e,f) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2011  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
2012  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20))
2014 #define LF_CR_7(a,b,c,d,e,f,g) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2015  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
2016  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
2017  ((LF_CR_ ## g) << 24))
2019 #define LF_CR_8(a,b,c,d,e,f,g,h) ((LF_CR_ ## a) | ((LF_CR_ ## b) << 4) | \
2020  ((LF_CR_ ## c) << 8) | ((LF_CR_ ## d) << 12) | \
2021  ((LF_CR_ ## e) << 16) | ((LF_CR_ ## f) << 20) | \
2022  ((LF_CR_ ## g) << 24) | ((LF_CR_ ## h) << 28))
2023 
2024 // @cond
2025 
2026 
2027 
2028 // @endcond
2029 
2104 #ifdef __cplusplus
2105 }
2106 #endif
2107 
2109 {
2110 #ifdef __cplusplus
2138  lfModifier (const lfLens *lens, float imgfocal, float imgcrop, int imgwidth, int imgheight, lfPixelFormat pixel_format, bool reverse = false);
2139 
2142 
2163 
2184 
2208  int EnableVignettingCorrection (float aperture, float distance);
2209 
2222  int EnableProjectionTransform (lfLensType target_projection);
2223 
2232  int EnableScaling (float scale);
2233 
2288  int EnablePerspectiveCorrection (float *x, float *y, int count, float d);
2289 
2293  int GetModFlags ();
2294 
2308  float GetAutoScale (bool reverse);
2309 
2339  bool ApplyColorModification (void *pixels, float x, float y, int width, int height,
2340  int comp_role, int row_stride) const;
2341 
2372  bool ApplyGeometryDistortion (float xu, float yu, int width, int height,
2373  float *res) const;
2374 
2406  bool ApplySubpixelDistortion (float xu, float yu, int width, int height,
2407  float *res) const;
2408 
2439  bool ApplySubpixelGeometryDistortion (float xu, float yu, int width, int height,
2440  float *res) const;
2441 
2442 private:
2443 
2445  struct lfCallbackData
2446  {
2447  virtual ~lfCallbackData() {}
2448  int priority;
2449 
2450  bool operator<(const lfCallbackData& c) const { return priority < c.priority; }
2451  bool operator>(const lfCallbackData& c) const { return priority > c.priority; }
2452  };
2453 
2456  struct lfCallBackDataPtrComp
2457  {
2458  bool operator () (const lfCallbackData* lhs, const lfCallbackData* rhs) const {
2459  return lhs->priority < rhs->priority;
2460  }
2461  };
2462 
2478  typedef void (*lfModifySubpixCoordFunc) (void *data, float *iocoord, int count);
2479 
2504  typedef void (*lfModifyColorFunc) (void *data, float x, float y,
2505  void *pixels, int comp_role, int count);
2506 
2519  typedef void (*lfModifyCoordFunc) (void *data, float *iocoord, int count);
2520 
2522  struct lfSubpixelCallback : public lfCallbackData
2523  {
2524  lfModifySubpixCoordFunc callback;
2525  };
2526 
2527  struct lfSubpixTCACallback : public lfSubpixelCallback
2528  {
2529  float terms [12];
2530  };
2531 
2533  struct lfCoordCallback : public lfCallbackData
2534  {
2535  lfModifyCoordFunc callback;
2536  };
2537 
2538  struct lfCoordDistCallbackData : public lfCoordCallback
2539  {
2540  float terms [5];
2541  };
2542 
2543  struct lfCoordScaleCallbackData : public lfCoordCallback
2544  {
2545  float scale_factor;
2546  };
2547 
2548  struct lfCoordGeomCallbackData : public lfCoordCallback
2549  {
2550  };
2551 
2552  struct lfCoordPerspCallbackData : public lfCoordCallback
2553  {
2554  float A [3][3];
2555  float delta_a, delta_b;
2556  };
2557 
2559  struct lfColorCallback : public lfCallbackData
2560  {
2561  lfModifyColorFunc callback;
2562  };
2563 
2564  struct lfColorVignCallbackData : public lfColorCallback
2565  {
2566  float norm_scale;
2567  float terms [3];
2568  };
2569 
2571  std::multiset<lfSubpixelCallback*, lfCallBackDataPtrComp> SubpixelCallbacks;
2573  std::multiset<lfColorCallback*, lfCallBackDataPtrComp> ColorCallbacks;
2575  std::multiset<lfCoordCallback*, lfCallBackDataPtrComp> CoordCallbacks;
2576 
2577  // A test point in the autoscale algorithm
2578  typedef struct { float angle, dist; } lfPoint;
2579 
2580  void AddSubpixTCACallback (const lfLensCalibTCA& lcd, lfModifySubpixCoordFunc func, int priority);
2581  void AddCoordGeomCallback (lfModifyCoordFunc func, int priority);
2582  void AddCoordDistCallback (const lfLensCalibDistortion& lcd, lfModifyCoordFunc func, int priority);
2583  void AddColorVignCallback (const lfLensCalibVignetting& lcv, lfModifyColorFunc func, int priority);
2584 
2598  double AutoscaleResidualDistance (float *coord) const;
2613  float GetTransformedDistance (lfPoint point) const;
2614 
2615  static void ModifyCoord_TCA_Linear (void *data, float *iocoord, int count);
2616  static void ModifyCoord_UnTCA_Poly3 (void *data, float *iocoord, int count);
2617  static void ModifyCoord_TCA_Poly3 (void *data, float *iocoord, int count);
2618  static void ModifyCoord_TCA_ACM (void *data, float *iocoord, int count);
2619 
2620  static void ModifyCoord_UnDist_Poly3 (void *data, float *iocoord, int count);
2621  static void ModifyCoord_Dist_Poly3 (void *data, float *iocoord, int count);
2622 #ifdef VECTORIZATION_SSE
2623  static void ModifyCoord_Dist_Poly3_SSE (void *data, float *iocoord, int count);
2624 #endif
2625  static void ModifyCoord_UnDist_Poly5 (void *data, float *iocoord, int count);
2626  static void ModifyCoord_Dist_Poly5 (void *data, float *iocoord, int count);
2627  static void ModifyCoord_UnDist_PTLens (void *data, float *iocoord, int count);
2628  static void ModifyCoord_Dist_PTLens (void *data, float *iocoord, int count);
2629 #ifdef VECTORIZATION_SSE
2630  static void ModifyCoord_UnDist_PTLens_SSE (void *data, float *iocoord, int count);
2631  static void ModifyCoord_Dist_PTLens_SSE (void *data, float *iocoord, int count);
2632 #endif
2633  static void ModifyCoord_Dist_ACM (void *data, float *iocoord, int count);
2634  static void ModifyCoord_Geom_FishEye_Rect (void *data, float *iocoord, int count);
2635  static void ModifyCoord_Geom_Panoramic_Rect (void *data, float *iocoord, int count);
2636  static void ModifyCoord_Geom_ERect_Rect (void *data, float *iocoord, int count);
2637  static void ModifyCoord_Geom_Rect_FishEye (void *data, float *iocoord, int count);
2638  static void ModifyCoord_Geom_Panoramic_FishEye (void *data, float *iocoord, int count);
2639  static void ModifyCoord_Geom_ERect_FishEye (void *data, float *iocoord, int count);
2640  static void ModifyCoord_Geom_Rect_Panoramic (void *data, float *iocoord, int count);
2641  static void ModifyCoord_Geom_FishEye_Panoramic (void *data, float *iocoord, int count);
2642  static void ModifyCoord_Geom_ERect_Panoramic (void *data, float *iocoord, int count);
2643  static void ModifyCoord_Geom_Rect_ERect (void *data, float *iocoord, int count);
2644  static void ModifyCoord_Geom_FishEye_ERect (void *data, float *iocoord, int count);
2645  static void ModifyCoord_Geom_Panoramic_ERect (void *data, float *iocoord, int count);
2646  static void ModifyCoord_Geom_Orthographic_ERect (void *data, float *iocoord, int count);
2647  static void ModifyCoord_Geom_ERect_Orthographic (void *data, float *iocoord, int count);
2648  static void ModifyCoord_Geom_Stereographic_ERect (void *data, float *iocoord, int count);
2649  static void ModifyCoord_Geom_ERect_Stereographic (void *data, float *iocoord, int count);
2650  static void ModifyCoord_Geom_Equisolid_ERect (void *data, float *iocoord, int count);
2651  static void ModifyCoord_Geom_ERect_Equisolid (void *data, float *iocoord, int count);
2652  static void ModifyCoord_Geom_Thoby_ERect (void *data, float *iocoord, int count);
2653  static void ModifyCoord_Geom_ERect_Thoby (void *data, float *iocoord, int count);
2654  static void ModifyCoord_Perspective_Correction (void *data, float *iocoord, int count);
2655  static void ModifyCoord_Perspective_Distortion (void *data, float *iocoord, int count);
2656 #ifdef VECTORIZATION_SSE
2657  static void ModifyColor_DeVignetting_PA_SSE (
2658  void *data, float _x, float _y, lf_f32 *pixels, int comp_role, int count);
2659 #endif
2660 #ifdef VECTORIZATION_SSE2
2661  static void ModifyColor_DeVignetting_PA_SSE2 (
2662  void *data, float _x, float _y, lf_u16 *pixels, int comp_role, int count);
2663 #endif
2664 
2665  template<typename T> static void ModifyColor_Vignetting_PA (
2666  void *data, float x, float y, T *rgb, int comp_role, int count);
2667  template<typename T> static void ModifyColor_DeVignetting_PA (
2668  void *data, float x, float y, T *rgb, int comp_role, int count);
2669 
2670  static void ModifyCoord_Scale (void *data, float *iocoord, int count);
2671 #endif
2674  double Width, Height;
2676  double Crop;
2678  double Focal;
2681  double RealFocal;
2683  double CenterX, CenterY;
2685  double NormScale, NormUnScale;
2686 
2688  cbool Reverse;
2689 
2691  lfPixelFormat PixelFormat;
2692 
2693  const lfLens* Lens;
2694 
2696  int EnabledMods;
2697 };
2698 
2699 #ifdef __cplusplus
2700 extern "C" {
2701 #endif
2702 
2703 C_TYPEDEF (struct, lfModifier)
2704 
2705 
2707  const lfLens* lens, float imgfocal, float imgcrop, int imgwidth, int imgheight, lfPixelFormat pixel_format, bool reverse);
2708 
2711 
2713 LF_EXPORT int lf_modifier_enable_scaling (lfModifier *modifier, float scale);
2714 
2717 
2720 
2723  lfModifier *modifier, float aperture, float distance);
2724 
2727  lfModifier *modifier, lfLensType target_projection);
2728 
2731  lfModifier *modifier, float *x, float *y, int count, float d);
2732 
2735 
2738  lfModifier *modifier, cbool reverse);
2739 
2742  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2743 
2746  lfModifier *modifier, void *pixels, float x, float y, int width, int height,
2747  int comp_role, int row_stride);
2748 
2751  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2752 
2755  lfModifier *modifier, float xu, float yu, int width, int height, float *res);
2756 
2759 #undef cbool
2760 
2761 #ifdef __cplusplus
2762 }
2763 #endif
2764 
2765 #endif /* __LENSFUN_H__ */
lfMLstr lf_mlstr_dup(const lfMLstr str)
Create a complete copy of a multi-language string.
unsigned char lf_u8
Definition: lensfun.h:141
char * lfMLstr
Definition: lensfun.h:125
void lf_free(void *data)
unsigned short lf_u16
Definition: lensfun.h:143
const char * lf_mlstr_get(const lfMLstr str)
Get a string corresponding to current locale from a multi-language string.
#define LF_EXPORT
This macro expands to an appropriate symbol visibility declaration.
Definition: lensfun.h:81
double lf_f64
Definition: lensfun.h:149
#define DEPRECATED
For marking deprecated functions, see http://stackoverflow.com/a/21265197.
Definition: lensfun.h:108
unsigned int lf_u32
Definition: lensfun.h:145
float lf_f32
Definition: lensfun.h:147
#define cbool
C-compatible bool type; don't bother to define Yet Another Boolean Type.
Definition: lensfun.h:115
lfMLstr lf_mlstr_add(lfMLstr str, const char *lang, const char *trstr)
Add a new translated string to a multi-language string.
lfError
Definition: lensfun.h:129
@ LF_NO_ERROR
Definition: lensfun.h:131
@ LF_NO_DATABASE
Definition: lensfun.h:135
@ LF_WRONG_FORMAT
Definition: lensfun.h:133
void lf_camera_copy(lfCamera *dest, const lfCamera *source)
Copy the data from one lfCamera structure into another.
cbool lf_camera_check(lfCamera *camera)
lfCamera * lf_camera_create()
Create a new camera object.
void lf_camera_destroy(lfCamera *camera)
Destroy a lfCamera object.
lfModifier * lf_modifier_create(const lfLens *lens, float imgfocal, float imgcrop, int imgwidth, int imgheight, lfPixelFormat pixel_format, bool reverse)
cbool lf_modifier_apply_subpixel_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
void lf_modifier_destroy(lfModifier *modifier)
cbool lf_modifier_apply_color_modification(lfModifier *modifier, void *pixels, float x, float y, int width, int height, int comp_role, int row_stride)
int lf_modifier_enable_tca_correction(lfModifier *modifier)
int lf_modifier_enable_vignetting_correction(lfModifier *modifier, float aperture, float distance)
cbool lf_modifier_enable_projection_transform(lfModifier *modifier, lfLensType target_projection)
float lf_modifier_get_auto_scale(lfModifier *modifier, cbool reverse)
int lf_modifier_enable_perspective_correction(lfModifier *modifier, float *x, float *y, int count, float d)
cbool lf_modifier_apply_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
cbool lf_modifier_apply_subpixel_geometry_distortion(lfModifier *modifier, float xu, float yu, int width, int height, float *res)
int lf_modifier_enable_distortion_correction(lfModifier *modifier)
int lf_modifier_enable_scaling(lfModifier *modifier, float scale)
int lf_modifier_get_mod_flags(lfModifier *modifier)
lfComponentRole
These constants define the role of every pixel component, four bits each. "pixel" refers here to a se...
Definition: lensfun.h:1968
lfPixelFormat
A list of pixel formats supported by internal colour callbacks.
Definition: lensfun.h:1949
@ LF_MODIFY_TCA
Definition: lensfun.h:1931
@ LF_MODIFY_VIGNETTING
Definition: lensfun.h:1933
@ LF_MODIFY_GEOMETRY
Definition: lensfun.h:1938
@ LF_MODIFY_DISTORTION
Definition: lensfun.h:1936
@ LF_MODIFY_PERSPECTIVE
Definition: lensfun.h:1942
@ LF_MODIFY_SCALE
Definition: lensfun.h:1940
@ LF_MODIFY_ALL
Definition: lensfun.h:1944
@ LF_CR_NEXT
Definition: lensfun.h:1980
@ LF_CR_END
Definition: lensfun.h:1973
@ LF_CR_INTENSITY
Definition: lensfun.h:1984
@ LF_CR_RED
Definition: lensfun.h:1986
@ LF_CR_UNKNOWN
Definition: lensfun.h:1982
@ LF_CR_GREEN
Definition: lensfun.h:1988
@ LF_CR_BLUE
Definition: lensfun.h:1990
@ LF_PF_U16
Definition: lensfun.h:1953
@ LF_PF_F64
Definition: lensfun.h:1959
@ LF_PF_U8
Definition: lensfun.h:1951
@ LF_PF_U32
Definition: lensfun.h:1955
@ LF_PF_F32
Definition: lensfun.h:1957
const lfCamera ** lf_db_find_cameras(const lfDatabase *db, const char *maker, const char *model)
lfError lf_db_save_str(const lfDatabase *db, char **xml, size_t *data_size)
lfError lf_db_load_path(lfDatabase *db, const char *pathname)
const char *const lf_db_system_updates_location
const lfLens *const * lf_db_get_lenses(lfDatabase *db)
lfError lf_db_load(lfDatabase *db)
const lfCamera *const * lf_db_get_cameras(lfDatabase *db)
lfError lf_db_save_all(const lfDatabase *db, const char *filename)
lfDatabase * lf_db_create(void)
Create a new empty database object.
lfError lf_db_load_str(lfDatabase *db, const char *xml, size_t data_size)
long int lf_db_read_timestamp(const char *dirname)
const lfMount *const * lf_db_get_mounts(lfDatabase *db)
const lfLens ** lf_db_find_lenses(const lfDatabase *db, const lfCamera *camera, const char *maker, const char *lens, int sflags)
const char * lf_db_mount_name(const lfDatabase *db, const char *mount)
const lfMount * lf_db_find_mount(const lfDatabase *db, const char *mount)
const char *const lf_db_user_location
const char *const lf_db_system_location
const lfCamera ** lf_db_find_cameras_ext(const lfDatabase *db, const char *maker, const char *model, int sflags)
const char *const lf_db_user_updates_location
void lf_db_destroy(lfDatabase *db)
Destroy the database object.
@ LF_SEARCH_LOOSE
This flag selects a looser search algorithm resulting in more results (still sorted by score).
Definition: lensfun.h:1507
@ LF_SEARCH_SORT_AND_UNIQUIFY
This flag makes Lensfun to sort the results by focal length, and remove all double lens names.
Definition: lensfun.h:1519
lfLens * lf_lens_create()
Create a new lens object.
void lf_lens_add_calib_crop(lfLens *lens, const lfLensCalibCrop *cc)
lfTCAModel
The Lensfun library supports several models for lens lateral chromatic aberrations (also called trans...
Definition: lensfun.h:645
void lf_lens_add_calib_vignetting(lfLens *lens, const lfLensCalibVignetting *vc)
cbool lf_lens_check(lfLens *lens)
void lf_lens_add_calib_distortion(lfLens *lens, const lfLensCalibDistortion *dc)
void lf_lens_destroy(lfLens *lens)
Destroy a lfLens object.
cbool lf_lens_interpolate_crop(const lfLens *lens, float crop, float focal, lfLensCalibCrop *res)
cbool lf_lens_interpolate_distortion(const lfLens *lens, float crop, float focal, lfLensCalibDistortion *res)
lfVignettingModel
The Lensfun library supports several models for lens vignetting correction.
Definition: lensfun.h:742
void lf_lens_add_mount(lfLens *lens, const char *val)
const char * lf_get_crop_desc(enum lfCropMode mode, const char **details, const lfParameter ***params)
void lf_lens_guess_parameters(lfLens *lens)
const char * lf_get_lens_type_desc(enum lfLensType type, const char **details)
lfCropMode
Different crop modes.
Definition: lensfun.h:799
cbool lf_lens_interpolate_tca(const lfLens *lens, float crop, float focal, lfLensCalibTCA *res)
const char * lf_get_tca_model_desc(enum lfTCAModel model, const char **details, const lfParameter ***params)
lfDistortionModel
The Lensfun library implements several lens distortion models. This enum lists them.
Definition: lensfun.h:528
void lf_lens_remove_calibrations(lfLens *lens)
const char *const * lf_lens_get_mount_names(const lfLens *lens)
void lf_lens_copy(lfLens *dest, const lfLens *source)
Copy the data from one lfLens structure into another.
lfLensType
Lens type. See Change of projection for further information.
Definition: lensfun.h:957
const char * lf_get_vignetting_model_desc(enum lfVignettingModel model, const char **details, const lfParameter ***params)
void lf_lens_add_calib_tca(lfLens *lens, const lfLensCalibTCA *tcac)
int lf_lens_available_modifications(lfLens *lens, float crop)
const char * lf_get_distortion_model_desc(enum lfDistortionModel model, const char **details, const lfParameter ***params)
cbool lf_lens_interpolate_vignetting(const lfLens *lens, float crop, float focal, float aperture, float distance, lfLensCalibVignetting *res)
@ LF_TCA_MODEL_NONE
No TCA correction data is known.
Definition: lensfun.h:647
@ LF_TCA_MODEL_LINEAR
Linear lateral chromatic aberrations model.
Definition: lensfun.h:659
@ LF_TCA_MODEL_POLY3
Third order polynomial.
Definition: lensfun.h:671
@ LF_TCA_MODEL_ACM
Adobe camera model for TCA. The coordinate system is different here. Everything is measured in units ...
Definition: lensfun.h:699
@ LF_VIGNETTING_MODEL_PA
Pablo D'Angelo vignetting model (which is a more general variant of the law).
Definition: lensfun.h:754
@ LF_VIGNETTING_MODEL_ACM
Adobe's vignetting model. It differs from D'Angelo's model only in the coordinate system....
Definition: lensfun.h:765
@ LF_VIGNETTING_MODEL_NONE
No vignetting correction data is known.
Definition: lensfun.h:744
@ LF_CROP_RECTANGLE
use a rectangular crop
Definition: lensfun.h:803
@ LF_CROP_CIRCLE
use a circular crop, e.g. for circular fisheye images
Definition: lensfun.h:805
@ LF_NO_CROP
no crop at all
Definition: lensfun.h:801
@ LF_DIST_MODEL_POLY5
5th order polynomial model.
Definition: lensfun.h:547
@ LF_DIST_MODEL_NONE
Distortion parameters are unknown.
Definition: lensfun.h:530
@ LF_DIST_MODEL_ACM
Adobe Camera Model. The coordinate system is different here. Everything is measured in units of the f...
Definition: lensfun.h:572
@ LF_DIST_MODEL_PTLENS
PTLens model, which is also used by Hugin.
Definition: lensfun.h:555
@ LF_DIST_MODEL_POLY3
3rd order polynomial model, which is a subset of the PTLens model.
Definition: lensfun.h:538
@ LF_FISHEYE
Equidistant fisheye.
Definition: lensfun.h:970
@ LF_FISHEYE_EQUISOLID
Equisolid fisheye.
Definition: lensfun.h:990
@ LF_FISHEYE_THOBY
Fisheye as measured by Thoby (for Nikkor 10.5).
Definition: lensfun.h:996
@ LF_UNKNOWN
Unknown lens type.
Definition: lensfun.h:959
@ LF_FISHEYE_ORTHOGRAPHIC
Orthographic fisheye.
Definition: lensfun.h:986
@ LF_EQUIRECTANGULAR
Equirectangular.
Definition: lensfun.h:984
@ LF_RECTILINEAR
Rectilinear lens.
Definition: lensfun.h:964
@ LF_FISHEYE_STEREOGRAPHIC
Stereographic fisheye.
Definition: lensfun.h:988
@ LF_PANORAMIC
Panoramic (cylindrical)
Definition: lensfun.h:977
lfMount * lf_mount_create()
Create a new mount object.
void lf_mount_destroy(lfMount *mount)
Destroy a lfMount object.
void lf_mount_add_compat(lfMount *mount, const char *val)
void lf_mount_copy(lfMount *dest, const lfMount *source)
Copy the data from one lfMount structure into another.
cbool lf_mount_check(lfMount *mount)
const char *const * lf_mount_get_compats(lfMount *mount)
#define C_TYPEDEF(t, c)
Definition: lensfun.h:45
Camera data. Unknown fields are set to NULL.
Definition: lensfun.h:355
lfMLstr Model
Model name (ex: "Rolleiflex SL35") – same as in EXIF.
Definition: lensfun.h:359
lfMLstr Variant
Camera variant. Some cameras use same EXIF id for different models.
Definition: lensfun.h:361
~lfCamera()
Destroy a camera object. All allocated fields are freed.
int Score
Camera matching score, used while searching: not actually a camera parameter.
Definition: lensfun.h:367
bool Check()
Check if a camera object is valid.
lfMLstr Maker
Camera maker (ex: "Rollei") – same as in EXIF.
Definition: lensfun.h:357
void SetVariant(const char *val, const char *lang=NULL)
Add a string to camera variant.
lfCamera(const lfCamera &other)
lfCamera()
Initialize a new camera object. All fields are set to 0.
void SetMaker(const char *val, const char *lang=NULL)
Add a string to camera maker.
char * Mount
Camera mount type (ex: "QBM")
Definition: lensfun.h:363
void SetMount(const char *val)
Set the value for camera Mount.
void SetModel(const char *val, const char *lang=NULL)
Add a string to camera model.
float CropFactor
Camera crop factor (ex: 1.0). Must be defined.
Definition: lensfun.h:365
A lens database object.
Definition: lensfun.h:1536
~lfDatabase()
Database object destructor.
lfError Save(const char *filename) const
Save the whole database to a file.
const lfMount * FindMount(const char *mount) const
Return the lfMount structure given the (basic) mount name.
void AddMount(lfMount *mount)
Add a mount to the database.
const lfCamera ** FindCameras(const char *maker, const char *model) const
Find a set of cameras that fit given criteria.
static const char *const SystemLocation
System lens database directory (something like "/usr/share/lensfun")
Definition: lensfun.h:1550
const lfLens ** FindLenses(const lfCamera *camera, const char *maker, const char *model, int sflags=0) const
Parse a human-friendly lens description (ex: "smc PENTAX-F 35-105mm F4-5.6" or "SIGMA AF 28-300 F3....
lfError Save(char *&xml, size_t &data_size) const
Save the database into a XML char string. The memory of the received char string has to be released w...
DEPRECATED char * UserUpdatesDir
Home lens database directory for automatic updates (deprecated). Replaced by lfDatabase::UserUpdatesL...
Definition: lensfun.h:1540
lfDatabase()
Database object constructor.
static long int ReadTimestamp(const char *dirname)
Scans for the timestamp of a Lensfun database.
static const char *const UserLocation
Home lens database directory (something like "~/.local/share/lensfun")
Definition: lensfun.h:1545
static const char *const UserUpdatesLocation
Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates")
Definition: lensfun.h:1548
DEPRECATED char * HomeDataDir
Home lens database directory (deprecated). Replaced by lfDatabase::UserLocation.
Definition: lensfun.h:1538
void AddCamera(lfCamera *camera)
Add a camera to the database.
const char * MountName(const char *mount) const
Get the name of a mount in current locale.
const lfCamera *const * GetCameras()
Retrieve a full list of cameras.
const lfLens *const * GetLenses()
Retrieve a full list of lenses.
const lfCamera ** FindCamerasExt(const char *maker, const char *model, int sflags=0) const
Searches all translations of camera maker and model.
void AddLens(lfLens *lens)
Add a lens to the database.
lfError Load()
Find and load the lens database.
static const char *const SystemUpdatesLocation
System lens database directory for automatic updates (something like "/var/lib/lensfun-updates")
Definition: lensfun.h:1553
const lfMount *const * GetMounts()
Retrieve a full list of mounts.
lfError Load(const char *xml, size_t data_size)
Load a database from a XML char string.
lfError Load(const char *pathname)
Load the database from specific path (directory or file).
Lens calibration attributes.
Definition: lensfun.h:497
float AspectRatio
Definition: lensfun.h:501
float CropFactor
Definition: lensfun.h:499
Struct to save image crop, which can depend on the focal length.
Definition: lensfun.h:814
lfLensCalibAttributes CalibAttr
Pointer to the calibration settings (currently unused).
Definition: lensfun.h:829
Lens distortion calibration data.
Definition: lensfun.h:584
float Focal
Nominal focal length in mm at which this calibration data was taken.
Definition: lensfun.h:589
lfLensCalibAttributes CalibAttr
Calibration settings (currently unused).
Definition: lensfun.h:626
cbool RealFocalMeasured
Whether the real focal length was actually measured.
Definition: lensfun.h:622
float RealFocal
Real focal length in mm for this nominal focal length.
Definition: lensfun.h:619
Struct to save calibrated field of view, which can depends on the focal length (DEPRECATED)
Definition: lensfun.h:842
float FieldOfView
Field of view for given images.
Definition: lensfun.h:854
float Focal
Definition: lensfun.h:844
lfLensCalibAttributes CalibAttr
Pointer to the calibration settings (currently unused).
Definition: lensfun.h:856
Laterlal chromatic aberrations calibration data.
Definition: lensfun.h:712
lfLensCalibAttributes CalibAttr
Pointer to the calibration settings (currently unused).
Definition: lensfun.h:720
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:716
Lens vignetting calibration data.
Definition: lensfun.h:778
lfLensCalibAttributes CalibAttr
Pointer to the calibration settings (currently unused).
Definition: lensfun.h:790
float Distance
Focus distance in meters.
Definition: lensfun.h:786
float Aperture
Aperture (f-number) at which this calibration data was taken.
Definition: lensfun.h:784
float Focal
Focal length in mm at which this calibration data was taken.
Definition: lensfun.h:782
A set of calibration data.
Definition: lensfun.h:869
lfLensCalibAttributes Attributes
Definition: lensfun.h:871
Lens data. Unknown fields are set to NULL or 0.
Definition: lensfun.h:1011
DEPRECATED lfLensCalibVignetting ** CalibVignetting
Definition: lensfun.h:1049
static const char * GetVignettingModelDesc(lfVignettingModel model, const char **details, const lfParameter ***params)
Get the human-readable vignetting model name and the descriptions of the parameters required by this ...
const lfLensCalibrationSet *const * GetCalibrationSets() const
Get a list of all calibration sets.
lfMLstr Model
Definition: lensfun.h:1015
void GuessParameters()
This method fills some fields if they are missing but can be derived from other fields.
bool Check()
Check if a lens object is valid.
void AddMount(const char *val)
Add a new mount type to this lens.
DEPRECATED lfLensCalibDistortion ** CalibDistortion
Definition: lensfun.h:1045
DEPRECATED float AspectRatio
Definition: lensfun.h:1043
int Score
Definition: lensfun.h:1055
lfMLstr Maker
Definition: lensfun.h:1013
void AddCalibDistortion(const lfLensCalibDistortion *lcd)
Add a new distortion calibration structure to the pool.
float CenterY
Definition: lensfun.h:1039
lfLens(const lfLens &other)
bool InterpolateDistortion(float crop, float focal, lfLensCalibDistortion &res) const
Interpolate lens geometry distortion data for given focal length and crop factor.
void RemoveCalibrations()
Remove all calibrations from the lens.
bool InterpolateVignetting(float crop, float focal, float aperture, float distance, lfLensCalibVignetting &res) const
Interpolate lens vignetting model parameters for given focal length, aperture, and focus distance.
DEPRECATED float CropFactor
Definition: lensfun.h:1041
bool InterpolateTCA(float crop, float focal, lfLensCalibTCA &res) const
Interpolate lens TCA calibration data for given focal length.
void SetModel(const char *val, const char *lang=NULL)
Add a string to camera model.
void AddCalibCrop(const lfLensCalibCrop *lcc)
Add a new lens crop structure to the pool.
void SetMaker(const char *val, const char *lang=NULL)
Add a string to camera maker.
DEPRECATED char ** Mounts
Definition: lensfun.h:1025
float MinFocal
Definition: lensfun.h:1017
lfLens()
Create a new lens object, initializing all fields to default values.
float MaxFocal
Definition: lensfun.h:1019
static const char * GetCropDesc(lfCropMode mode, const char **details, const lfParameter ***params)
Get the human-readable crop name and the descriptions of the parameters required by this model.
void AddCalibVignetting(const lfLensCalibVignetting *lcv)
Add a new vignetting calibration structure to the pool.
bool InterpolateCrop(float crop, float focal, lfLensCalibCrop &res) const
Interpolate lens crop data for given focal length.
float MinAperture
Definition: lensfun.h:1021
static const char * GetDistortionModelDesc(lfDistortionModel model, const char **details, const lfParameter ***params)
Get the human-readable distortion model name and the descriptions of the parameters required by this ...
DEPRECATED lfLensCalibTCA ** CalibTCA
Definition: lensfun.h:1047
int AvailableModifications(float crop) const
Get a flag with the available modifications for this lens considering the image crop factor.
DEPRECATED lfLensCalibFov ** CalibFov
Definition: lensfun.h:1053
float MaxAperture
Definition: lensfun.h:1023
float CenterX
Definition: lensfun.h:1037
void AddCalibTCA(const lfLensCalibTCA *lctca)
Add a new transversal chromatic aberration calibration structure to the pool.
DEPRECATED void AddCalibFov(const lfLensCalibFov *lcf)
Add a new lens fov structure to the pool.
const char *const * GetMountNames() const
Get a list of all mount names.
~lfLens()
Destroy this and all associated objects.
DEPRECATED lfLensCalibCrop ** CalibCrop
Definition: lensfun.h:1051
lfLensType Type
Definition: lensfun.h:1027
static const char * GetLensTypeDesc(lfLensType type, const char **details)
Get the human-readable lens type name and a short description of this lens type.
static const char * GetTCAModelDesc(lfTCAModel model, const char **details, const lfParameter ***params)
Get the human-readable transversal chromatic aberrations model name and the descriptions of the param...
A modifier object contains optimized data required to rectify a image.
Definition: lensfun.h:2109
int EnableTCACorrection()
Enable TCA correction.
int EnableScaling(float scale)
Enable image scaling.
int EnableVignettingCorrection(const lfLensCalibVignetting &lcv)
Enable vignetting correction.
int EnableDistortionCorrection()
Enable distortion correction.
bool ApplySubpixelGeometryDistortion(float xu, float yu, int width, int height, float *res) const
Apply stage 2 & 3 in one step.
bool ApplyColorModification(void *pixels, float x, float y, int width, int height, int comp_role, int row_stride) const
Image correction step 1: fix image colors.
bool ApplyGeometryDistortion(float xu, float yu, int width, int height, float *res) const
Image correction step 2: apply the transforms on a block of pixel coordinates.
~lfModifier()
Modifier object destructor.
int EnableDistortionCorrection(const lfLensCalibDistortion &lcd)
Enable distortion correction.
int EnableProjectionTransform(lfLensType target_projection)
Enable projection transform.
int EnableVignettingCorrection(float aperture, float distance)
Enable vignetting correction.
int GetModFlags()
Return the current set of LF_MODIFY_XXX flags.
bool ApplySubpixelDistortion(float xu, float yu, int width, int height, float *res) const
Image correction step 3: apply subpixel distortions.
lfModifier(const lfLens *lens, float imgfocal, float imgcrop, int imgwidth, int imgheight, lfPixelFormat pixel_format, bool reverse=false)
Create an empty image modifier object.
int EnableTCACorrection(const lfLensCalibTCA &lctca)
Enable TCA correction.
float GetAutoScale(bool reverse)
Compute the automatic scale factor for the image.
int EnablePerspectiveCorrection(float *x, float *y, int count, float d)
Enable the perspective correction.
This structure contains everything specific to a camera mount.
Definition: lensfun.h:219
void AddCompat(const char *val)
Add a mount name to the list of compatible mounts.
bool Check()
Check if a mount object is valid.
lfMount()
Initialize a new mount object. All fields are set to 0.
DEPRECATED char ** Compat
Definition: lensfun.h:227
const char *const * GetCompats() const
Return a list of compatible mounts.
lfMount(const lfMount &other)
lfMLstr Name
Camera mount name.
Definition: lensfun.h:225
void SetName(const char *val, const char *lang=NULL)
Add a string to mount name.
~lfMount()
Destroy a mount object. All allocated fields are freed.
This structure describes a single parameter for some lens model.
Definition: lensfun.h:940
const char * Name
Parameter name (something like 'k', 'k3', 'omega' etc.)
Definition: lensfun.h:942
float Max
Maximal value that has sense.
Definition: lensfun.h:946
float Min
Minimal value that has sense.
Definition: lensfun.h:944
float Default
Default value for the parameter.
Definition: lensfun.h:948