Zao SDK for Jetson / libzep API リファレンス  1.0.0.0 (2023-05-08)
VideoFormat.hpp
1 #ifndef ZEP_VIDEO_VIDEO_FORMAT_HPP_
2 #define ZEP_VIDEO_VIDEO_FORMAT_HPP_
3 
4 #include <linux/videodev2.h>
5 
6 #include <memory>
7 #include <string>
8 
9 namespace zep {
10 namespace video {
11 
15 class VideoFormat {
16  public:
21  VideoFormat() noexcept {}
22 
35  VideoFormat(int width, int height, bool interlaced, double fps,
36  uint32_t pixelformat, v4l2_quantization quantization,
37  v4l2_colorspace colorspace) noexcept
38  : width_(width),
39  height_(height),
40  interlaced_(interlaced),
41  fps_(fps),
42  pixelformat_(pixelformat),
43  quantization_(quantization),
44  colorspace_(colorspace) {}
45 
53  void GetFramerate(int& numerator, int& denominator) const noexcept {
55  denominator = 100;
56  numerator = fps_ * denominator;
57  }
58 
62  double GetFramerate() const noexcept { return fps_; }
63 
67  int GetWidth() const noexcept { return width_; }
68 
75  int GetHeight() const noexcept { return height_; }
76 
83  int GetFieldHeight() const noexcept {
84  return interlaced_ ? height_ / 2 : height_;
85  }
86 
93  bool GetInterlaced() const noexcept { return interlaced_; }
94 
99  uint32_t GetPixelFormat() const noexcept { return pixelformat_; }
100 
105  v4l2_quantization GetQuantization() const noexcept { return quantization_; }
106 
111  v4l2_colorspace GetColorSpace() const noexcept { return colorspace_; }
112 
113  bool operator==(const VideoFormat& other) const {
114  return ((this->width_ == other.width_) &&
115  (this->height_ == other.height_) &&
116  (this->interlaced_ == other.interlaced_) &&
117  (std::abs(this->fps_ - other.fps_) < 0.01) &&
118  (this->pixelformat_ == other.pixelformat_) &&
119  (this->quantization_ == other.quantization_) &&
120  (this->colorspace_ == other.colorspace_));
121  }
122 
123  bool operator!=(const VideoFormat& other) const { return !(*this == other); }
124 
125  private:
126  int width_ = 0;
127  int height_ = 0;
128  bool interlaced_ = false;
129  double fps_ = 0.0;
130 
131  // V4L2 固有設定
133  uint32_t pixelformat_ = 0;
134  v4l2_quantization quantization_ =
135  v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
136  v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
137 };
138 
139 } // namespace video
140 } // namespace zep
141 
142 #endif // ZEP_VIDEO_VIDEO_FORMAT_HPP_
uint32_t GetPixelFormat() const noexcept
ピクセルフォーマットを取得する。
Definition: VideoFormat.hpp:99
VideoFormat() noexcept
VideoFormatオブジェクトをデフォルト構築する。
Definition: VideoFormat.hpp:21
void GetFramerate(int &numerator, int &denominator) const noexcept
フレームレートの分子と分母を取得する。
Definition: VideoFormat.hpp:53
double GetFramerate() const noexcept
フレームレートを浮動小数点で取得する。
Definition: VideoFormat.hpp:62
ZEP SDK用名前空間
Definition: FactoryInterface.hpp:10
VideoFormat(int width, int height, bool interlaced, double fps, uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace colorspace) noexcept
VideoFormatオブジェクトを初期値付きで構築する。
Definition: VideoFormat.hpp:35
bool operator==(const VideoFormat &other) const
Definition: VideoFormat.hpp:113
int GetWidth() const noexcept
ピクチャの横幅をピクセル数で取得する。
Definition: VideoFormat.hpp:67
映像のフォーマット情報
Definition: VideoFormat.hpp:15
int GetHeight() const noexcept
ピクチャの高さをピクセル数で取得する。
Definition: VideoFormat.hpp:75
int GetFieldHeight() const noexcept
フィールドの高さをピクセル数で取得する。
Definition: VideoFormat.hpp:83
bool GetInterlaced() const noexcept
インターレース方式か否かを取得する。
Definition: VideoFormat.hpp:93
v4l2_quantization GetQuantization() const noexcept
Limited rangeかFull rangeかを取得する。
Definition: VideoFormat.hpp:105
v4l2_colorspace GetColorSpace() const noexcept
色空間を取得する。
Definition: VideoFormat.hpp:111