我需要从Appstore获得与EpocCam应用程序类似的东西,但问题是我不知道从哪里开始,必须遵循哪些步骤(我在网上搜索,我发现它是模糊的。)建议朝这个方向发展?
答案 0 :(得分:0)
从实现的角度来看,实时流可以分解为以下子任务:
没有内置的方法可以做到这一点。您需要实施AVCaptureSession。最简单的实现会将每个捕获的帧发送到服务器。
示例:
// Create input.
AVCaptureDevice *camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:camera error:nil];
// Create data output.
AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[output setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
// Create capture session and set input and output.
AVCaptureSession *captureSession = [[[AVCaptureSession alloc] init] autorelease];
[captureSession addInput:input];
[captureSession addOutput:output];
// Create a preview layer.
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
previewLayer.frame = view.bounds;
[view.layer addSublayer:previewLayer];
// Start capturing the video.
[captureSession startRunning];
委托回电:
- (void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
// Get captured frame.
CVImageBufferRef buffer = CMSampleBufferGetImageBuffer(sampleBuffer);
}