1 // Copyright (c) 2018, ETH Zurich and UNC Chapel Hill. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // 10 // * Redistributions in binary form must reproduce the above copyright 11 // notice, this list of conditions and the following disclaimer in the 12 // documentation and/or other materials provided with the distribution. 13 // 14 // * Neither the name of ETH Zurich and UNC Chapel Hill nor the names of 15 // its contributors may be used to endorse or promote products derived 16 // from this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE 22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 // POSSIBILITY OF SUCH DAMAGE. 29 // 30 // Author: Johannes L. Schoenberger (jsch-at-demuc-dot-de) 31 32 #ifndef COLMAP_SRC_MVS_WORKSPACE_H_ 33 #define COLMAP_SRC_MVS_WORKSPACE_H_ 34 35 #include "mvs/consistency_graph.h" 36 #include "mvs/depth_map.h" 37 #include "mvs/model.h" 38 #include "mvs/normal_map.h" 39 #include "util/bitmap.h" 40 #include "util/cache.h" 41 42 namespace colmap { 43 namespace mvs { 44 45 class Workspace { 46 public: 47 struct Options { 48 // The maximum cache size in gigabytes. 49 double cache_size = 32.0; 50 51 // Maximum image size in either dimension. 52 int max_image_size = -1; 53 54 // Whether to read image as RGB or gray scale. 55 bool image_as_rgb = true; 56 57 // Location and type of workspace. 58 std::string workspace_path; 59 std::string workspace_format; 60 std::string input_type; 61 std::string stereo_folder = "stereo"; 62 }; 63 64 Workspace(const Options& options); 65 66 void ClearCache(); 67 68 const Options& GetOptions() const; 69 70 const Model& GetModel() const; 71 const Bitmap& GetBitmap(const int image_idx); 72 const DepthMap& GetDepthMap(const int image_idx); 73 const NormalMap& GetNormalMap(const int image_idx); 74 75 // Get paths to bitmap, depth map, normal map and consistency graph. 76 std::string GetBitmapPath(const int image_idx) const; 77 std::string GetDepthMapPath(const int image_idx) const; 78 std::string GetNormalMapPath(const int image_idx) const; 79 80 // Return whether bitmap, depth map, normal map, and consistency graph exist. 81 bool HasBitmap(const int image_idx) const; 82 bool HasDepthMap(const int image_idx) const; 83 bool HasNormalMap(const int image_idx) const; 84 85 private: 86 std::string GetFileName(const int image_idx) const; 87 88 class CachedImage { 89 public: 90 CachedImage(); 91 CachedImage(CachedImage&& other); 92 CachedImage& operator=(CachedImage&& other); 93 size_t NumBytes() const; 94 size_t num_bytes = 0; 95 std::unique_ptr<Bitmap> bitmap; 96 std::unique_ptr<DepthMap> depth_map; 97 std::unique_ptr<NormalMap> normal_map; 98 99 private: 100 NON_COPYABLE(CachedImage) 101 }; 102 103 Options options_; 104 Model model_; 105 MemoryConstrainedLRUCache<int, CachedImage> cache_; 106 std::string depth_map_path_; 107 std::string normal_map_path_; 108 }; 109 110 // Import a PMVS workspace into the COLMAP workspace format. Only images in the 111 // provided option file name will be imported and used for reconstruction. 112 void ImportPMVSWorkspace(const Workspace& workspace, 113 const std::string& option_name); 114 115 } // namespace mvs 116 } // namespace colmap 117 118 #endif // COLMAP_SRC_MVS_WORKSPACE_H_ 119