iPhone custom camera overlay (plus image processing) : how-to

21,763

Solution 1

Yes, create a UIImagePickerController from code, adjust its properties, add an overlay onto it, and with you controller, control whatever you want on that overlay : custom controls, overlaying images, etc...

That gives something like this :

self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;

// Insert the overlay
self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
self.overlay.pickerReference = self.picker;
self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;

[self presentModalViewController:self.picker animated:NO];

OverlayViewController is the controller that you must write to control everything you add onto the overlay.

pickerReference is a property you can keep to send orders to the camera. For example, you could call the following from an IBAction coming from a UIButton placed onto the overlay :

[self.pickerReference takePicture];

Solution 2

For image processing (regarding our discuss in the comments), you could take a look at this :

http://code.google.com/p/simple-iphone-image-processing/

http://sourceforge.net/projects/photoshopframew/

https://github.com/esilverberg/ios-image-filters

http://developer.apple.com/library/ios/#samplecode/QuartzDemo/Introduction/Intro.html

http://cocoawithlove.com/2011/01/advanced-drawing-using-appkit.html

Share:
21,763
Fred Collins
Author by

Fred Collins

Updated on November 10, 2020

Comments

  • Fred Collins
    Fred Collins over 3 years

    Possible Duplicate:
    How do you create a custom camera view, instead of UIImagePickerViewController?

    Many image sharing apps available today from the App Store use a custom camera instead of the standard camera picker provided by Apple.

    Does anyone know any tutorials or tips for creating a custom camera?

  • Fred Collins
    Fred Collins over 12 years
    Thank you for the answer. I've understood but only a question: how can I make a shot button that when is pressed it stops the image capturing from the camera? (in few words, how can I implement a 'take a picture' button. Thanks guy.
  • Oliver
    Oliver over 12 years
    @FredCollins: put a button on the overlay, link it with an IBAction and into the IBAction call [self.pickerReference takePicture]; (check the method name in Apple doc, I think it's this one)
  • Fred Collins
    Fred Collins over 12 years
    Thanks Oliver! Have you also any ideas on how to implement the effects to apply to the images? If when I'll try to implementing this I'll have some trouble I'll write here. You're very kind!
  • Fred Collins
    Fred Collins over 12 years
    Please re-read my last comments. I've just updated it.
  • Oliver
    Oliver over 12 years
    @FredCollins : Applying effect starts with the delgate method - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info to get the taken image. After that, you have an infinite number of effects you can apply so... It's up to you to do what you want.
  • Fred Collins
    Fred Collins over 12 years
    Yes Oliver but for the effect I need to use OpenGL, right?
  • Oliver
    Oliver over 12 years
    @FredCollins : That really depends. OpenGL is for 3D Effects and/or some complex effects. But for basic things, CoreGraphics could be enough. Here we enter in image processing and once you exactly know what kind of effect you want, you should open another question. Also think about looking to the other StackExchange sites. Some talks about image processing.
  • Fred Collins
    Fred Collins over 12 years
    Thanks for all Oliver. God bless you for your kindness. :)
  • Oliver
    Oliver over 12 years
    @FredCollins : You're welcome