libcamera  v0.2.0+85-1c5830a9
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 Ltd
4  *
5  * transform.h - 2D plane transforms
6  */
7 
8 #pragma once
9 
10 #include <string>
11 
12 namespace libcamera {
13 
14 enum class Orientation;
15 
16 enum class Transform : int {
17  Identity = 0,
18  Rot0 = Identity,
19  HFlip = 1,
20  VFlip = 2,
21  HVFlip = HFlip | VFlip,
22  Rot180 = HVFlip,
23  Transpose = 4,
24  Rot270 = HFlip | Transpose,
25  Rot90 = VFlip | Transpose,
26  Rot180Transpose = HFlip | VFlip | Transpose
27 };
28 
30 {
31  return static_cast<Transform>(static_cast<int>(t0) & static_cast<int>(t1));
32 }
33 
35 {
36  return static_cast<Transform>(static_cast<int>(t0) | static_cast<int>(t1));
37 }
38 
40 {
41  return static_cast<Transform>(static_cast<int>(t0) ^ static_cast<int>(t1));
42 }
43 
45 {
46  return t0 = t0 & t1;
47 }
48 
50 {
51  return t0 = t0 | t1;
52 }
53 
55 {
56  return t0 = t0 ^ t1;
57 }
58 
60 
62 
63 constexpr bool operator!(Transform t)
64 {
65  return t == Transform::Identity;
66 }
67 
69 {
70  return static_cast<Transform>(~static_cast<int>(t) & 7);
71 }
72 
73 Transform transformFromRotation(int angle, bool *success = nullptr);
74 
75 Transform operator/(const Orientation &o1, const Orientation &o2);
76 Orientation operator*(const Orientation &o, const Transform &t);
77 
78 const char *transformToString(Transform t);
79 
80 } /* namespace libcamera */
constexpr Transform & operator &=(Transform &t0, Transform t1)
Apply bitwise AND-assignment operator between the bits in the two transforms.
Definition: transform.h:44
Transform transformFromRotation(int angle, bool *success=nullptr)
Return the transform representing a rotation of the given angle clockwise.
Definition: transform.cpp:278
constexpr Transform & operator|=(Transform &t0, Transform t1)
Apply bitwise OR-assignment operator between the bits in the two transforms.
Definition: transform.h:49
constexpr Transform operator|(Transform t0, Transform t1)
Apply bitwise OR operator between the bits in the two transforms.
Definition: transform.h:34
constexpr Transform operator &(Transform t0, Transform t1)
Apply bitwise AND operator between the bits in the two transforms.
Definition: transform.h:29
Top-level libcamera namespace.
Definition: backtrace.h:17
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:16
Transform operator/(const Orientation &o1, const Orientation &o2)
Return the Transform that applied to o2 gives o1.
Definition: transform.cpp:347
constexpr Transform operator~(Transform t)
Return the transform with all the bits inverted individually.
Definition: transform.h:68
Orientation
The image orientation in a memory buffer.
Definition: orientation.h:14
constexpr bool operator!(Transform t)
Return true if the transform is the Identity, otherwise false
Definition: transform.h:63
Transform operator*(Transform t0, Transform t1)
Compose two transforms by applying t0 first then t1.
Definition: transform.cpp:209
constexpr Transform operator^(Transform t0, Transform t1)
Apply bitwise XOR operator between the bits in the two transforms.
Definition: transform.h:39
constexpr Transform & operator^=(Transform &t0, Transform t1)
Apply bitwise XOR-assignment operator between the bits in the two transforms.
Definition: transform.h:54
const char * transformToString(Transform t)
Return a character string describing the transform.
Definition: transform.cpp:393
Transform operator-(Transform t)
Invert a transform.
Definition: transform.cpp:235