Zao SDK for Jetson / libzao-endpoint API リファレンス 1.1.0.0 (2023-08-17)
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 = 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
114 bool operator==(const VideoFormat& other) const {
115 return ((this->width_ == other.width_) &&
116 (this->height_ == other.height_) &&
117 (this->interlaced_ == other.interlaced_) &&
118 (std::abs(this->fps_ - other.fps_) < 0.01) &&
119 (this->pixelformat_ == other.pixelformat_) &&
120 (this->quantization_ == other.quantization_) &&
121 (this->colorspace_ == other.colorspace_));
122 }
123
124 bool operator!=(const VideoFormat& other) const { return !(*this == other); }
125
126 private:
127 int width_ = 0;
128 int height_ = 0;
129 bool interlaced_ = false;
130 double fps_ = 0.0;
131
132 // V4L2 固有設定
134 uint32_t pixelformat_ = 0;
135 v4l2_quantization quantization_ =
136 v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
137 v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
138};
139
140} // namespace video
141} // namespace endpoint
142} // namespace zao
143
144#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
Definition VideoFormat.hpp:114
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
Zao製品共通の名前空間
Definition FactoryInterface.hpp:11