2017-06-06 9 views
0

カメラプレビュービューレイヤーにpng画像(青色の矩形)を追加したいとします。IOSカメラのプレビュー画層で1つの画像をマージするにはどうすればよいですか?

-(void) captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection 
{ 
    UIImage * image1 = [self ImageFromSampleBuffer:sampleBuffer]; 
    NSData *imageData1; 
} 

この機能はプレビュー画像をUIImageviewに設定する機能です。

-(void) SetPreview 
{ 


    session =[[AVCaptureSession alloc]init]; 
    session.sessionPreset = AVCaptureSessionPresetPhoto; 

    //Add device; 
    AVCaptureDevice*device = nil; 
    device = [self cameraWithPosition:AVCaptureDevicePositionFront]; 

    AVCaptureDeviceInput*input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil]; 

    if(!input) 
    { 
     NSLog(@"NO Input"); 
    } 

    [session addInput:input]; 

    //Output 

    output = [[AVCaptureVideoDataOutput alloc] init]; 
    [session addOutput:output]; 
    output.videoSettings = @{(NSString*)kCVPixelBufferPixelFormatTypeKey:@(kCVPixelFormatType_32BGRA)}; 

    //Preview layer 
    AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; 

    cameraView = self.view; 

    previewLayer.frame =CGRectMake(cameraView.bounds.origin.x+5, cameraView.bounds.origin.y+5, cameraView.bounds.size.width - 10, cameraView.bounds.size.height-10); 

    previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; 


    [_vImage.layer addSublayer:previewLayer]; 
    timer =[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(snapshot) userInfo:nil repeats:YES]; 

    [session startRunning]; 


} 

この機能はどのように実装できますか?

enter image description here

答えて

0

enter image description here

私は、ビューの "戻るIMG" を入れて、この問題を解決しました。

関連する問題