Tôi đang cố gắng chụp khung ở kích thước cụ thể từ AVCaptureVideoDataOutput
bằng cách đặt kCVPixelBufferWidthKey
& kCVPixelBufferHeightKey
.
Vấn đề là chiều rộng và chiều cao đệm không bao giờ thay đổi, họ luôn trở lại 852x640AVCaptureVideoDataOutput và thiết lập kCVPixelBufferWidthKey & kCVPixelBufferHeightKey
Đây là tôi mã:
// Add the video frame output
self.videoOutput = [[AVCaptureVideoDataOutput alloc] init];
[videoOutput setAlwaysDiscardsLateVideoFrames:YES];
// Use RGB frames instead of YUV to ease color processing
[videoOutput setVideoSettings:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat:320.0], (id)kCVPixelBufferWidthKey,
[NSNumber numberWithFloat:320.0], (id)kCVPixelBufferHeightKey,
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA],(id)kCVPixelBufferPixelFormatTypeKey,
nil]];
[videoOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
EDIT: từ iOS AVCaptureOutput.h: Hiện nay, chìa khóa chỉ được hỗ trợ là kCVPixelBufferPixelFormatTypeKey.
có ai biết phương pháp làm việc thiết lập chiều rộng/chiều cao đệm đầu ra không?
Tôi ước nó đã hoạt động mặc dù tôi cũng có thể sử dụng nó. :-) –