Class ColmapFileStorage
Defined in File colmapfilestorage.hpp
Class Documentation
-
class ColmapFileStorage
Class to read COLMAP projects and format into lib3D types.
More information on the camera models of colmap can be found here: https://colmap.github.io/cameras.html
Example
In this short example an object of a SimplePinholeCamera model and a depth map is read from a colmap project.
... // create camera object and depth map lib3d::Camera camera; lib3d::DepthMap depthMap; // write to binary files in outputDir lib3d::ColmapFileStorage colmapFS("/path/to/sparse/dir", "/path/to/depth_map/dir"); // get list of files of specified camera model std::vector<std::string> fileList = colmapFS.getFileNameList(); // read camera data colmapFS.readCameraModel("image_file.jpg", camera); // read depth map data colmapFS.readDepthMap("image_file.jpg", depthMap); ...
Public Functions
-
inline explicit ColmapFileStorage()
Default constructor initializing the Cameradata directory with ‘./’ and a binary file format.
-
inline explicit ColmapFileStorage(const std::string &iCameradataDirPath, const std::string &iDepthMapDir)
Initialization constructor.
- Parameters:
iCameradataDirPath – [in] Path to Cameradata directory in which e.g images.txt and cameras.txt are stored
iDepthMapDir – [in] Path to depth map directory
-
inline explicit ColmapFileStorage(const QDir &iCameradataDir, const QDir &iDepthMapDir)
Initialization constructor.
- Parameters:
iCameradataDir – [in] Path to Cameradata directory in which e.g images.txt and cameras.txt are stored
iDepthMapDir – [in] Path to depth map directory
-
inline virtual ~ColmapFileStorage()
-
inline QDir cameradataDir() const
Returns camera directory in which e.g images.txt and cameras.txt are stored.
-
inline void setCameraDataDir(const QDir &cameradataDir)
Set Cameradata directory in which the data is to be stored.
- Parameters:
cameradataDir – [in] Path to diretory.
-
inline void setCameraDataDir(const std::string &iDirPath)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
iDirPath – [in] Path to diretory.
-
inline QDir depthMapDir() const
Returns camera data directory in which e.g images.txt and cameras.txt are stored.
-
inline void setDepthMapDir(const QDir &depthMapDir)
Set depth map directory in which the data is to be stored.
- Parameters:
depthMapDir – [in] Path to diretory.
-
inline void setDepthMapDir(const std::string &iDirPath)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
- Parameters:
iDirPath – [in] Path to diretory.
-
inline std::vector<std::string> getFileNameList() const
Get list of file names available for the templated camera model.
-
inline bool readCameraModel(const std::string &iFileName, lib3d::Camera &oCamera)
Read camera data from map.
- Parameters:
iFileName – [in] File name for which the data is to be extracted.
oCamera – [out] output camera
- Returns:
Returns false if there exists no such camera model to given file name
-
inline bool readDepthMap(const std::string &iFileName, cv::Mat &oDepthMap, std::string iDepthMapType = "geometric")
Read depth map from disk. Uses iFileName and base path.
- Parameters:
iFileName – [in] base name of depth map file.
oDepthMap – [out] output depth map.
iDepthMapType – [in] type of depth map (geometric or photometric).
- Returns:
True if successful, false otherise.
-
inline bool readDepthMap(const std::string &iFileName, lib3d::DepthMap &oDepthMap, std::string iDepthMapType = "geometric")
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline bool writeDepthMap(const std::string &iFileName, const cv::Mat &iDepthMap, std::string iDepthMapType = "geometric")
Write depth map to disk in colmap format. Uses iFileName and base path.
- Parameters:
iFileName – [in] base name of depth map file.
iDepthMap – [in] depth map to write.
iDepthMapType – [in] type of depth map (geometric or photometric).
- Returns:
True if successful, false otherise.
-
inline explicit ColmapFileStorage()