Post

Replies

Boosts

Views

Activity

Reply to Extrinsic matrix
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.") } }
Dec ’24
Reply to extrinsicMatrix inside AVCameraCalibrationData
Have you configured the constituent devices? Try: In your session configuration: photoOutput.isVirtualDeviceConstituentPhotoDeliveryEnabled = true In your capture photo function: // Enable constituent photo delivery for specific devices let constituentDevices: [AVCaptureDevice] = [ .builtInWideAngleCamera, .builtInUltraWideCamera, ].compactMap { AVCaptureDevice.default($0, for: .video, position: .back) } photoSettings.virtualDeviceConstituentPhotoDeliveryEnabledDevices = constituentDevices photoOutput.capturePhoto(with: photoSettings, delegate: self) In your photoOutput delegate: if let cameraCalibrationData = photo.cameraCalibrationData { let extrinsicMatrix = cameraCalibrationData.extrinsicMatrix print("Extrinsic Matrix: \(extrinsicMatrix)") } This should print two matrices: The primary constituent device -> Identity matrix The secondary constituent device -> [R|t] w.r.t. primary constituent device.
Topic: App & System Services SubTopic: Core OS Tags:
Jan ’25