8 #ifndef META_OCEAN_DEVICES_ARKIT_UTILITIES_H
9 #define META_OCEAN_DEVICES_ARKIT_UTILITIES_H
19 #include <ARKit/ARKit.h>
43 template <
typename T = Scalar>
52 template <
typename T = Scalar>
61 template <
typename T = Scalar>
86 template <
typename T = Scalar>
93 if constexpr (std::is_same<T, float>::value)
97 memcpy(matrix.
data() + 0, &simdTransform.columns[0],
sizeof(
float) * 3);
98 memcpy(matrix.
data() + 3, &simdTransform.columns[1],
sizeof(
float) * 3);
99 memcpy(matrix.
data() + 6, &simdTransform.columns[2],
sizeof(
float) * 3);
109 template <
typename T>
112 if constexpr (std::is_same<T, float>::value)
116 memcpy(matrix.
data() + 0, &simdTransform.columns[0],
sizeof(
float) * 4);
117 memcpy(matrix.
data() + 4, &simdTransform.columns[1],
sizeof(
float) * 4);
118 memcpy(matrix.
data() + 8, &simdTransform.columns[2],
sizeof(
float) * 4);
119 memcpy(matrix.
data() + 12, &simdTransform.columns[3],
sizeof(
float) * 4);
129 template <
typename T>
132 if constexpr (std::is_same<T, float>::value)
134 simd_float4x4 simdTransform;
136 memcpy(&simdTransform.columns[0], matrix.
data() + 0,
sizeof(
float) * 4);
137 memcpy(&simdTransform.columns[1], matrix.
data() + 4,
sizeof(
float) * 4);
138 memcpy(&simdTransform.columns[2], matrix.
data() + 8,
sizeof(
float) * 4);
139 memcpy(&simdTransform.columns[3], matrix.
data() + 12,
sizeof(
float) * 4);
141 return simdTransform;
149 template <
typename T>
152 ocean_assert(arFrame !=
nullptr);
154 const SquareMatrixT3<T> cameraIntrinsics = toSquareMatrix3<T>(arFrame.camera.intrinsics);
159 if (width > 0 && height > 0 && !cameraIntrinsics.
isSingular())
161 return std::make_shared<AnyCameraPinholeT<T>>(
PinholeCameraT<T>(cameraIntrinsics, (
unsigned int)(width), (
unsigned int)(height)));
164 ocean_assert(
false &&
"This should never happen");
This class impelements utility functions.
Definition: devices/arkit/Utilities.h:34
static simd_float4x4 fromHomogenousMatrix4(const HomogenousMatrixT4< T > &matrix)
Converts an Ocean HomogenousMatrix4 matrix to an ARKit simd_float4x4 matrix.
Definition: devices/arkit/Utilities.h:130
static HomogenousMatrixT4< T > toHomogenousMatrix4(const simd_float4x4 &simdTransform)
Converts a ARKit simd_float4x4 matrix to an Ocean HomogenousMatrix4 matrix.
Definition: devices/arkit/Utilities.h:110
static Frame extractDepthFrame(const ARFrame *arFrame, Frame *confidenceFrame=nullptr, const bool copyData=true)
Extracts the depth image from an ARKit frame, if existing.
static SquareMatrixT3< T > toSquareMatrix3(const simd_float3x3 &simdTransform)
Converts a ARKit simd_float3x3 matrix to an Ocean SquareMatrix3 matrix.
Definition: devices/arkit/Utilities.h:91
static Frame extractFrame(const ARFrame *arFrame, const bool copyData=true, const FrameType::PixelFormat preferredPixelFormat=FrameType::FORMAT_UNDEFINED)
Extracts the color image from an ARKit frame.
static SharedAnyCameraT< T > extractCameraModel(const ARFrame *arFrame)
Extracts the camera profile of the color image from an ARKit frame.
Definition: devices/arkit/Utilities.h:150
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition: Frame.h:187
This class implements a 4x4 homogeneous transformation matrix using floating point values with the pr...
Definition: HomogenousMatrix4.h:110
const T * data() const
Returns a pointer to the internal values.
Definition: HomogenousMatrix4.h:1843
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
Definition of a pinhole camera model.
Definition: PinholeCamera.h:114
This class implements a 3x3 square matrix.
Definition: SquareMatrix3.h:88
const T * data() const
Returns a pointer to the internal values.
Definition: SquareMatrix3.h:1046
bool isSingular() const
Returns whether this matrix is singular (and thus cannot be inverted).
Definition: SquareMatrix3.h:1341
HomogenousMatrixT4< float > HomogenousMatrixF4
Instantiation of the HomogenousMatrixT4 template class using a float precision float data type.
Definition: HomogenousMatrix4.h:58
std::shared_ptr< AnyCameraT< T > > SharedAnyCameraT
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:53
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15