libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
Supporting cameras in Linux since 2019
transform.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2020, Raspberry Pi (Trading) Limited
4  *
5  * transform.h - 2D plane transforms
6  */
7 
8 #ifndef __LIBCAMERA_TRANSFORM_H__
9 #define __LIBCAMERA_TRANSFORM_H__
10 
11 #include <string>
12 
13 namespace libcamera {
14 
15 enum class Transform : int {
16  Identity = 0,
17  Rot0 = Identity,
18  HFlip = 1,
19  VFlip = 2,
20  HVFlip = HFlip | VFlip,
21  Rot180 = HVFlip,
22  Transpose = 4,
23  Rot270 = HFlip | Transpose,
24  Rot90 = VFlip | Transpose,
25  Rot180Transpose = HFlip | VFlip | Transpose
26 };
27 
29 {
30  return static_cast<Transform>(static_cast<int>(t0) & static_cast<int>(t1));
31 }
32 
34 {
35  return static_cast<Transform>(static_cast<int>(t0) | static_cast<int>(t1));
36 }
37 
39 {
40  return static_cast<Transform>(static_cast<int>(t0) ^ static_cast<int>(t1));
41 }
42 
44 {
45  return t0 = t0 & t1;
46 }
47 
49 {
50  return t0 = t0 | t1;
51 }
52 
54 {
55  return t0 = t0 ^ t1;
56 }
57 
59 
61 
62 constexpr bool operator!(Transform t)
63 {
64  return t == Transform::Identity;
65 }
66 
68 {
69  return static_cast<Transform>(~static_cast<int>(t) & 7);
70 }
71 
72 Transform transformFromRotation(int angle, bool *success = nullptr);
73 
74 const char *transformToString(Transform t);
75 
76 } /* namespace libcamera */
77 
78 #endif /* __LIBCAMERA_TRANSFORM_H__ */
constexpr Transform & operator &=(Transform &t0, Transform t1)
Apply bitwise AND-assignment operator between the bits in the two transforms.
Definition: transform.h:43
Transform transformFromRotation(int angle, bool *success=nullptr)
Return the transform representing a rotation of the given angle clockwise.
Definition: transform.cpp:276
constexpr Transform & operator|=(Transform &t0, Transform t1)
Apply bitwise OR-assignment operator between the bits in the two transforms.
Definition: transform.h:48
constexpr Transform operator|(Transform t0, Transform t1)
Apply bitwise OR operator between the bits in the two transforms.
Definition: transform.h:33
Transform operator*(Transform t0, Transform t1)
Compose two transforms together.
Definition: transform.cpp:207
constexpr Transform operator &(Transform t0, Transform t1)
Apply bitwise AND operator between the bits in the two transforms.
Definition: transform.h:28
Top-level libcamera namespace.
Definition: bound_method.h:15
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:15
constexpr Transform operator~(Transform t)
Return the transform with all the bits inverted individually.
Definition: transform.h:67
constexpr bool operator!(Transform t)
Return true if the transform is the Identity, otherwise false
Definition: transform.h:62
constexpr Transform operator^(Transform t0, Transform t1)
Apply bitwise XOR operator between the bits in the two transforms.
Definition: transform.h:38
constexpr Transform & operator^=(Transform &t0, Transform t1)
Apply bitwise XOR-assignment operator between the bits in the two transforms.
Definition: transform.h:53
const char * transformToString(Transform t)
Return a character string describing the transform.
Definition: transform.cpp:306
Transform operator-(Transform t)
Invert a transform.
Definition: transform.cpp:233