Project import generated by Copybara.
GitOrigin-RevId: 0517756260533d374df93679965ca662d0ec6943
This commit is contained in:
committed by
Hadon Nash
parent
38ee2603a7
commit
ae6be10afe
@@ -27,8 +27,10 @@
|
||||
AVCaptureDepthDataOutput* _depthDataOutput;
|
||||
AVCaptureDevice *_currentDevice;
|
||||
|
||||
matrix_float3x3 _cameraIntrinsicMatrix;
|
||||
OSType _pixelFormatType;
|
||||
BOOL _autoRotateBuffers;
|
||||
BOOL _didReadCameraIntrinsicMatrix;
|
||||
BOOL _setupDone;
|
||||
BOOL _useDepth;
|
||||
BOOL _useCustomOrientation;
|
||||
@@ -229,9 +231,6 @@
|
||||
AVCaptureConnection* connection =
|
||||
[_depthDataOutput connectionWithMediaType:AVMediaTypeDepthData];
|
||||
|
||||
if (connection != nil)
|
||||
connection.enabled = true;
|
||||
|
||||
// Set this when we have a handler.
|
||||
if (self.delegateQueue) {
|
||||
[_depthDataOutput setDelegate:self callbackQueue:self.delegateQueue];
|
||||
@@ -246,6 +245,13 @@
|
||||
connection.videoOrientation = _orientation;
|
||||
}
|
||||
|
||||
{
|
||||
AVCaptureConnection* connection = [_videoDataOutput connectionWithMediaType:AVMediaTypeVideo];
|
||||
if ([connection isCameraIntrinsicMatrixDeliverySupported]) {
|
||||
[connection setCameraIntrinsicMatrixDeliveryEnabled:YES];
|
||||
}
|
||||
}
|
||||
|
||||
_setupDone = YES;
|
||||
}
|
||||
|
||||
@@ -272,6 +278,19 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
} else if ([self.delegate respondsToSelector:@selector(processVideoFrame:fromSource:)]) {
|
||||
[self.delegate processVideoFrame:imageBuffer fromSource:self];
|
||||
}
|
||||
if (!_didReadCameraIntrinsicMatrix) {
|
||||
// Get camera intrinsic matrix.
|
||||
CFTypeRef cameraIntrinsicData =
|
||||
CMGetAttachment(sampleBuffer, kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix, nil);
|
||||
if (cameraIntrinsicData != nil) {
|
||||
CFDataRef cfdr = (CFDataRef)cameraIntrinsicData;
|
||||
matrix_float3x3* intrinsicMatrix = (matrix_float3x3*)(CFDataGetBytePtr(cfdr));
|
||||
if (intrinsicMatrix != nil) {
|
||||
_cameraIntrinsicMatrix = *intrinsicMatrix;
|
||||
}
|
||||
}
|
||||
_didReadCameraIntrinsicMatrix = YES;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - AVCaptureDepthDataOutputDelegate methods
|
||||
|
||||
Reference in New Issue
Block a user