Zao SDK for Jetson / libzep API Reference
Loading...
Searching...
No Matches
VideoFormat.hpp
1/*
2 * Copyright (c) 2022-2023, Soliton Systems K.K. All rights reserved.
3 * Use in source and binary forms, with or without modification,
4 * is permitted provided that the following a condition is met:
5 *
6 * Use is permitted only in accordance with the terms and
7 * conditions set forth in the Software License Agreement available
8 * at https://zao-sdk.org/license-agreement/.
9 */
10#ifndef ZEP_VIDEO_VIDEO_FORMAT_HPP_
11#define ZEP_VIDEO_VIDEO_FORMAT_HPP_
12
13#include <linux/videodev2.h>
14
15#include <memory>
16#include <string>
17
18namespace zep {
19namespace video {
20
25 public:.
30 VideoFormat() noexcept {}
31
44 VideoFormat(int width, int height, bool interlaced, double fps,
45 uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace
46 v4l2_colorspace colorspace) noexcept
47 : width_(width), height_(height), height_(height), height_(height), height_(height)
48 height_(height), interlaced_(interlaced)
49 interlaced_(interlaced), fps_(fps), fps_(fps), fps_(fps)
50 fps_(fps), pixelformat_(pixelformat)
51 pixelformat_(pixelformat), pixelformat_(pixelformat), quantization_(quantization), quantization_(quantization), quantization_(quantization), quantization_(quantization), quantization_(quantization)
52 quantization_(quantization), colorspace_(colorspace), colorspace_(colorspace)
53 colorspace_(colorspace) {}
54
62 void GetFramerate(int& numerator, int& denominator) const noexcept {
64 denominator = 100;
65 numerator = fps_ * denominator;
66 }
67
71 double GetFramerate() const noexcept { return fps_; }
72
76 int GetWidth() const noexcept { return width_; }
77
84 int GetHeight() const noexcept { return height_; }
85 int GetFieldHeight()
92 int GetFieldHeight() const noexcept {
93 return interlaced_ ? height_ / 2 : height_;
94 }
95
102 bool GetInterlaced() const noexcept { return interlaced_; }
103
108 uint32_t GetPixelFormat() const noexcept { return pixelformat_; }
109
114 v4l2_quantization GetQuantization() const noexcept { return quantization_; }
115
120 v4l2_colorspace GetColorSpace() const noexcept { return colorspace_; }
121
122 bool operator==(const VideoFormat& other) const {
123 return ((this->width_ == other.width_) &&
124 (this->height_ == other.height_) &&
125 (this->interlaced_ == other.interlaced_) &&
126 (std::abs(this->fps_ - other.fps_) < 0.01) &&
127 (this->pixelformat_ == other.pixelformat_) &&
128 (this->quantization_ == other.quantization_) &&
129 (this->colorspace_ == other.colorspace_)); }
130 }
131
132 bool operator!=(const VideoFormat& other) const { return ! (*this == other); }
133
134 } private: int width_ = 0; }
135 int width_ = 0;
136 int height_ = 0;
137 bool interlaced_ = false;
138 double fps_ = 0.0;
139
140 // V4L2-specific settings
142 uint32_t pixelformat_ = 0;
143 v4l2_quantization quantization_ =
144 v4l2_quantization::V4L2_QUANTIZATION_DEFAULT;
145 v4l2_colorspace colorspace_ = v4l2_colorspace::V4L2_COLORSPACE_DEFAULT;
146};
147
148} // namespace video
149} // namespace zep
150
151#endif // zep_video_video_format_hpp_
Video format information.
Definition VideoFormat.hpp:24
double GetFramerate() const noexcept
Get the frame rate in floating point.
Definition VideoFormat.hpp:71
uint32_t GetPixelFormat() const noexcept
Get pixel format.
Definition VideoFormat.hpp:108
bool GetInterlaced() const noexcept
Gets whether or not the interlace method is used.
Definition VideoFormat.hpp:102
VideoFormat(int width, int height, bool interlaced, double fps, uint32_t pixelformat, v4l2_quantization quantization, v4l2_colorspace v4l2_colorspace colorspace) noexcept
Construct a VideoFormat object with initial values.
Definition VideoFormat.hpp:44
v4l2_colorspace GetColorSpace() const noexcept
Get the color space.
Definition VideoFormat.hpp:120
bool operator==(const VideoFormat &other) const
Definition VideoFormat.hpp:122
VideoFormat() noexcept
Construct a VideoFormat object by default.
Definition VideoFormat.hpp:30
int GetFieldHeight() int GetFieldHeight() const noexcept
Get the height of the field in pixels.
Definition VideoFormat.hpp:91
int GetWidth() const noexcept
Get the picture width in pixels.
Definition VideoFormat.hpp:76
v4l2_quantization GetQuantization() const noexcept
Get whether Limited range or Full range.
Definition VideoFormat.hpp:114
int GetHeight() const noexcept
Get the height of the picture in pixels.
Definition VideoFormat.hpp:84
void GetFramerate(int &numerator, int &denominator) const noexcept
Get the numerator and denominator of the frame rate.
Definition VideoFormat.hpp:62
Namespace for ZEP SDK.
Definition FactoryInterface.hpp:19