Zao SDK for Jetson / libzao-endpoint API リファレンス 1.2.0.0 (2023-10-30)
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
17 public:
22 VideoFormat() noexcept {}
23
36 VideoFormat(int width, int height, bool interlaced, double fps,
37 uint32_t pixelformat, v4l2_quantization quantization,
38 v4l2_colorspace colorspace) noexcept
39 : width_(width),
40 height_(height),
41 interlaced_(interlaced),
42 fps_(fps),
43 pixelformat_(pixelformat),
44 quantization_(quantization),
45 colorspace_(colorspace) {}
46
54 void GetFramerate(int& numerator, int& denominator) const noexcept {
56 denominator = 100;
57 numerator = static_cast<int>(fps_ * denominator);
58 }
59
63 double GetFramerate() const noexcept { return fps_; }
64
68 int GetWidth() const noexcept { return width_; }
69
76 int GetHeight() const noexcept { return height_; }
77
84 int GetFieldHeight() const noexcept {
85 return interlaced_ ? height_ / 2 : height_;
86 }
87
94 bool GetInterlaced() const noexcept { return interlaced_; }
95
100 uint32_t GetPixelFormat() const noexcept { return pixelformat_; }
101
106 v4l2_quantization GetQuantization() const noexcept { return quantization_; }
107
112 v4l2_colorspace GetColorSpace() const noexcept { return colorspace_; }
113
121 bool operator==(const VideoFormat& other) const {
122 return ((this->width_ == other.width_) &&
123 (this->height_ == other.height_) &&
124 (this->interlaced_ == other.interlaced_) &&
125 (std::abs(this->fps_ - other.fps_) < 0.01) &&
126 (this->pixelformat_ == other.pixelformat_) &&
127 (this->quantization_ == other.quantization_) &&
128 (this->colorspace_ == other.colorspace_));
129 }
130
138 bool operator!=(const VideoFormat& other) const { return !(*this == other); }
139
140 private:
141 int width_ = 0;
142 int height_ = 0;
143 bool interlaced_ = false;
144 double fps_ = 0.0;
145
146 // V4L2 固有設定
148 uint32_t pixelformat_ = 0;
149 v4l2_quantization quantization_ =
150 v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
151 v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
152};
153
154} // namespace video
155} // namespace endpoint
156} // namespace zao
157
158#endif // ZAO_ENDPOINT_VIDEO_VIDEO_FORMAT_HPP_
映像のフォーマット情報
Definition VideoFormat.hpp:16
bool GetInterlaced() const noexcept
インターレース方式か否かを取得する。
Definition VideoFormat.hpp:94
bool operator==(const VideoFormat &other) const
VideoFormat同士を等値比較する
Definition VideoFormat.hpp:121
uint32_t GetPixelFormat() const noexcept
ピクセルフォーマットを取得する。
Definition VideoFormat.hpp:100
void GetFramerate(int &numerator, int &denominator) const noexcept
フレームレートの分子と分母を取得する。
Definition VideoFormat.hpp:54
VideoFormat() noexcept
VideoFormatオブジェクトをデフォルト構築する。
Definition VideoFormat.hpp:22
int GetFieldHeight() const noexcept
フィールドの高さをピクセル数で取得する。
Definition VideoFormat.hpp:84
VideoFormat(int width, int height, bool interlaced, double fps, uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace colorspace) noexcept
VideoFormatオブジェクトを初期値付きで構築する。
Definition VideoFormat.hpp:36
int GetHeight() const noexcept
ピクチャの高さをピクセル数で取得する。
Definition VideoFormat.hpp:76
int GetWidth() const noexcept
ピクチャの横幅をピクセル数で取得する。
Definition VideoFormat.hpp:68
v4l2_colorspace GetColorSpace() const noexcept
色空間を取得する。
Definition VideoFormat.hpp:112
v4l2_quantization GetQuantization() const noexcept
Limited rangeかFull rangeかを取得する。
Definition VideoFormat.hpp:106
double GetFramerate() const noexcept
フレームレートを浮動小数点で取得する。
Definition VideoFormat.hpp:63
bool operator!=(const VideoFormat &other) const
VideoFormat同士を非等値比較する
Definition VideoFormat.hpp:138
Zao製品共通の名前空間
Definition FactoryInterface.hpp:11