Face Engine SDK  5.25.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SubImage.h
1 #pragma once
2 
3 #include <fsdk/Types/Format.h>
4 #include <fsdk/Types/Rect.h>
5 #include <fsdk/Types/Vector2.h>
6 
7 namespace fsdk {
13  struct SubImage {
14  void* data;
15 
16  int pitch;
17 
18  int x;
19  int y;
20 
21  int width;
22  int height;
23 
25 
28  SubImage() noexcept
29  : data(nullptr)
30  , pitch(0)
31  , x(0)
32  , y(0)
33  , width(0)
34  , height(0) {
35  }
36 
39  template <typename T>
40  T* getDataAs() noexcept {
41  return reinterpret_cast<T*>(data);
42  }
43 
46  template <typename T>
47  const T* getDataAs() const noexcept {
48  return reinterpret_cast<const T*>(data);
49  }
50 
52  Point2i getOrigin() const noexcept {
53  return Point2i(x, y);
54  }
55 
57  Size getSize() const noexcept {
58  return Size(width, height);
59  }
60 
63  Rect getRect() const noexcept {
64  return Rect(x, y, width, height);
65  }
66 
69  bool isValid() const noexcept {
70  return !(data == nullptr) && height > 0 && width > 0 && format.isValid();
71  }
72  };
73 } // namespace fsdk
Size getSize() const noexcept
Definition: SubImage.h:57
Vector2< int > Point2i
Definition: Vector2.h:294
bool isValid() const noexcept
Definition: Format.h:253
Image format.
Definition: Format.h:11
int x
Sub image origin x coordinate.
Definition: SubImage.h:18
int height
Sub image height.
Definition: SubImage.h:22
Format format
Sub image format.
Definition: SubImage.h:24
int pitch
Number of bytes to the next scanline of the sub image.
Definition: SubImage.h:16
int y
Sub image origin y coordinate.
Definition: SubImage.h:19
const T * getDataAs() const noexcept
Definition: SubImage.h:47
Point2i getOrigin() const noexcept
Definition: SubImage.h:52
void * data
Beginning of data sub image data.
Definition: SubImage.h:14
bool isValid() const noexcept
Definition: SubImage.h:69
int width
Sub image width.
Definition: SubImage.h:21
SubImage() noexcept
intializes empty sub image.
Definition: SubImage.h:28
Rect getRect() const noexcept
Definition: SubImage.h:63
T * getDataAs() noexcept
Definition: SubImage.h:40
Sub Image.
Definition: SubImage.h:13
Vector2< int > Size
Definition: Vector2.h:303