A lens database object.
More...
#include <lensfun.h>
|
| DEPRECATED void | Destroy () |
| | Destroy the database object and free all loaded data. More...
|
| |
| DEPRECATED bool | LoadDirectory (const char *dirname) |
| | Open and parse all XML files in a given directory. More...
|
| |
| lfError | Load () |
| | Find and load the lens database. More...
|
| |
| lfError | Load (const char *pathname) |
| | Load the database from specific path (directory or file). More...
|
| |
| lfError | Load (const char *errcontext, const char *data, size_t data_size) |
| | Load a set of camera/lenses from a memory array. More...
|
| |
| lfError | Save (const char *filename) const |
| | Save the whole database to a file. More...
|
| |
| lfError | Save (const char *filename, const lfMount *const *mounts, const lfCamera *const *cameras, const lfLens *const *lenses) const |
| | Save a set of camera and lens descriptions to a file. More...
|
| |
| const lfCamera ** | FindCameras (const char *maker, const char *model) const |
| | Find a set of cameras that fit given criteria. More...
|
| |
| const lfCamera ** | FindCamerasExt (const char *maker, const char *model, int sflags=0) const |
| | Searches all translations of camera maker and model. More...
|
| |
| const lfCamera *const * | GetCameras () const |
| | Retrieve a full list of cameras. More...
|
| |
| 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.5-5.6 DL IF") and return a list of lfLens'es which are matching this description. More...
|
| |
| const lfLens ** | FindLenses (const lfLens *lens, int sflags=0) const |
| | Find a set of lenses that fit certain criteria. More...
|
| |
| const lfLens *const * | GetLenses () const |
| | Retrieve a full list of lenses. More...
|
| |
| const lfMount * | FindMount (const char *mount) const |
| | Return the lfMount structure given the (basic) mount name. More...
|
| |
| const char * | MountName (const char *mount) const |
| | Get the name of a mount in current locale. More...
|
| |
| const lfMount *const * | GetMounts () const |
| | Retrieve a full list of mounts. More...
|
| |
| void | AddMount (lfMount *mount) |
| | Add a mount to the database. More...
|
| |
| void | AddCamera (lfCamera *camera) |
| | Add a camera to the database. More...
|
| |
| void | AddLens (lfLens *lens) |
| | Add a lens to the database. More...
|
| |
|
|
static const char *const | UserLocation |
| | Home lens database directory (something like "~/.local/share/lensfun")
|
| |
|
static const char *const | UserUpdatesLocation |
| | Home lens database directory for automatic updates (something like "~/.local/share/lensfun/updates")
|
| |
|
static const char *const | SystemLocation |
| | System lens database directory (something like "/usr/share/lensfun")
|
| |
|
static const char *const | SystemUpdatesLocation |
| | System lens database directory for automatic updates (something like "/var/lib/lensfun-updates")
|
| |
A lens database object.
This object contains a list of mounts, cameras and lenses through which you can search. The objects are loaded from XML files (see How database files are found and loaded).
Objects loaded later override objects loaded earlier. Thus, if user modifies a object you must save it to its home directory (see lfDatabase::UserLocation), where it will override any definitions from the system-wide database.
- Examples:
- example.c, lenstool.cpp, and tfun.cpp.
◆ AddCamera()
| void lfDatabase::AddCamera |
( |
lfCamera * |
camera | ) |
|
Add a camera to the database.
- Parameters
-
◆ AddLens()
| void lfDatabase::AddLens |
( |
lfLens * |
lens | ) |
|
Add a lens to the database.
- Parameters
-
◆ AddMount()
| void lfDatabase::AddMount |
( |
lfMount * |
mount | ) |
|
Add a mount to the database.
- Parameters
-
◆ Create()
Create a new empty database object.
This function is deprecated and will be removed in the future. Please use the standard constructor instead.
◆ Destroy()
Destroy the database object and free all loaded data.
This function is deprecated and will be removed in the future. Please use the standard destructor instead.
- Examples:
- tfun.cpp.
◆ FindCameras()
| const lfCamera** lfDatabase::FindCameras |
( |
const char * |
maker, |
|
|
const char * |
model |
|
) |
| const |
Find a set of cameras that fit given criteria.
The maker and model must be given (if possible) exactly as they are spelled in database, except that the library will compare case-insensitively and will compress spaces. This means that the database must contain camera maker/lens exactly how it is given in EXIF data, but you may add human-friendly translations of them using the multi-language string feature (including a translation to "en" to avoid displaying EXIF tags in user interface - they are often upper-case which looks ugly).
- Parameters
-
| maker | Camera maker (either from EXIF tags or from some other source). The string is expected to be pure ASCII, since EXIF data does not allow 8-bit data to be used. |
| model | Camera model (either from EXIF tags or from some other source). The string is expected to be pure ASCII, since EXIF data does not allow 8-bit data to be used. |
- Returns
- A NULL-terminated list of cameras matching the search criteria or NULL if none. Release return value with lf_free() (only the list of pointers, not the camera objects!).
◆ FindCamerasExt()
| const lfCamera** lfDatabase::FindCamerasExt |
( |
const char * |
maker, |
|
|
const char * |
model, |
|
|
int |
sflags = 0 |
|
) |
| const |
Searches all translations of camera maker and model.
Thus, you may search for a user-entered camera even in a language different from English. This function is somewhat similar to FindCameras(), but uses a different search algorithm.
This is a lot slower than FindCameras().
- Parameters
-
| maker | Camera maker. This can be any UTF-8 string. |
| model | Camera model. This can be any UTF-8 string. |
| sflags | Additional flags influencing the search algorithm. This is a combination of LF_SEARCH_XXX flags. |
- Returns
- A NULL-terminated list of cameras matching the search criteria or NULL if none. Release return value with lf_free() (only the list of pointers, not the camera objects!).
- Examples:
- lenstool.cpp.
◆ FindLenses() [1/2]
| const lfLens** lfDatabase::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.5-5.6 DL IF") and return a list of lfLens'es which are matching this description.
Multiple lenses may be returned if multiple lenses match (perhaps due to non-unique lens description provided, e.g. "Pentax SMC").
The matching algorithm works as follows: first the user description is tried to be interpreted according to several well-known lens naming schemes, so additional data like focal and aperture ranges are extracted if they are present. After that word matching is done; a lens matches the description ONLY IF it contains all the words found in the description (including buzzwords e.g. IF IZ AL LD DI USM SDM etc). Order of the words does not matter. An additional check is done on the focal/aperture ranges, they must exactly match if they are specified.
- Parameters
-
| camera | The camera (can be NULL if camera is unknown, or just certain fields in structure can be NULL). The algorithm will look for a lens with crop factor not larger than of given camera, since the mathematical models of the lens can be incorrect for sensor sizes larger than the one used for calibration. Also camera mount is taken into account, the lenses with incompatible mounts will be filtered out. |
| maker | Lens maker or NULL if not known. |
| model | A human description of the lens model(-s). |
| sflags | Additional flags influencing the search algorithm. This is a combination of LF_SEARCH_XXX flags. |
- Returns
- A list of lenses parsed from user description or NULL. Release memory with lf_free(). The list is ordered in the most-likely to least-likely order, e.g. the first returned value is the most likely match.
- Examples:
- lenstool.cpp, and tfun.cpp.
◆ FindLenses() [2/2]
| const lfLens** lfDatabase::FindLenses |
( |
const lfLens * |
lens, |
|
|
int |
sflags = 0 |
|
) |
| const |
Find a set of lenses that fit certain criteria.
- Parameters
-
| lens | The approximative lense. Uncertain fields may be NULL. The "CropFactor" field defines the minimal value for crop factor; no lenses with crop factor larger than that will be returned. The Mounts field will be scanned for allowed mounts, if NULL any mounts are considered compatible. |
| sflags | Additional flags influencing the search algorithm. This is a combination of LF_SEARCH_XXX flags. |
- Returns
- A NULL-terminated list of lenses matching the search criteria or NULL if none. Release memory with lf_free(). The list is ordered in the most-likely to least-likely order, e.g. the first returned value is the most likely match.
◆ FindMount()
| const lfMount* lfDatabase::FindMount |
( |
const char * |
mount | ) |
const |
Return the lfMount structure given the (basic) mount name.
- Parameters
-
| mount | The basic mount name. |
- Returns
- A pointer to lfMount structure or NULL.
◆ GetCameras()
| const lfCamera* const* lfDatabase::GetCameras |
( |
| ) |
const |
Retrieve a full list of cameras.
- Returns
- An NULL-terminated list containing all cameras loaded until now. The list is valid only until the lens database is modified. The returned pointer does not have to be freed.
◆ GetLenses()
| const lfLens* const* lfDatabase::GetLenses |
( |
| ) |
const |
Retrieve a full list of lenses.
- Returns
- An NULL-terminated list containing all lenses loaded until now. The list is valid only until the lens database is modified. The returned pointer does not have to be freed.
◆ GetMounts()
| const lfMount* const* lfDatabase::GetMounts |
( |
| ) |
const |
Retrieve a full list of mounts.
- Returns
- An array containing all mounts loaded until now. The list is valid only until the mount database is modified. The returned pointer does not have to be freed.
◆ Load() [1/3]
◆ Load() [2/3]
| lfError lfDatabase::Load |
( |
const char * |
pathname | ) |
|
Load the database from specific path (directory or file).
If the given path is a folder, all included XML files will be parsed for valid lens data. If a loaded file contains the specification of a camera/lens that's already in memory, it overrides that data.
- Parameters
-
| pathname | The name of a XML file to load. Note that Lensfun does not support the full XML specification as it uses the glib's simple XML parser, so advanced XML features are not available. |
- Returns
- LF_NO_ERROR or a error code.
◆ Load() [3/3]
| lfError lfDatabase::Load |
( |
const char * |
errcontext, |
|
|
const char * |
data, |
|
|
size_t |
data_size |
|
) |
| |
Load a set of camera/lenses from a memory array.
This is the lowest-level loading function.
- Parameters
-
| errcontext | The error context to be displayed in error messages (usually this is the name of the file to which data belongs). |
| data | The XML data. |
| data_size | XML data size in bytes. |
- Returns
- LF_NO_ERROR or a error code.
◆ LoadDirectory()
| DEPRECATED bool lfDatabase::LoadDirectory |
( |
const char * |
dirname | ) |
|
Open and parse all XML files in a given directory.
Returns true if valid Lensfun XML data was found and loaded sucessfully.
This function is deprecated and will be removed in the future. Please use the lfDatabase::Load(const char *pathname) syntax instead.
- Parameters
-
| dirname | The directory to be read. |
- Returns
- True if valid lensfun XML data was succesfully loaded.
◆ MountName()
| const char* lfDatabase::MountName |
( |
const char * |
mount | ) |
const |
Get the name of a mount in current locale.
- Parameters
-
| mount | The basic mount name. |
- Returns
- The name of the mount in current locale (UTF-8 string).
◆ ReadTimestamp()
| static long int lfDatabase::ReadTimestamp |
( |
const char * |
dirname | ) |
|
|
static |
Scans for the timestamp of a Lensfun database.
"database" means here a directory containing XML files. If it also contains a file timestamp.txt, its content is interpreted as a string-encoded floating point value, representing the timestamp in seconds since the Epoch (UNIX time). If it is not present, 0 is returned. If the directory is not found or empty, a negative value is returned.
- Parameters
-
| dirname | the name of the directory containing a Lensfun database |
- Returns
- the UNIX timestamp when database was last updated.
◆ Save() [1/3]
| lfError lfDatabase::Save |
( |
const char * |
filename | ) |
const |
Save the whole database to a file.
- Parameters
-
| filename | The file name to write the XML stream into. |
- Returns
- LF_NO_ERROR or a error code.
◆ Save() [2/3]
| lfError lfDatabase::Save |
( |
const char * |
filename, |
|
|
const lfMount *const * |
mounts, |
|
|
const lfCamera *const * |
cameras, |
|
|
const lfLens *const * |
lenses |
|
) |
| const |
Save a set of camera and lens descriptions to a file.
- Parameters
-
| filename | The file name to write the XML stream into. |
| mounts | A list of mounts to be written to the file. Can be NULL. |
| cameras | A list of cameras to be written to the file. Can be NULL. |
| lenses | A list of lenses to be written to the file. Can be NULL. |
- Returns
- LF_NO_ERROR or a error code.
◆ Save() [3/3]
| static char* lfDatabase::Save |
( |
const lfMount *const * |
mounts, |
|
|
const lfCamera *const * |
cameras, |
|
|
const lfLens *const * |
lenses |
|
) |
| |
|
static |
Save a set of camera and lens descriptions into a memory array.
- Parameters
-
| mounts | A list of mounts to be written to the file. Can be NULL. |
| cameras | A list of cameras to be written to the file. Can be NULL. |
| lenses | A list of lenses to be written to the file. Can be NULL. |
- Returns
- A pointer to an allocated string with the output. Free it with lf_free().
The documentation for this struct was generated from the following file: