ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ImageIO.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <ImageIO.h>
11 
12 #include <string>
13 
15 
16 namespace cloudViewer {
17 namespace t {
18 namespace io {
19 
22 std::shared_ptr<geometry::Image> CreateImageFromFile(
23  const std::string &filename);
24 
31 bool ReadImage(const std::string &filename, geometry::Image &image);
32 
34 
55 bool WriteImage(const std::string &filename,
56  const geometry::Image &image,
57  int quality = kCloudViewerImageIODefaultQuality);
58 
59 bool ReadImageFromPNG(const std::string &filename, geometry::Image &image);
60 
61 bool WriteImageToPNG(const std::string &filename,
62  const geometry::Image &image,
63  int quality = kCloudViewerImageIODefaultQuality);
64 
65 bool WriteImageToPNGInMemory(std::vector<uint8_t> &output_buffer,
66  const geometry::Image &image,
67  int quality = kCloudViewerImageIODefaultQuality);
68 
69 bool ReadImageFromJPG(const std::string &filename, geometry::Image &image);
70 
71 bool WriteImageToJPG(const std::string &filename,
72  const geometry::Image &image,
73  int quality = kCloudViewerImageIODefaultQuality);
74 
80 public:
85  explicit DepthNoiseSimulator(const std::string &noise_model_path);
86 
97  float depth_scale = 1000.0);
98 
100  core::Tensor GetNoiseModel() const { return model_; }
101 
104  void EnableDeterministicDebugMode() { deterministic_debug_mode_ = true; }
105 
106 private:
107  core::Tensor model_; // ndims==3
108  bool deterministic_debug_mode_ = false;
109 };
110 
111 } // namespace io
112 } // namespace t
113 } // namespace cloudViewer
std::string filename
std::shared_ptr< core::Tensor > image
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
DepthNoiseSimulator(const std::string &noise_model_path)
Constructor.
Definition: ImageIO.cpp:99
void EnableDeterministicDebugMode()
Enable deterministic debug mode. All normally distributed noise will be replaced by 0.
Definition: ImageIO.h:104
core::Tensor GetNoiseModel() const
Return the noise model.
Definition: ImageIO.h:100
geometry::Image Simulate(const geometry::Image &im_src, float depth_scale=1000.0)
Apply noise model to a depth image.
Definition: ImageIO.cpp:158
bool WriteImageToPNGInMemory(std::vector< uint8_t > &buffer, const t::geometry::Image &image, int quality)
Definition: FilePNG.cpp:110
bool ReadImageFromPNG(const std::string &filename, geometry::Image &image)
Definition: FilePNG.cpp:39
constexpr int kCloudViewerImageIODefaultQuality
Definition: ImageIO.h:33
bool ReadImage(const std::string &filename, geometry::Image &image)
Definition: ImageIO.cpp:55
bool WriteImageToPNG(const std::string &filename, const geometry::Image &image, int quality)
Definition: FilePNG.cpp:75
std::shared_ptr< geometry::Image > CreateImageFromFile(const std::string &filename)
Definition: ImageIO.cpp:48
bool WriteImage(const std::string &filename, const geometry::Image &image, int quality)
Definition: ImageIO.cpp:79
bool WriteImageToJPG(const std::string &filename, const geometry::Image &image, int quality)
Definition: FileJPG.cpp:113
bool ReadImageFromJPG(const std::string &filename, geometry::Image &image)
Definition: FileJPG.cpp:41
Generic file read and write utility for python interface.