HuginBase::LensDB::LensDB Class Reference

main wrapper class for lensfun database More...

#include <LensDB.h>

List of all members.

Public Member Functions

 LensDB ()
 constructor
virtual ~LensDB ()
 destructor
void SetMainDBPath (std::string mainPath)
 sets the main path of the database files, if not set the default location is used
std::string GetMainDBPath ()
 return the path where the database is read
std::string GetUserDBPath ()
 returns the path to the user specific part of the database
void ReloadUserPart ()
 reloads the user part of the lensfun db
bool GetCropFactor (std::string maker, std::string model, double &cropFactor)
 returns the crop factor for the given camera (maker/model)
bool GetCameraMount (std::string maker, std::string model, std::string &mount)
 returns the mount of the given camera (maker/model)
bool FindLens (std::string camMaker, std::string camModel, std::string lens)
 searches for the given lens and store it parameters inside
void SetActiveLens (const lfLens *activeLens)
 sets the active lens for the following Check* call
bool CheckLensFocal (double focal)
 checks if the focal length matches the lens spec
bool CheckLensAperture (double aperture)
 checks if the aperture matches the lens spec
bool FindLenses (std::string camMaker, std::string camModel, std::string lensname, LensDBList &foundLenses, bool fuzzy=false)
 searches for the given lens and gives back a list of matching lenses
bool GetMounts (std::vector< std::string > &foundMounts)
 searches for all mounts in the database
bool GetProjection (BaseSrcPanoImage::Projection &projection)
 returns the projection of the last found lens (you need to call LensDB::FindLens before calling this procedure)
bool GetCrop (double focal, BaseSrcPanoImage::CropMode &cropMode, hugin_utils::FDiff2D &cropLeftTop, hugin_utils::FDiff2D &cropRightBottom)
 returns the crop of the last found lens (you need to call LensDB::FindLens before calling this procedure)
bool GetFov (double focal, double &fov)
 returns the field of view of the last found lens (you need to call LensDB::FindLens before calling this procedure)
bool GetDistortion (double focal, std::vector< double > &distortion)
 returns the distortion parameters of the last found lens (you need to call LensDB::FindLens before calling this procedure)
bool GetVignetting (double focal, double aperture, double distance, std::vector< double > &vignetting)
 returns the vignetting parameters of the last found lens (you need to call LensDB::FindLens before calling this procedure)
bool SaveCameraCrop (std::string filename, std::string maker, std::string model, std::string mount, double cropfactor)
 save the camera with the given cropfactor into the given file
int BeginSaveLens (std::string filename, std::string maker, std::string lensname, std::string mount, BaseSrcPanoImage::Projection projection, double cropfactor)
 starts saving a lens to database, call LensDB::SaveHFOV, LensDB::SaveCrop, LensDB::SaveDistortion and/or LensDB::SaveVignetting to add information to database, finally save information to file with LensDB::EndSaveLens
void SaveHFOV (double focal, double hfov)
 updated the hfov for the given focal length
void SaveCrop (double focal, BaseSrcPanoImage::CropMode cropMode, hugin_utils::FDiff2D cropLeftTop, hugin_utils::FDiff2D cropRightBottom)
 updated the crop for the given focal length
void SaveDistortion (double focal, std::vector< double > distortion)
 updated the distortion for the given focal length
void SaveVignetting (double focal, double aperture, double distance, std::vector< double > vignetting)
 updated the vignetting for the given focal length
bool EndSaveLens ()
 finally saves the new information to file, see also LensDB::BeginSaveLens

Static Public Member Functions

LensDBGetSingleton ()
 returns the static LensDB instance
void Clean ()
 cleanup the static LensDB instance, must be called at the end of the program

Private Member Functions

bool InitDB ()
 initialize db
bool LoadFilesInDir (std::string path)
 load all xml files in given path into database
void CleanSaveInformation ()
 free all ressources used for saving lens
bool IsNewMount (std::string newMount)
 check, if mount is already in database, if not it populates the LensDB::m_updatedMounts with the mounts
void FreeLensList ()
 deletes the lens list
void CleanUpdatedMounts ()
 cleans up the information stored for mounts (variable LensDB::m_updatedMounts)

Private Attributes

lfDatabase * m_db
 the main database
lfDatabase * m_newDB
 database for saving
const struct lfLens ** m_lenses
 found lenses for LensDB::GetProjection, LensDB::GetCrop
bool m_needLensCleanup
 variable used for cleanup of lensfun points
lfLens ** m_updatedLenses
 list of lenses for saving
lfMount ** m_updatedMounts
 list of new mounts for saving
lfLens * m_currentLens
 struct of lens currently is saved
std::string m_lensFilename
 current filename for saving lens
bool m_initialized
 true, if database was successful initialized
std::string m_main_db_path
std::string m_user_db_path

Static Private Attributes

LensDBm_instance = NULL


Detailed Description

main wrapper class for lensfun database

Definition at line 63 of file LensDB.h.


Constructor & Destructor Documentation

HuginBase::LensDB::LensDB::LensDB  ) 
 

constructor

Definition at line 49 of file LensDB.cpp.

References m_currentLens, m_db, m_initialized, m_lenses, m_needLensCleanup, m_newDB, m_updatedLenses, m_updatedMounts, m_user_db_path, and makefile::string.

Referenced by GetSingleton().

HuginBase::LensDB::LensDB::~LensDB  )  [virtual]
 

destructor

Definition at line 69 of file LensDB.cpp.

References CleanSaveInformation(), FreeLensList(), and m_db.


Member Function Documentation

int HuginBase::LensDB::LensDB::BeginSaveLens std::string  filename,
std::string  maker,
std::string  lensname,
std::string  mount,
BaseSrcPanoImage::Projection  projection,
double  cropfactor
 

starts saving a lens to database, call LensDB::SaveHFOV, LensDB::SaveCrop, LensDB::SaveDistortion and/or LensDB::SaveVignetting to add information to database, finally save information to file with LensDB::EndSaveLens

Parameters:
filename filename to which the information should be saved
maker maker of the lens
lensname lens name
mount mount of the lens (if empty string "Generic" is written to database )
projection projection of the lens
cropfactor crop factor of the lens
Returns:
0 - if all okay, 1 - if database could not created, 2 - if projection does not match type saved in database, 3 - if crop factor does not match crop factor in database

Definition at line 806 of file LensDB.cpp.

References HuginBase::LensDB::basic_path, CleanSaveInformation(), IsNewMount(), m_currentLens, m_lensFilename, m_newDB, m_updatedLenses, HuginBase::LensDB::TranslateProjectionHugin2LF(), and HuginBase::LensDB::TranslateProjectionLF2Hugin().

Referenced by SaveLensParameters().

bool HuginBase::LensDB::LensDB::CheckLensAperture double  aperture  ) 
 

checks if the aperture matches the lens spec

Returns:
true, if aperture is inside spec

Definition at line 319 of file LensDB.cpp.

References m_lenses.

bool HuginBase::LensDB::LensDB::CheckLensFocal double  focal  ) 
 

checks if the focal length matches the lens spec

Returns:
true, if focal length is inside spec

Definition at line 310 of file LensDB.cpp.

References m_lenses.

void HuginBase::LensDB::LensDB::Clean  )  [static]
 

cleanup the static LensDB instance, must be called at the end of the program

Definition at line 104 of file LensDB.cpp.

References m_instance.

Referenced by main(), PTBatcherGUI::OnExit(), huginApp::~huginApp(), and LensCalFrame::~LensCalFrame().

void HuginBase::LensDB::LensDB::CleanSaveInformation  )  [private]
 

free all ressources used for saving lens

Definition at line 1158 of file LensDB.cpp.

References CleanUpdatedMounts(), m_newDB, and m_updatedLenses.

Referenced by BeginSaveLens(), EndSaveLens(), SaveCameraCrop(), and ~LensDB().

void HuginBase::LensDB::LensDB::CleanUpdatedMounts  )  [private]
 

cleans up the information stored for mounts (variable LensDB::m_updatedMounts)

Definition at line 1222 of file LensDB.cpp.

References m_updatedMounts.

Referenced by CleanSaveInformation(), and IsNewMount().

bool HuginBase::LensDB::LensDB::EndSaveLens  ) 
 

finally saves the new information to file, see also LensDB::BeginSaveLens

Definition at line 1128 of file LensDB.cpp.

References CleanSaveInformation(), m_currentLens, m_lensFilename, m_newDB, and m_updatedMounts.

Referenced by SaveLensParameters().

bool HuginBase::LensDB::LensDB::FindLens std::string  camMaker,
std::string  camModel,
std::string  lens
 

searches for the given lens and store it parameters inside

Parameters:
camMaker maker of the camera, for fixed lens cameras
camModel model of the camera, for fixed lens cameras
lens lens for searching
Returns:
true, if a lens was found

Definition at line 244 of file LensDB.cpp.

References FindLenses(), FreeLensList(), InitDB(), m_db, m_lenses, m_needLensCleanup, and hugin_utils::tolower().

bool HuginBase::LensDB::LensDB::FindLenses std::string  camMaker,
std::string  camModel,
std::string  lensname,
LensDBList foundLenses,
bool  fuzzy = false
 

searches for the given lens and gives back a list of matching lenses

Parameters:
camMaker maker of the camera, for fixed lens cameras
camModel model of the camera, for fixed lens cameras
lensname lensname to search
foundLenses contains found lenses names
fuzzy set to true, if search should use fuzzy algorithm
Returns:
true, if lenses were found

Definition at line 336 of file LensDB.cpp.

References HuginBase::LensDB::LensDBList::GetLensCount(), InitDB(), m_db, HuginBase::LensDB::LensDBList::SetCameraModelMaker(), HuginBase::LensDB::LensDBList::SetLenses(), and hugin_utils::tolower().

Referenced by FindLens().

void HuginBase::LensDB::LensDB::FreeLensList  )  [private]
 

deletes the lens list

Definition at line 79 of file LensDB.cpp.

References m_lenses.

Referenced by FindLens(), SetActiveLens(), and ~LensDB().

bool HuginBase::LensDB::LensDB::GetCameraMount std::string  maker,
std::string  model,
std::string mount
 

returns the mount of the given camera (maker/model)

Parameters:
maker maker of the desired camera
model camera model
mount contains the mount
Returns:
true, if the mount could be obtained from the database, otherwise false

Definition at line 229 of file LensDB.cpp.

References InitDB(), m_db, and makefile::string.

Referenced by SaveCameraCropFactor(), and SaveLensParameters().

bool HuginBase::LensDB::LensDB::GetCrop double  focal,
BaseSrcPanoImage::CropMode cropMode,
hugin_utils::FDiff2D cropLeftTop,
hugin_utils::FDiff2D cropRightBottom
 

returns the crop of the last found lens (you need to call LensDB::FindLens before calling this procedure)

Parameters:
focal focal length, for which the crop should be returned
cropMode contains the crop mode of the lens
cropLeftTop contains the left top border edge of the crop
cropRightBottom contains the right bottom edge of the crop
Returns:
true, if the database has stored information about the lens crop

Definition at line 545 of file LensDB.cpp.

References hugin_utils::FDiff2D, m_lenses, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

Referenced by ApplyLensDBParameters().

bool HuginBase::LensDB::LensDB::GetCropFactor std::string  maker,
std::string  model,
double &  cropFactor
 

returns the crop factor for the given camera (maker/model)

Parameters:
maker maker of the desired camera
model camera model
cropFactor contains the crop factor
Returns:
true, if the crop factor could be obtained from the database, otherwise false

Definition at line 214 of file LensDB.cpp.

References InitDB(), and m_db.

bool HuginBase::LensDB::LensDB::GetDistortion double  focal,
std::vector< double > &  distortion
 

returns the distortion parameters of the last found lens (you need to call LensDB::FindLens before calling this procedure)

Parameters:
focal focal length, for which the distortion parameters should be returned
distortion stored the returned distortion parameters
Returns:
true, if the database has stored information about the distortion

Definition at line 602 of file LensDB.cpp.

References m_lenses.

Referenced by ApplyLensDBParameters().

bool HuginBase::LensDB::LensDB::GetFov double  focal,
double &  fov
 

returns the field of view of the last found lens (you need to call LensDB::FindLens before calling this procedure)

Parameters:
focal focal length, for which the fov should be returned
fov stored the returned field of view
Returns:
true, if the database has stored information about the field of view

Definition at line 585 of file LensDB.cpp.

References m_lenses.

Referenced by ApplyLensDBParameters().

std::string HuginBase::LensDB::LensDB::GetMainDBPath  ) 
 

return the path where the database is read

Definition at line 118 of file LensDB.cpp.

Referenced by AboutDialog::GetSystemInformation().

bool HuginBase::LensDB::LensDB::GetMounts std::vector< std::string > &  foundMounts  ) 
 

searches for all mounts in the database

Returns:
true, if mounts were found

Definition at line 388 of file LensDB.cpp.

References InitDB(), and m_db.

bool HuginBase::LensDB::LensDB::GetProjection BaseSrcPanoImage::Projection projection  ) 
 

returns the projection of the last found lens (you need to call LensDB::FindLens before calling this procedure)

Parameters:
projection contains the projection of the lens
Returns:
true, if the database has stored information about the lens projection

Definition at line 536 of file LensDB.cpp.

References m_lenses, and HuginBase::LensDB::TranslateProjectionLF2Hugin().

Referenced by ApplyLensDBParameters().

LensDB & HuginBase::LensDB::LensDB::GetSingleton  )  [static]
 

returns the static LensDB instance

Definition at line 95 of file LensDB.cpp.

References LensDB(), and m_instance.

Referenced by LoadLensDBDialog::ActivateSelectedLens(), ApplyLensDBParameters(), EVT_LIST_ITEM_ACTIVATED(), AboutDialog::GetSystemInformation(), InitLensDB(), huginApp::OnInit(), LensCalApp::OnInit(), LoadLensDBDialog::OnSearch(), SaveCameraCropFactor(), and SaveLensParameters().

std::string HuginBase::LensDB::LensDB::GetUserDBPath  ) 
 

returns the path to the user specific part of the database

Definition at line 123 of file LensDB.cpp.

Referenced by AboutDialog::GetSystemInformation(), SaveCameraCropFactor(), and SaveLensParameters().

bool HuginBase::LensDB::LensDB::GetVignetting double  focal,
double  aperture,
double  distance,
std::vector< double > &  vignetting
 

returns the vignetting parameters of the last found lens (you need to call LensDB::FindLens before calling this procedure)

Parameters:
focal focal length, for which the vignetting parameters should be returned
aperture aperture, for which the vignetting parameters should be returned
distance distance, for which the vignetting parameters should be returned
vignetting stored the returned vignetting
Returns:
true, if the database has stored information about the vignetting

Definition at line 642 of file LensDB.cpp.

References vigra_ext::distance(), and m_lenses.

Referenced by ApplyLensDBParameters().

bool HuginBase::LensDB::LensDB::InitDB  )  [private]
 

initialize db

Definition at line 128 of file LensDB.cpp.

References LoadFilesInDir(), m_db, m_initialized, m_main_db_path, and m_user_db_path.

Referenced by FindLens(), FindLenses(), GetCameraMount(), GetCropFactor(), GetMounts(), and ReloadUserPart().

bool HuginBase::LensDB::LensDB::IsNewMount std::string  newMount  )  [private]
 

check, if mount is already in database, if not it populates the LensDB::m_updatedMounts with the mounts

Returns:
true, if new mount is found

Definition at line 1177 of file LensDB.cpp.

References CleanUpdatedMounts(), m_db, m_newDB, and m_updatedMounts.

Referenced by BeginSaveLens(), and SaveCameraCrop().

bool HuginBase::LensDB::LensDB::LoadFilesInDir std::string  path  )  [private]
 

load all xml files in given path into database

Definition at line 161 of file LensDB.cpp.

References HuginBase::LensDB::basic_path, GETPATHSTRING, m_db, makefile::path, and makefile::string.

Referenced by InitDB(), and ReloadUserPart().

void HuginBase::LensDB::LensDB::ReloadUserPart  ) 
 

reloads the user part of the lensfun db

Definition at line 198 of file LensDB.cpp.

References InitDB(), LoadFilesInDir(), m_db, and m_user_db_path.

Referenced by SaveLensParameters().

bool HuginBase::LensDB::LensDB::SaveCameraCrop std::string  filename,
std::string  maker,
std::string  model,
std::string  mount,
double  cropfactor
 

save the camera with the given cropfactor into the given file

Parameters:
filename in which file the db should be saved, existing entries will be
maker camera maker to save
model camera model to save
mount mount of the used camera model
cropfactor crop factor for given camera
Returns:
true, if saving was successful

Definition at line 678 of file LensDB.cpp.

References HuginBase::LensDB::basic_path, CleanSaveInformation(), IsNewMount(), and m_newDB.

Referenced by SaveCameraCropFactor(), and SaveLensParameters().

void HuginBase::LensDB::LensDB::SaveCrop double  focal,
BaseSrcPanoImage::CropMode  cropMode,
hugin_utils::FDiff2D  cropLeftTop,
hugin_utils::FDiff2D  cropRightBottom
 

updated the crop for the given focal length

Parameters:
focal focal length
hfov horizontal field of view to save

Definition at line 992 of file LensDB.cpp.

References hugin_utils::FDiff2D, m_currentLens, hugin_utils::TDiff2D< T >::x, and hugin_utils::TDiff2D< T >::y.

Referenced by SaveLensParameters().

void HuginBase::LensDB::LensDB::SaveDistortion double  focal,
std::vector< double >  distortion
 

updated the distortion for the given focal length

Parameters:
focal focal length
distortion distortion to save, vector must have 3 elements

Definition at line 1054 of file LensDB.cpp.

References m_currentLens.

Referenced by SaveLensParameters().

void HuginBase::LensDB::LensDB::SaveHFOV double  focal,
double  hfov
 

updated the hfov for the given focal length

Parameters:
focal focal length
hfov horizontal field of view to save

Definition at line 963 of file LensDB.cpp.

References m_currentLens.

Referenced by SaveLensParameters().

void HuginBase::LensDB::LensDB::SaveVignetting double  focal,
double  aperture,
double  distance,
std::vector< double >  vignetting
 

updated the vignetting for the given focal length

Parameters:
focal focal length, for which vignetting was determined
aperture aperture, for which vignetting was determined
distance distance for which vignetting was determined
vignetting vignetting to save, vector must have 3 elements

Definition at line 1089 of file LensDB.cpp.

References vigra_ext::distance(), and m_currentLens.

Referenced by SaveLensParameters().

void HuginBase::LensDB::LensDB::SetActiveLens const lfLens *  activeLens  ) 
 

sets the active lens for the following Check* call

Definition at line 302 of file LensDB.cpp.

References FreeLensList(), m_lenses, and m_needLensCleanup.

void HuginBase::LensDB::LensDB::SetMainDBPath std::string  mainPath  ) 
 

sets the main path of the database files, if not set the default location is used

Definition at line 113 of file LensDB.cpp.

References m_main_db_path.


Member Data Documentation

struct lfLens* HuginBase::LensDB::LensDB::m_currentLens [private]
 

struct of lens currently is saved

Definition at line 220 of file LensDB.h.

Referenced by BeginSaveLens(), EndSaveLens(), LensDB(), SaveCrop(), SaveDistortion(), SaveHFOV(), and SaveVignetting().

struct lfDatabase* HuginBase::LensDB::LensDB::m_db [private]
 

the main database

Definition at line 208 of file LensDB.h.

Referenced by FindLens(), FindLenses(), GetCameraMount(), GetCropFactor(), GetMounts(), InitDB(), IsNewMount(), LensDB(), LoadFilesInDir(), ReloadUserPart(), and ~LensDB().

bool HuginBase::LensDB::LensDB::m_initialized [private]
 

true, if database was successful initialized

Definition at line 224 of file LensDB.h.

Referenced by InitDB(), and LensDB().

LensDB * HuginBase::LensDB::LensDB::m_instance = NULL [static, private]
 

Definition at line 47 of file LensDB.cpp.

Referenced by Clean(), and GetSingleton().

const struct lfLens** HuginBase::LensDB::LensDB::m_lenses [private]
 

found lenses for LensDB::GetProjection, LensDB::GetCrop

Definition at line 212 of file LensDB.h.

Referenced by CheckLensAperture(), CheckLensFocal(), FindLens(), FreeLensList(), GetCrop(), GetDistortion(), GetFov(), GetProjection(), GetVignetting(), LensDB(), and SetActiveLens().

std::string HuginBase::LensDB::LensDB::m_lensFilename [private]
 

current filename for saving lens

Definition at line 222 of file LensDB.h.

Referenced by BeginSaveLens(), and EndSaveLens().

std::string HuginBase::LensDB::LensDB::m_main_db_path [private]
 

Definition at line 226 of file LensDB.h.

Referenced by InitDB(), and SetMainDBPath().

bool HuginBase::LensDB::LensDB::m_needLensCleanup [private]
 

variable used for cleanup of lensfun points

Definition at line 214 of file LensDB.h.

Referenced by FindLens(), LensDB(), and SetActiveLens().

struct lfDatabase* HuginBase::LensDB::LensDB::m_newDB [private]
 

database for saving

Definition at line 210 of file LensDB.h.

Referenced by BeginSaveLens(), CleanSaveInformation(), EndSaveLens(), IsNewMount(), LensDB(), and SaveCameraCrop().

struct lfLens** HuginBase::LensDB::LensDB::m_updatedLenses [private]
 

list of lenses for saving

Definition at line 216 of file LensDB.h.

Referenced by BeginSaveLens(), CleanSaveInformation(), and LensDB().

struct lfMount** HuginBase::LensDB::LensDB::m_updatedMounts [private]
 

list of new mounts for saving

Definition at line 218 of file LensDB.h.

Referenced by CleanUpdatedMounts(), EndSaveLens(), IsNewMount(), and LensDB().

std::string HuginBase::LensDB::LensDB::m_user_db_path [private]
 

Definition at line 227 of file LensDB.h.

Referenced by InitDB(), LensDB(), and ReloadUserPart().


The documentation for this class was generated from the following files:
Generated on Sat Apr 19 01:25:51 2014 for Hugintrunk by  doxygen 1.3.9.1