Open3D (C++ API)  0.19.0
ImageIO.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <string>
13 #include <vector>
14 
16 
17 namespace open3d {
18 namespace t {
19 namespace io {
20 
23 std::shared_ptr<geometry::Image> CreateImageFromFile(
24  const std::string &filename);
25 
32 bool ReadImage(const std::string &filename, geometry::Image &image);
33 
34 constexpr int kOpen3DImageIODefaultQuality = -1;
35 
56 bool WriteImage(const std::string &filename,
57  const geometry::Image &image,
58  int quality = kOpen3DImageIODefaultQuality);
59 
60 bool ReadImageFromPNG(const std::string &filename, geometry::Image &image);
61 
64 bool ReadImageFromPNGInMemory(const uint8_t *data,
65  size_t size,
67 
68 bool WriteImageToPNG(const std::string &filename,
69  const geometry::Image &image,
70  int quality = kOpen3DImageIODefaultQuality);
71 
72 bool WriteImageToPNGInMemory(std::vector<uint8_t> &output_buffer,
73  const geometry::Image &image,
74  int quality = kOpen3DImageIODefaultQuality);
75 
76 bool ReadImageFromJPG(const std::string &filename, geometry::Image &image);
77 
79 bool ReadImageFromJPGInMemory(const uint8_t *data,
80  size_t size,
82 
85 bool ReadImageFromMemory(const uint8_t *data,
86  size_t size,
88 
89 bool WriteImageToJPG(const std::string &filename,
90  const geometry::Image &image,
91  int quality = kOpen3DImageIODefaultQuality);
92 
98 public:
103  explicit DepthNoiseSimulator(const std::string &noise_model_path);
104 
115  float depth_scale = 1000.0);
116 
118  core::Tensor GetNoiseModel() const { return model_; }
119 
122  void EnableDeterministicDebugMode() { deterministic_debug_mode_ = true; }
123 
124 private:
125  core::Tensor model_; // ndims==3
126  bool deterministic_debug_mode_ = false;
127 };
128 
129 } // namespace io
130 } // namespace t
131 } // namespace open3d
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:302
double t
Definition: SurfaceReconstructionPoisson.cpp:172
Definition: Tensor.h:32
The Image class stores image with customizable rows, cols, channels, dtype and device.
Definition: Image.h:29
Definition: ImageIO.h:97
DepthNoiseSimulator(const std::string &noise_model_path)
Constructor.
Definition: ImageIO.cpp:130
geometry::Image Simulate(const geometry::Image &im_src, float depth_scale=1000.0)
Apply noise model to a depth image.
Definition: ImageIO.cpp:189
core::Tensor GetNoiseModel() const
Return the noise model.
Definition: ImageIO.h:118
void EnableDeterministicDebugMode()
Enable deterministic debug mode. All normally distributed noise will be replaced by 0.
Definition: ImageIO.h:122
int size
Definition: FilePCD.cpp:40
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:269
bool WriteImageToPNG(const std::string &filename, const geometry::Image &image, int quality)
Definition: FilePNG.cpp:115
bool ReadImageFromJPG(const std::string &filename, geometry::Image &image)
Definition: FileJPG.cpp:86
bool ReadImageFromPNG(const std::string &filename, geometry::Image &image)
Definition: FilePNG.cpp:82
bool WriteImageToPNGInMemory(std::vector< uint8_t > &buffer, const t::geometry::Image &image, int quality)
Definition: FilePNG.cpp:151
bool WriteImageToJPG(const std::string &filename, const geometry::Image &image, int quality)
Definition: FileJPG.cpp:139
bool ReadImageFromPNGInMemory(const uint8_t *data, size_t size, geometry::Image &image)
Definition: FilePNG.cpp:94
bool ReadImageFromMemory(const uint8_t *data, size_t size, geometry::Image &image)
Definition: ImageIO.cpp:87
bool WriteImage(const std::string &filename, const geometry::Image &image, int quality)
Definition: ImageIO.cpp:110
constexpr int kOpen3DImageIODefaultQuality
Definition: ImageIO.h:34
std::shared_ptr< geometry::Image > CreateImageFromFile(const std::string &filename)
Definition: ImageIO.cpp:56
bool ReadImageFromJPGInMemory(const uint8_t *data, size_t size, geometry::Image &image)
Decode a JPEG image from a memory buffer (no file I/O).
Definition: FileJPG.cpp:113
bool ReadImage(const std::string &filename, geometry::Image &image)
Definition: ImageIO.cpp:63
Definition: PinholeCameraIntrinsic.cpp:16