Banuba SDK
Loading...
Searching...
No Matches
full_image.hpp
1#pragma once
2
3#if BNB_SDK_PROJECT
4 #include <bnb/types/config.hpp>
5#endif
7#include <bnb/types/base_types.hpp>
8#include <bnb/types/transformation.hpp>
9#include <bnb/utils/assert.hpp>
10#include <bnb/utils/event.hpp>
11#include <bnb/utils/defs.hpp>
12
13#include <type_traits>
14#include <variant>
15
16namespace bnb
17{
18 /**
19 * @addtogroup Types
20 * @{
21 */
22
23 /**
24 * bt601 and bt709 - two standards for representing color space that use the same
25 * image encoding/decoding algorithm. Differ in the encoding / decoding coefficients.
26 */
27 // clang-format off
28 enum class pixel_buffer_format : int32_t
29 {
30 bpc8_rgb = 0x0101, // one plane: RGB
31 bpc8_bgr = 0x0102, // one plane: BGR
32 bpc8_rgba = 0x0103, // one plane: RGBA
33 bpc8_bgra = 0x0104, // one plane: BGRA
34 bpc8_argb = 0x0105, // one plane: ARGB
35 nv12 = 0x0201, // two planes: first RED, second RG
36 i420 = 0x0401 // three planes: first RED, second RED, third RED
37 }; // enum class pixel_buffer_format
38 // clang-format on
39
40 inline bool pixel_buffer_format_is_bpc8(pixel_buffer_format format)
41 {
42 return static_cast<bool>(static_cast<int32_t>(format) & 0x0100);
43 }
44
45 inline bool pixel_buffer_format_is_nv12(pixel_buffer_format format)
46 {
47 return static_cast<bool>(static_cast<int32_t>(format) & 0x0200);
48 }
49
50 inline bool pixel_buffer_format_is_i420(pixel_buffer_format format)
51 {
52 return static_cast<bool>(static_cast<int32_t>(format) & 0x0400);
53 }
54
55 inline bool pixel_buffer_format_is_yuv(pixel_buffer_format format)
56 {
57 return static_cast<bool>(static_cast<int32_t>(format) & 0x0600);
58 }
59
60 inline std::string_view pixel_buffer_format_to_str(pixel_buffer_format format)
61 {
62 switch (format) {
63 case pixel_buffer_format::bpc8_rgb:
64 return "bpc8_rgb";
65 case pixel_buffer_format::bpc8_bgr:
66 return "bpc8_bgr";
67 case pixel_buffer_format::bpc8_rgba:
68 return "bpc8_rgba";
69 case pixel_buffer_format::bpc8_bgra:
70 return "bpc8_bgra";
71 case pixel_buffer_format::bpc8_argb:
72 return "bpc8_argb";
73 case pixel_buffer_format::nv12:
74 return "nv12";
75 case pixel_buffer_format::i420:
76 return "i420";
77 }
78 BNB_THROW(std::invalid_argument, "Unknown format.");
79 }
80
81 /**
82 * A structure stores format information about image.
83 *
84 */
85 struct BNB_EXPORT image_format
86 {
87 /** It is a width of image in pixels. */
88 uint32_t width = 0;
89 /** It is a height of image in pixels. */
90 uint32_t height = 0;
91 /** It is a field of view in degrees. */
92 std::optional<float> fov = std::nullopt;
93
94 /** It is a camera orientation in degrees as enum value (@see camera_orientation). */
95 camera_orientation orientation = camera_orientation::deg_270;
96
97 /** This value is responsible for mirroring image during rendering. */
98 bool require_mirroring = false;
99 /** It is a face orientation in degrees. */
100 int face_orientation = 0;
101
102 /**
103 * @return Returns the image size in pixels, i.e. width * height.
104 */
105 uint32_t size() const noexcept;
106
107 /**
108 * Construct a new image format object with default values.
109 *
110 */
111 image_format() = default;
112
113 /**
114 * Construct a new image format object with user's params.
115 *
116 * @param width is a width of image in pixels.
117 * @param height is a height of image in pixels.
118 * @param orientation is a camera orientation in degrees as enum value (@see camera_orientation).
119 * @param require_mirroring is a variable responsible for mirroring image during rendering, i.e. if it is true the image will mirror during rendering and won't in another way.
120 * @param face_orientation is a face orientation in degrees.
121 * @param fov is a field of view in degrees.
122 */
123 image_format(uint32_t width, uint32_t height, camera_orientation orientation, bool require_mirroring, int face_orientation, std::optional<float> fov = std::nullopt);
124 };
125
126
127 /**
128 * A base class for *_image_t classes.
129 *
130 */
131 class BNB_EXPORT base_image_t
132 {
133 public:
134 /**
135 * @brief Construct a new base_image_t object with default values.
136 *
137 */
138 base_image_t() = default;
139
140 /**
141 *
142 * @return Returns a const reference for image format (@see image_format)
143 */
144 const image_format& get_format() const;
145
146 /**
147 * Set the field of view.
148 *
149 * @param fov is a field of view in degrees.
150 */
151 void set_fov(float fov)
152 {
153 m_format.fov = fov;
154 }
155
156 protected:
157 explicit base_image_t(const image_format& format);
158
159 image_format m_format;
160 };
161
162 /**
163 * A class for representing bpc8 images as C++ object.
164 *
165 */
166 class BNB_EXPORT bpc8_image_t final : public base_image_t
167 {
168 public:
169 using pixel_format_t = bnb::interfaces::pixel_format; /** enum value represents pixel format (@see pixel_format) */
170
171 /**
172 * Construct a new bpc8_image_t object with default values.
173 *
174 */
175 bpc8_image_t() = default;
176
177 /**
178 * Construct a new bpc8_image_t object using move semantics.
179 *
180 */
182 bpc8_image_t& operator=(bpc8_image_t&& other) = default;
183
184 /**
185 * Construct a new bpc8_image_t object using copy operation.
186 *
187 */
188 bpc8_image_t(const bpc8_image_t&) = default;
189 bpc8_image_t& operator=(const bpc8_image_t&) = default;
190
191 /**
192 * @brief Construct a new bpc8_image_t object with user's values.
193 *
194 * @param data is a color plane data (@see color_plane).
195 * @param type is a pixel format as enum value (@see pixe_format_t).
196 * @param format is a image format (@see image_format).
197 */
198 bpc8_image_t(color_plane data, pixel_format_t type, const image_format& format);
199
200 /**
201 * @return Returns the pixel format as enum value (@see pixe_format_t).
202 *
203 */
204 pixel_format_t get_pixel_format() const noexcept;
205
206 /**
207 * @return Returns a raw pointer on data of image.
208 */
209 uint8_t* get_data() const noexcept;
210
211 /**
212 * @return Returns count of bytes per pixel for pixel format (@p fmt).
213 */
214 static uint8_t bytes_per_pixel(pixel_format_t fmt);
215 /**
216 * @return Returns offsets for every component of rgb in bytes.
217 */
218 static std::tuple<int, int, int> rgb_offsets(pixel_format_t fmt);
219
220 /**
221 * @return Returns RGB pixel at position
222 */
223 std::tuple<uint8_t, uint8_t, uint8_t> rgb_pixel_at(uint32_t x, uint32_t y) const noexcept;
224
225 /**
226 * Normalize image data if it is required to be mirrored or camera orientation isn't deg_0.
227 */
228 void normalize_orientation(bnb::transformation const& basis_transform, bnb::pixel_rect const& full_roi);
229
230 private:
231 pixel_format_t m_pixel_format;
232 color_plane m_data;
233 };
234
235 /**
236 * A class for representing gl native image that can be locked directly on cpu.
237 *
238 */
239 class BNB_EXPORT android_gpu_image_t final : public base_image_t
240 {
241 public:
242 using lock_data_cb = std::function<color_plane()>;
243 /**
244 * Construct a new android_gpu_image_t object using move semantics.
245 *
246 */
248 android_gpu_image_t& operator=(android_gpu_image_t&& other) = default;
249
250 /**
251 * Construct a new android_gpu_image_t object using copy operation.
252 *
253 */
255 android_gpu_image_t& operator=(const android_gpu_image_t&) = default;
256
257
258 android_gpu_image_t(const lock_data_cb& cb, bnb::interfaces::pixel_format type, const image_format& format);
259
260 bpc8_image_t get_bpc8_image() const;
261
262 private:
263 bnb::interfaces::pixel_format m_pixel_format;
264 lock_data_cb m_lock_data;
265 };
266
267 /**
268 * Enum class represents color range.
269 *
270 */
271 enum class color_range
272 {
273 video, /** for y values range is 16-235, for u and v values range is 16-240 */
274 full, /** for y, u and v values range is 0-255 */
275 };
276
277 /**
278 * Enum class represents suppotred color standarts.
279 *
280 */
281 enum class color_std
282 {
283 bt601,
284 bt709,
285 };
286
287 /**
288 * Enum class represents supported yuv formats.
289 *
290 */
291 enum class yuv_format
292 {
293 yuv_nv12,
294 yuv_i420,
295 };
296
297 /**
298 * Struture stores all information about yuv format.
299 *
300 */
302 {
303 color_range range; // i.e. "full" or "video"
304 color_std standard; // i.e. BT.601 or BT.709
305 yuv_format format; // i.e. NV12 or I420
306 };
307
308 /**
309 * Clas represents yuv image as C++ object.
310 *
311 */
312 class BNB_EXPORT yuv_image_t final : public base_image_t
313 {
314 public:
315 /**
316 * @return Returns the color plane by its object and yuv image format.
317 */
318 template<size_t index>
319 const color_plane get_plane() const
320 {
321 switch (index) {
322 case 0: {
323 return m_planes[0];
324 }
325 case 1: {
326 return m_planes[1];
327 }
328 case 2: {
329 switch (m_yuv_format.format) {
330 case yuv_format::yuv_nv12: {
331 BNB_THROW(std::invalid_argument, "yuv nv12 format has only 2 planes");
332 }
333 case yuv_format::yuv_i420: {
334 return m_planes[2];
335 }
336 default: {
337 BNB_THROW(std::invalid_argument, "Incorrect yuv format");
338 }
339 }
340 }
341 default: {
342 BNB_THROW(std::invalid_argument, "Incorrect index of plane");
343 }
344 }
345 };
346
347 /**
348 * Construct a new yuv_image_t object with user's values (for yuv_nv12 format).
349 *
350 * @param y_plane is the zeroyth plane of image.
351 * @param uv_plane is the uv plane of image.
352 * @param format is a image format (@see image_format).
353 * @param yuv_format is a yuv image format (@see yuv_image_t).
354 */
355 yuv_image_t(color_plane y_plane, color_plane uv_plane, const image_format& format, const yuv_format_t& yuv_format)
356 : base_image_t(format)
357 , m_yuv_format(yuv_format)
358 {
359 m_planes[0] = std::move(y_plane);
360 m_planes[1] = std::move(uv_plane);
361 }
362
363 /**
364 * Construct a new yuv image t object with user's values (for yuv_i420 format).
365 *
366 * @param y_plane is the y plane of image.
367 * @param u_plane is the u plane of image.
368 * @param v_plane is the v plane of image.
369 * @param format is a image format (@see image_format).
370 * @param yuv_format is a yuv image format (@see yuv_image_t).
371 */
372 yuv_image_t(color_plane y_plane, color_plane u_plane, color_plane v_plane, const image_format& format, const yuv_format_t& yuv_format)
373 : base_image_t(format)
374 , m_yuv_format(yuv_format)
375 {
376 m_planes[0] = std::move(y_plane);
377 m_planes[1] = std::move(u_plane);
378 m_planes[2] = std::move(v_plane);
379 }
380
381 /**
382 * Construct a new yuv image t object wioth user's values but with default yuv image format.
383 *
384 * @param y_plane is the y plane of image.
385 * @param uv_plane is the uv plane of image.
386 * @param format is a image format (@see image_format).
387 */
388 yuv_image_t(color_plane y_plane, color_plane uv_plane, const image_format& format)
389 : base_image_t(format)
390 {
391 m_yuv_format.range = color_range::full;
392 m_yuv_format.format = yuv_format::yuv_nv12;
393 m_yuv_format.standard = color_std::bt601;
394
395 m_planes[0] = std::move(y_plane);
396 m_planes[1] = std::move(uv_plane);
397 }
398
399 /**
400 * @return Returns the size of y plane of image
401 */
402 size_t y_size() const noexcept;
403 /**
404 * @return Returns the size of uv plane of image.
405 */
406 size_t uv_size() const noexcept;
407
408 using conversion_matrix = std::array<float, 16>;
409
410 // NOTE: Matrix should be transposed to multiply vector-row by matrix.
411 virtual conversion_matrix get_yuv_to_rgb_matrix() const;
412 virtual conversion_matrix get_rgb_to_yuv_matrix() const;
413
414 /**
415 * @return Returns the pixel's value of y plane with coords @p xi and @p yi.
416 */
417 uint8_t y_pixel_at(uint32_t xi, uint32_t yi) const noexcept;
418 /**
419 * @return Returns the pixel's value of uv plane with coords @p xi and @p yi.
420 */
421 uint8_t uv_pixel_at(uint32_t xi, uint32_t yi, uint32_t offset) const noexcept;
422
423 /**
424 * @return Returns the pixel's value of u plane with coords @p xi and @p yi.
425 */
426 uint8_t u_pixel_at(uint32_t xi, uint32_t yi) const noexcept;
427 /**
428 * @return Returns the pixel's value of v plane with coords @p xi and @p yi.
429 */
430 uint8_t v_pixel_at(uint32_t xi, uint32_t yi) const noexcept;
431
432 /**
433 * Construct a new yuv_image_t object with default params.
434 *
435 */
436 yuv_image_t() = default;
437
438 /**
439 * Construct a new yuv_image_t object using move semantics.
440 *
441 */
443 yuv_image_t& operator=(yuv_image_t&& other) = default;
444 /**
445 * Construct a new yuv image t object with copy operation.
446 *
447 */
448 yuv_image_t(const yuv_image_t&) = default;
449 yuv_image_t& operator=(const yuv_image_t&) = default;
450
451 /**
452 * Normalize image data if it is required to be mirrored or camera orientation isn't deg_0.
453 */
454 void normalize_orientation(bnb::transformation const& y_basis, bnb::transformation const& uv_basis, bnb::pixel_rect const& full_roi);
455
456 /**
457 * @return Returns the const reference on yuv_format of image (@see yuv_format_t).
458 */
459 const yuv_format_t& get_yuv_format() const noexcept;
460
461 /**
462 * @return Returns conversion matrix (@see conversion_matrix) for @p standard (@see color_std) and @p range (@see color_range) from yuv to rgb.
463 */
464 static const bnb::yuv_image_t::conversion_matrix& get_yuv_to_rgb_matrix(color_std standard, color_range range);
465 /**
466 * @return Returns conversion matrix (@see conversion_matrix) for @p standard (@see color_std) and @p range (@see color_range) from rgb to yuv.
467 */
468 static const bnb::yuv_image_t::conversion_matrix& get_rgb_to_yuv_matrix(color_std standard, color_range range);
469
470 private:
471 yuv_format_t m_yuv_format;
472
473 //[3] planes is optional for i420 formats
474 color_plane m_planes[3];
475 };
476
477 /// basis is the base basis:
478 /// for y/rgb basis use .basis or get_subchannel_basis_transform(1);
479 /// for uv basis use get_subchannel_basis_transform(2);
481 {
482 public:
483 /**
484 * A method for loading video from @p path with/whithout @p alpha.
485 *
486 * @param path is a full path to downloadable image.
487 * @param alpha is value responcible that image includes alpha channel.
488 * @return Returns full_image_t object with data of image from @p path or nullptr.
489 */
490 static full_image_t load(const std::string& path, bool alpha = false);
491
492 /**
493 * Construct a new full_image_t object with default params.
494 *
495 */
497
498 /**
499 * Construct a new full_image_t object from @p image.
500 *
501 * @param image is a C++ bpc8 image ( @see bpc8_image ) representation.
502 */
503 explicit full_image_t(bpc8_image_t image);
504 /**
505 * Construct a new full_image_t object from @p image.
506 *
507 * @param image is a C++ yuv image ( @see yuv_image ) representation.
508 */
509 explicit full_image_t(yuv_image_t image);
510
511#if BNB_OS_ANDROID
512 /**
513 * Construct a new full_image_t object from @p image.
514 *
515 * @param image is a C++ gpu image ( @see android_gpu_image_t ) representation.
516 */
517 explicit full_image_t(android_gpu_image_t image);
518#endif
519
520 ~full_image_t() override;
521
522 /**
523 * Construct a new full_image_t object using copy operation.
524 *
525 */
527 full_image_t& operator=(const full_image_t&);
528
529 /**
530 * Construct a new full_image_t object using move semantics.
531 *
532 */
534 full_image_t& operator=(full_image_t&& other) noexcept;
535
536 /**
537 * @return Returns image format ( @see image_format ).
538 */
539 image_format get_format() const;
540 /**
541 * @return true if image orientation is landscape and false in another way.
542 */
543 bool is_landscape() const;
544
545 bnb::transformation get_subchannel_basis_transform(float inv_scale = 1.f) const
546 {
547 return basis_transform >> bnb::transformation(1.f / inv_scale, 1.f / inv_scale);
548 }
549
550 /**
551 * @return Returns bassis of image as row-major matrix 3x3 ( @see transformation ).
552 */
554 {
555 using rot_t = transformation::rotate_t;
556 return bnb::transformation(full_roi, full_roi, rot_t::deg_0, get_format().require_mirroring) >> basis_transform;
557 }
558
559 /**
560 * @return Returns the image object if T is yuv or bpc8 image and at the same time yuv or bpc8 image saved.
561 */
562 template<typename T>
563 const T& get_data() const noexcept;
564
565 /**
566 * @return Returns true if T is yuv or bpc8 image and at the same time yuv or bpc8 image saved.
567 */
568 template<typename T>
569 bool has_data() const noexcept;
570
571 /**
572 * @brief Set the field of view ( @p fov ) object.
573 *
574 * @param fov is a field of view in degrees.
575 */
576 void set_fov(float fov);
577
578 /**
579 * Normalize image data if it is required to be mirrored or camera orientation isn't deg_0.
580 */
581 void normalize_orientation();
582
583 unsigned camera_tex_id = 0;
584#if BNB_OS_ANDROID || BNB_OS_EMSCRIPTEN
585 unsigned ext_camera_tex_id = 0; /** external texture for optimisation on android (check this PR: https://bitbucket.org/BanubaLimited/banuba_sdk/pull-requests/4391 )*/
586 unsigned ext_camera_tex_width = 0; /** Width of external texture in pixels. */
587 unsigned ext_camera_tex_height = 0; /** Height of external texture in pixels. */
588#endif
589
590 public:
591 using plane_deleter = std::function<void(uint8_t*)>;
592
593 static full_image_t create_bpc8(
594 const uint8_t* rgb_plane,
595 int32_t rgb_stride,
596 int32_t width,
597 int32_t height,
599 orientation orient,
600 bool mirroring,
601 plane_deleter deleter
602 );
603
604 static full_image_t create_nv12(
605 const uint8_t* y_plane,
606 int32_t y_stride,
607 const uint8_t* uv_plane,
608 int32_t uv_stride,
609 int32_t width,
610 int32_t height,
611 bnb::color_std std,
613 orientation orient,
614 bool mirroring,
615 plane_deleter y_deleter,
616 plane_deleter uv_deleter
617 );
618
619 static full_image_t create_i420(
620 const uint8_t* y_plane,
621 int32_t y_stride,
622 const uint8_t* u_plane,
623 int32_t u_stride,
624 const uint8_t* v_plane,
625 int32_t v_stride,
626 int32_t width,
627 int32_t height,
628 bnb::color_std std,
630 orientation orient,
631 bool mirroring,
632 plane_deleter y_deleter,
633 plane_deleter u_deleter,
634 plane_deleter v_deleter
635 );
636
637 void set_camera_transform(const float in_origin_x, const float in_origin_y, const float in_scale_x, const float in_scale_y);
638
639 /**
640 * Returns the orientation of the image
641 * @return orientation
642 */
644
645 /**
646 * Returns the mirroring of the image. Mirroring applied after orientation
647 * @return mirroring
648 */
649 bool get_mirroring() const;
650
651 /**
652 * Returns format of the image
653 * @return fortmat of the pixel_buffer
654 */
656
657 /**
658 * Returns yuv color standard of the image
659 * @return color standard
660 */
662
663 /**
664 * Returns yuv color range of the image
665 * @return color range
666 */
668
669 /**
670 * Returns count of the planes
671 */
672 uint32_t get_number_of_planes() const;
673
674 /**
675 * Returns the shared pointer of the first plane
676 */
677 uint8_t* get_base_ptr() const;
678
679 /**
680 * Returns the shared pointer to pixel data of the specified plane
681 * @param plane_num plane number. Must be 0 for bpc8, [0..1] for nv12 and [0..2] for i420 images
682 */
683 uint8_t* get_base_ptr_of_plane(uint32_t plane_num) const;
684
685 /**
686 * Returns the pixel size of the first plane
687 */
688 int32_t get_bytes_per_pixel() const;
689
690 /**
691 * Returns the pixel size of the specified plane
692 * @param plane_num plane number. Must be 0 for bpc8, [0..1] for nv12 and [0..2] for i420 images
693 */
694 int32_t get_bytes_per_pixel_of_plane(uint32_t plane_num) const;
695
696 /**
697 * Returns the stride of the first plane
698 */
699 int32_t get_bytes_per_row() const;
700
701 /**
702 * Returns the stride of the specified plane
703 * @param plane_num plane number. Must be 0 for bpc8, [0..1] for nv12 and [0..2] for i420 images
704 */
705 int32_t get_bytes_per_row_of_plane(uint32_t plane_num) const;
706
707 /**
708 * Returns the width of the first plane
709 */
710 int32_t get_width() const;
711
712 /**
713 * Returns the width of the specified plane
714 * @param plane_num plane number. Must be 0 for bpc8, [0..1] for nv12 and [0..2] for i420 images
715 */
716 int32_t get_width_of_plane(uint32_t plane_num) const;
717
718 /**
719 * Returns the height of the first plane
720 */
721 int32_t get_height() const;
722
723 /**
724 * Returns the height of the specified plane
725 * @param plane_num plane number. Must be 0 for bpc8, [0..1] for nv12 and [0..2] for i420 images
726 */
727 int32_t get_height_of_plane(uint32_t plane_num) const;
728
729#if BNB_OS_ANDROID
730 void lock_gpu_data();
731#endif
732
733 private:
734 void init_planes_data();
735 void init_plane(uint32_t plane_num, uint8_t* data, int32_t stride, int32_t width, int32_t height, int32_t pixel_size);
736 void validate_plane_number(uint32_t plane_num) const;
737
738 private:
739 struct plane_data
740 {
741 uint8_t* data{0};
742 int32_t bytes_per_row{0};
743 int32_t width{0};
744 int32_t height{0};
745 int32_t pixel_size{0};
746 }; /* struct plane_data */
747
748 using image_t = std::variant<
749 yuv_image_t,
750 bpc8_image_t
751#if BNB_OS_ANDROID
752 ,
753 android_gpu_image_t
754#endif
755 >;
756 image_t m_image;
757 plane_data m_planes_info[3];
758 uint32_t m_plane_count{0};
759 pixel_buffer_format m_pb_format;
760
761 template<typename T>
762 const T& _get_data() const noexcept;
763
764 template<typename T>
765 bool _has_data() const noexcept;
766
767 void update_basis_transform();
768 };
769
770 template<typename T>
771 inline const T& bnb::full_image_t::get_data() const noexcept
772 {
773 static_assert(std::is_base_of<base_image_t, T>::value, "Type is not image_t");
774 BNB_ASSERT(std::holds_alternative<T>(m_image));
775 return *std::get_if<T>(&m_image);
776 }
777
778 template<typename T>
779 inline bool full_image_t::has_data() const noexcept
780 {
781 static_assert(std::is_base_of<base_image_t, T>::value, "Type is not image_t");
782 return std::holds_alternative<T>(m_image);
783 }
784
785 /** @} */ // endgroup types
786
787} // namespace bnb
A class for representing gl native image that can be locked directly on cpu.
android_gpu_image_t(android_gpu_image_t &&)=default
Construct a new android_gpu_image_t object using move semantics.
android_gpu_image_t(const android_gpu_image_t &)=default
Construct a new android_gpu_image_t object using copy operation.
A base class for *_image_t classes.
base_image_t()=default
Construct a new base_image_t object with default values.
void set_fov(float fov)
Set the field of view.
const image_format & get_format() const
A class for representing bpc8 images as C++ object.
bpc8_image_t(color_plane data, pixel_format_t type, const image_format &format)
Construct a new bpc8_image_t object with user's values.
pixel_format_t get_pixel_format() const noexcept
bpc8_image_t(const bpc8_image_t &)=default
Construct a new bpc8_image_t object using copy operation.
bpc8_image_t()=default
enum value represents pixel format (
bpc8_image_t(bpc8_image_t &&)=default
Construct a new bpc8_image_t object using move semantics.
basis is the base basis: for y/rgb basis use .basis or get_subchannel_basis_transform(1); for uv basi...
int32_t get_bytes_per_row() const
Returns the stride of the first plane.
int32_t get_height_of_plane(uint32_t plane_num) const
Returns the height of the specified plane.
full_image_t(full_image_t &&) noexcept
Construct a new full_image_t object using move semantics.
full_image_t()
Construct a new full_image_t object with default params.
uint8_t * get_base_ptr_of_plane(uint32_t plane_num) const
Returns the shared pointer to pixel data of the specified plane.
static full_image_t load(const std::string &path, bool alpha=false)
A method for loading video from path with/whithout alpha.
uint8_t * get_base_ptr() const
Returns the shared pointer of the first plane.
int32_t get_bytes_per_row_of_plane(uint32_t plane_num) const
Returns the stride of the specified plane.
int32_t get_width_of_plane(uint32_t plane_num) const
Returns the width of the specified plane.
int32_t get_width() const
Returns the width of the first plane.
uint32_t get_number_of_planes() const
Returns count of the planes.
int32_t get_bytes_per_pixel() const
Returns the pixel size of the first plane.
full_image_t(yuv_image_t image)
Construct a new full_image_t object from image.
full_image_t(const full_image_t &)
Construct a new full_image_t object using copy operation.
bool get_mirroring() const
Returns the mirroring of the image.
color_range get_color_range() const
Returns yuv color range of the image.
int32_t get_height() const
Returns the height of the first plane.
bnb::transformation image_basis() const
color_std get_color_standard() const
Returns yuv color standard of the image.
full_image_t(bpc8_image_t image)
Construct a new full_image_t object from image.
orientation get_orientation() const
Returns the orientation of the image.
pixel_buffer_format get_pixel_buffer_format() const
Returns format of the image.
int32_t get_bytes_per_pixel_of_plane(uint32_t plane_num) const
Returns the pixel size of the specified plane.
This class implements affine or perspective 2d transformations Standard usage implies transformation ...
rotate_t
Rotation is counter clockwise(only in standart basis):
Clas represents yuv image as C++ object.
size_t y_size() const noexcept
yuv_image_t(color_plane y_plane, color_plane uv_plane, const image_format &format, const yuv_format_t &yuv_format)
Construct a new yuv_image_t object with user's values (for yuv_nv12 format).
yuv_image_t(color_plane y_plane, color_plane uv_plane, const image_format &format)
Construct a new yuv image t object wioth user's values but with default yuv image format.
const color_plane get_plane() const
yuv_image_t(color_plane y_plane, color_plane u_plane, color_plane v_plane, const image_format &format, const yuv_format_t &yuv_format)
Construct a new yuv image t object with user's values (for yuv_i420 format).
yuv_format
Enum class represents supported yuv formats.
color_std
Enum class represents suppotred color standarts.
camera_orientation
camera image layout is top-left, 0 orientation is portrait, rotation is counterclockwise
color_range
Enum class represents color range.
pixel_buffer_format
bt601 and bt709 - two standards for representing color space that use the same image encoding/decodin...
A structure stores format information about image.
uint32_t size() const noexcept
Struture stores all information about yuv format.