00001
00002
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _LENS_DB_H
00027 #define _LENS_DB_H
00028
00029 #include <hugin_shared.h>
00030 #include <string>
00031 #ifndef Hugin_shared
00032 #define CONF_LENSFUN_STATIC
00033 #endif
00034 #include <lensfun.h>
00035 #include <panodata/SrcPanoImage.h>
00036 #include <hugin_math/hugin_math.h>
00037
00038 namespace HuginBase
00039 {
00040
00041 namespace LensDB
00042 {
00043
00045 class IMPEX LensDBList
00046 {
00047 public:
00048 LensDBList();
00049 ~LensDBList();
00050 const size_t GetLensCount() const;
00051 const lfLens* GetLens(size_t index) const;
00052 void SetLenses(const lfLens** lenses);
00053 std::string GetLensName(size_t index) const;
00054 void SetCameraModelMaker(const std::string camMaker, const std::string camModel);
00055 private:
00056 const lfLens** m_lenses;
00057 size_t m_lensCount;
00058 std::string m_camMaker;
00059 std::string m_camModel;
00060 };
00061
00063 class IMPEX LensDB
00064 {
00065 public:
00067 LensDB();
00069 virtual ~LensDB();
00070
00072 void SetMainDBPath(std::string mainPath);
00074 std::string GetMainDBPath();
00076 std::string GetUserDBPath();
00078 void ReloadUserPart();
00079
00080
00086 bool GetCropFactor(std::string maker, std::string model, double &cropFactor);
00092 bool GetCameraMount(std::string maker, std::string model, std::string &mount);
00098 bool FindLens(std::string camMaker, std::string camModel, std::string lens);
00100 void SetActiveLens(const lfLens* activeLens);
00103 bool CheckLensFocal(double focal);
00106 bool CheckLensAperture(double aperture);
00114 bool FindLenses(std::string camMaker, std::string camModel, std::string lensname, LensDBList &foundLenses, bool fuzzy=false);
00117 bool GetMounts(std::vector<std::string> &foundMounts);
00121 bool GetProjection(BaseSrcPanoImage::Projection & projection);
00128 bool GetCrop(double focal, BaseSrcPanoImage::CropMode &cropMode, hugin_utils::FDiff2D &cropLeftTop, hugin_utils::FDiff2D &cropRightBottom);
00133 bool GetFov(double focal,double &fov);
00138 bool GetDistortion(double focal, std::vector<double> &distortion);
00145 bool GetVignetting(double focal, double aperture, double distance, std::vector<double> &vignetting);
00146
00147
00155 bool SaveCameraCrop(std::string filename, std::string maker, std::string model, std::string mount, double cropfactor);
00156
00166 int BeginSaveLens(std::string filename, std::string maker, std::string lensname, std::string mount, BaseSrcPanoImage::Projection projection, double cropfactor);
00170 void SaveHFOV(double focal, double hfov);
00174 void SaveCrop(double focal, BaseSrcPanoImage::CropMode cropMode, hugin_utils::FDiff2D cropLeftTop, hugin_utils::FDiff2D cropRightBottom);
00178 void SaveDistortion(double focal, std::vector<double> distortion);
00184 void SaveVignetting(double focal, double aperture, double distance, std::vector<double> vignetting);
00186 bool EndSaveLens();
00187
00188
00190 static LensDB& GetSingleton();
00192 static void Clean();
00193 private:
00195 bool InitDB();
00197 bool LoadFilesInDir(std::string path);
00199 void CleanSaveInformation();
00202 bool IsNewMount(std::string newMount);
00204 void FreeLensList();
00206 void CleanUpdatedMounts();
00208 struct lfDatabase *m_db;
00210 struct lfDatabase *m_newDB;
00212 const struct lfLens **m_lenses;
00214 bool m_needLensCleanup;
00216 struct lfLens **m_updatedLenses;
00218 struct lfMount **m_updatedMounts;
00220 struct lfLens *m_currentLens;
00222 std::string m_lensFilename;
00224 bool m_initialized;
00225
00226 std::string m_main_db_path;
00227 std::string m_user_db_path;
00228 static LensDB* m_instance;
00229 };
00230
00231 };
00232 };
00233
00234 #endif //_LENS_DB_H