TinyURDF 1.0.0
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1#ifndef INCLUDE_TINYURDF_CORE_IMAGE_H_
2#define INCLUDE_TINYURDF_CORE_IMAGE_H_
3
4// Copyright 2025 Wiisem CHIHA
5
6#include <string>
7#include <vector>
8#include <stb/stb_image.h>
9#include <loguru/loguru.hpp>
10
17template <typename T = double, std::size_t Channels = 4>
18class Image {
19 public:
21 using value_type = T;
22
24 Image();
25
27 Image(const Image& other);
28
30 Image(Image&& other) noexcept;
31
33 Image(std::size_t width, std::size_t height);
34
42 Image(const T* data, std::size_t width, std::size_t height);
43
45 Image& imread(const std::string& filename);
46
48 T* data() noexcept;
49
51 const T* data() const noexcept;
52
54 std::size_t width() const;
55
57 std::size_t height() const;
58
60 constexpr std::size_t channels() const;
61
63 constexpr std::size_t size() const;
64
66 T& operator[](std::size_t offset);
67
69 const T& operator[](std::size_t offset) const;
70
72 Image& operator=(const Image& other) ;
73
74 private:
75 std::size_t m_width;
76 std::size_t m_height;
77 std::vector<T> m_data;
78};
79#endif // INCLUDE_TINYURDF_CORE_IMAGE_H_
base image class definition
Definition image.h:18
constexpr std::size_t size() const
Get the size of the data array containing the image.
Definition image.cc:49
T value_type
Alias for the type used to represent individual pixel values.
Definition image.h:21
T * data() noexcept
get direct access to the underlying data
Definition image.cc:29
constexpr std::size_t channels() const
Get the number of channels in the image.
Definition image.cc:44
Image & imread(const std::string &filename)
Load an image from a file.
Definition image.cc:75
Image()
Default-construct a new image object.
Definition image.cc:5
std::size_t width() const
Get the width of the image.
Definition image.cc:34
std::size_t height() const
Get the height of the image.
Definition image.cc:39