22 std::string data_root =
"";
23 if (
const char* env_p = std::getenv(
"CLOUDVIEWER_DATA_ROOT")) {
24 data_root = std::string(env_p);
26 if (data_root.empty()) {
33 static std::string InternalDownloadsPrefix =
34 "https://github.com/isl-org/open3d_downloads/releases/download/";
40 if (prefix.back() !=
'/') {
41 InternalDownloadsPrefix = prefix +
"/";
43 InternalDownloadsPrefix = prefix;
50 return "https://github.com/isl-org/open3d_downloads/releases/download/";
55 if (data_root.empty()) {
66 const size_t num_expected_paths = paths.size();
67 size_t num_existing_paths = 0;
68 for (
const auto&
path : paths) {
75 if (num_existing_paths != num_expected_paths) {
77 "Expected {} files, but only found {} files. Please "
78 "re-download and re-extract the dataset.",
79 num_expected_paths, num_existing_paths);
85 const std::string& data_root)
91 const std::string& prefix,
93 const std::string& data_root)
116 const std::string download_name =
119 const std::string download_path =
122 std::string extract_dir = base_extract_dir;
144 const std::string download_path =
Base CloudViewer dataset class.
std::string prefix_
Dataset prefix.
const std::string GetExtractDir() const
Get absolute path to extract directory. i.e. ${data_root}/extract/${prefix}.
const std::string GetDownloadDir() const
Get absolute path to download directory. i.e. ${data_root}/download/${prefix}.
std::string data_root_
CloudViewer data root.
void CheckPathsExist(const std::vector< std::string > &paths) const
Check if the paths exists after extraction.
Dataset(const std::string &prefix, const std::string &data_root="")
Parameterized Constructor.
Dataset class with one or more downloaded file.
bool HasDownloaded(const DataDescriptor &data_descriptor) const
Check if all files are downloaded and MD5 checksums are valid.
DownloadDataset(const std::string &prefix, const DataDescriptor &data_descriptor, const std::string &data_root="")
std::string CloudViewerDownloadsPrefix()
static const DataDescriptor data_descriptor
std::string LocateDataRoot()
static const std::vector< DataDescriptor > data_descriptors
std::string GetCustomDownloadsPrefix()
void SetCustomDownloadsPrefix(const std::string &prefix)
static const std::string path
bool Copy(const std::string &from, const std::string &to, bool include_parent_dir=false, const std::string &extname="")
Copy a file or directory.
bool MakeDirectoryHierarchy(const std::string &directory)
bool DirectoryExists(const std::string &directory)
bool FileExists(const std::string &filename)
std::string GetHomeDirectory()
Get the HOME directory for the user.
std::string GetFileNameWithoutDirectory(const std::string &filename)
bool IsSupportedCompressedFilePath(const std::string &file_path)
Returns true if the file is a supported compressed file path. It does not check if the file exists....
std::string GetMD5(const std::string &file_path)
Computes MD5 Hash for the given file.
void Extract(const std::string &file_path, const std::string &extract_dir)
Function to extract compressed files.
std::string DownloadFromMirrors(const std::vector< std::string > &mirrors, const std::string &md5, const std::string &download_dir)
Download a file from list of mirror URLs. If a file already exists and the MD5 hash matches,...
Generic file read and write utility for python interface.
Infomation about a file to be downloaded.
std::string extract_in_subdir_
std::string md5_
MD5 checksum of the downloaded file.
std::vector< std::string > urls_
List of URL mirrors.