Hi guys,
I have found a the problem in my code.
I realized that I was converting the Data matrix into a 4x4 for some weird reason.
While writing this question I realized that the correct values were there but somehow scrambled (due to the 4x4 convertion)
The following code works perfect:
// Get the extrinsic matrix from ultra-wide to wide camera
if let wideCameraDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) {
if let extrinsicMatrixData = AVCaptureDevice.extrinsicMatrix(from: ultraWideCameraDevice, to: wideCameraDevice) {
// Convert the Data to matrix_float4x3
extrinsicMatrixData.withUnsafeBytes { (pointer: UnsafeRawBufferPointer) in
if let baseAddress = pointer.baseAddress {
// Access the matrix as a matrix_float4x3
let matrix = baseAddress.bindMemory(to: matrix_float4x3.self, capacity: 1).pointee
// Print the matrix row by row
print("Extrinsic Matrix:")
print("[\(matrix.columns.0.x), \(matrix.columns.1.x), \(matrix.columns.2.x), \(matrix.columns.3.x)]")
print("[\(matrix.columns.0.y), \(matrix.columns.1.y), \(matrix.columns.2.y), \(matrix.columns.3.y)]")
print("[\(matrix.columns.0.z), \(matrix.columns.1.z), \(matrix.columns.2.z), \(matrix.columns.3.z)]")
}
}
} else {
print("Failed to retrieve the extrinsic matrix.")
}
}