libcamera v0.3.2 Supporting cameras in Linux since 2019

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