Shakti
Shakti

Reputation: 1959

Still Image using AVCaptureDevice with overlay image

I am developing an iPhone app in which I am capturing the live video.

I have added the AVCaptureVideoPreviewLayer to the self.view.layer as sublayer. [self.view.layer addSublayer: self.prevLayer];

On the same self.view I have added an image as subview. [self.view addSubView:image];

Now what I want is to capture an image from the live video but the image should also come into that picture as it looks on the screen. I have tried to take the screen shot but it capture only the image and not the live video image. Can any body please help me on this. Thanks in advance.

Upvotes: 0

Views: 576

Answers (1)

The iOSDev
The iOSDev

Reputation: 5267

hi this will help you as it works for me

- (void)didTakePicture:(UIImage *)picture
{
    UIImage *frm = self.overlayViewController.imgOverlay.image;
    NSLog(@"width %f height %f",picture.size.width,picture.size.height);
    UIGraphicsBeginImageContext(picture.size);
    [picture drawAtPoint:CGPointMake(0,0)];
    [frm drawInRect:CGRectMake(0, 0, picture.size.width, picture.size.height)];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSLog(@"view %@",viewImage.debugDescription);
    [self.capturedImages addObject:viewImage];
}

Upvotes: 1

Related Questions