简体   繁体   中英

How to overlay camera capture image?

I am replacing the part of image by capture image from camera. i need to perform the activity like this app in my application. https://itunes.apple.com/in/app/replace-my-face-funny-girls/id794033892?mt=8

I need a way of how can i take picture from background view with super view image and save the new generated image with merging of both image. Please suggest me solution. The simple work i did

- (void)viewDidLoad {
     [super viewDidLoad];
     self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.delegate = self;
self.picker.allowsEditing = NO;
self.picker.showsCameraControls = NO;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;

CGRect overlayRect = CGRectMake(0, 0, self.imageView.frame.size.width,self.imageView.frame.size.height);

    UIView *overlayView = [[UIView alloc] initWithFrame:overlayRect];
UIImageView *capture_image=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.imageView.frame.size.width,self.imageView.frame.size.height)];

capture_image.image=[UIImage imageNamed:@"1.jpg"];
[overlayView addSubview:capture_image];
[self.picker setCameraOverlayView:overlayView];
[self.navigationController presentViewController:self.picker animated:YES completion:nil];
 }

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:NULL];
   }
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

}

Please also suggest me if there is any repository working like this approach.

About capturing the image: you might want to look at FastttCamera , which allows you to set the camera view to your defined image view and crops the image accordingly.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM