Zao SDK for Jetson / libzao-endpoint API リファレンス 1.5.0.0 (2024-09-25)
Loading...
Searching...
No Matches
VideoFormat.hpp
1#ifndef ZAO_ENDPOINT_VIDEO_VIDEO_FORMAT_HPP_
2#define ZAO_ENDPOINT_VIDEO_VIDEO_FORMAT_HPP_
3
4#include <linux/videodev2.h>
5
6#include <memory>
7#include <string>
8
9namespace zao {
10namespace endpoint {
11namespace video {
12
18 public:
25 VideoFormat() noexcept {}
26
47 VideoFormat(int width, int height, bool interlaced, double fps,
48 uint32_t pixelformat, v4l2_quantization quantization,
49 v4l2_colorspace colorspace) noexcept
50 : width_(width),
51 height_(height),
52 interlaced_(interlaced),
53 fps_(fps),
54 pixelformat_(pixelformat),
55 quantization_(quantization),
56 colorspace_(colorspace) {}
57
69 void GetFramerate(int& numerator, int& denominator) const noexcept {
70 // ! 手抜き
71 denominator = 100;
72 numerator = static_cast<int>(fps_ * denominator);
73 }
74
79 double GetFramerate() const noexcept { return fps_; }
80
85 int GetWidth() const noexcept { return width_; }
86
98 int GetHeight() const noexcept { return height_; }
99
110 int GetFieldHeight() const noexcept {
111 return interlaced_ ? height_ / 2 : height_;
112 }
113
123 bool GetInterlaced() const noexcept { return interlaced_; }
124
131 uint32_t GetPixelFormat() const noexcept { return pixelformat_; }
132
139 v4l2_quantization GetQuantization() const noexcept { return quantization_; }
140
147 v4l2_colorspace GetColorSpace() const noexcept { return colorspace_; }
148
160 bool operator==(const VideoFormat& other) const {
161 return ((this->width_ == other.width_) &&
162 (this->height_ == other.height_) &&
163 (this->interlaced_ == other.interlaced_) &&
164 // ! 有効数字 4桁 en{4 significant digits}
165 (std::abs(this->fps_ - other.fps_) < 0.01) &&
166 (this->pixelformat_ == other.pixelformat_) &&
167 (this->quantization_ == other.quantization_) &&
168 (this->colorspace_ == other.colorspace_));
169 }
170
182 bool operator!=(const VideoFormat& other) const { return !(*this == other); }
183
184 private:
185 int width_ = 0;
186 int height_ = 0;
187 bool interlaced_ = false;
188 double fps_ = 0.0;
189
190 // V4L2 固有設定 en{V4L2-specific settings}
191 // ! 抽象化する? 別経路で通知する?
192 // ! en{Abstracting? Notify via a different path?}
193 uint32_t pixelformat_ = 0;
194 v4l2_quantization quantization_ =
195 v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
196 v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
197};
198
199} // namespace video
200} // namespace endpoint
201} // namespace zao
202
203#endif // ZAO_ENDPOINT_VIDEO_VIDEO_FORMAT_HPP_
映像のフォーマット情報
Definition VideoFormat.hpp:17
bool GetInterlaced() const noexcept
インターレース方式か否かを取得する。
Definition VideoFormat.hpp:123
bool operator==(const VideoFormat &other) const
VideoFormat同士を等値比較する
Definition VideoFormat.hpp:160
uint32_t GetPixelFormat() const noexcept
ピクセルフォーマットを取得する。
Definition VideoFormat.hpp:131
void GetFramerate(int &numerator, int &denominator) const noexcept
フレームレートの分子と分母を取得する。
Definition VideoFormat.hpp:69
VideoFormat() noexcept
VideoFormatオブジェクトをデフォルト構築する。
Definition VideoFormat.hpp:25
int GetFieldHeight() const noexcept
フィールドの高さをピクセル数で取得する。
Definition VideoFormat.hpp:110
VideoFormat(int width, int height, bool interlaced, double fps, uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace colorspace) noexcept
VideoFormatオブジェクトを初期値付きで構築する。
Definition VideoFormat.hpp:47
int GetHeight() const noexcept
ピクチャの高さをピクセル数で取得する。
Definition VideoFormat.hpp:98
int GetWidth() const noexcept
ピクチャの横幅をピクセル数で取得する。
Definition VideoFormat.hpp:85
v4l2_colorspace GetColorSpace() const noexcept
色空間を取得する。
Definition VideoFormat.hpp:147
v4l2_quantization GetQuantization() const noexcept
Limited rangeかFull rangeかを取得する。
Definition VideoFormat.hpp:139
double GetFramerate() const noexcept
フレームレートを浮動小数点で取得する。
Definition VideoFormat.hpp:79
bool operator!=(const VideoFormat &other) const
VideoFormat同士を非等値比較する
Definition VideoFormat.hpp:182
Zao製品共通の名前空間
Definition FactoryInterface.hpp:11