Setting background image / view in camera view?

Is it possible to set the background for a specific view controller to show live view? If so, is it possible to lead me in the right direction to make this possible?

+5
source share
3 answers

Yes, definitely possible. You can embed a direct camera in a UIView, which you can place anywhere.

Start reading here: Link AVFoundation is your infrastructure

The private class you are looking for is AVCaptureVideoPreviewLayer

What works in tune with AVCaptureSession

And this is a sample project that covers everything you need: AVCam

+8

#import <AVFoundation/AVFoundation.h>

, viewDidLoad:

AVCaptureSession *session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetHigh;

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
[session addInput:input];

AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
newCaptureVideoPreviewLayer.frame = self.view.bounds;

[self.view.layer addSublayer:newCaptureVideoPreviewLayer];

[session startRunning];
+7

, - Apple, AVCam. , AVCaptureVideoPreviewLayer. UIView, "".

, UIView . UIImageView ( , ).

+3

All Articles