iPhone sdk - Use a custom camera - iphone

I'm developing an app that needs to take two pictures in a row. I'm currently using the iPhone camera but :
I would like to NOT have the cancel
button on the bottom left
I would like to NOT have the preview of my picture (with the blue
button "use").
What should I do ? Should I make my own camera ? I couldn't find an easy tutorial for a custom camera with only a "take picture" button...

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];

The easiest way to do it is to use UIImagePickerController with showsCameraControls set to NO and a custom view set in cameraOverlayView; this view can have whatever buttons you need on it. When touched, the button should call takePicture on the image picker, and when you're done just use dismissModalViewControllerAnimated: to dismiss the picker.

Related

save an image immediately after the shutter is presed iOS

The default camera picker behavior available with the methods below is as follows: after the user presses the shutter button they are presented with a preview, and two buttons, Retake and Use.
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
I want instead to mimic the behavior of the iOS default camera tool, that is as soon as an image is taken I'd like it saved and then the shutter becomes available again immediately.
Is this simple to do or do I need to write a custom toolbar using the cameraOverlayView property and a custom method that fires the shutter?
picker.cameraOverlayView = [[UIView alloc] init];
[picker.cameraOverlayView addSubview:bottomToolBar];
Seems that what I needed to do was create an instance of UIView as below and it works.
picker.cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(
0, 0, 640, 960)];
for my experiment I just created a UIButton that targets a method called takePicture. takePicture calls [picker takePicture];which in turn calls imagePickerController:didFinishPickingImage:editingInfo: via delegation, which calls UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);. The picker is not dismissed so I can continue taking pictures.

iphone: displaying small, live camera image in window

I'd like to invoke the camera and display a live image in a small preview window (similar to below) that is embedded in a standard viewController. The code below creates the live reduced camera image, but I cannot see the other objects on the NIB file. Thoughts appreciated.
imagePicker = [[UIImagePickerController alloc] init];
//Setting the control source type as the Camera device.
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
//Camera display is off
imagePicker.showsCameraControls = NO;
imagePicker.navigationBarHidden = YES;
//Picking only the rear camera.
imagePicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
//Turning the camera flash off.
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;
// Make camera view partial screen:
imagePicker.cameraViewTransform = CGAffineTransformScale(imagePicker.cameraViewTransform, 0.5, 0.5);
// add subView
[self.view addSubview:imagePicker.view];
[imagePicker viewWillAppear:YES];
[imagePicker viewDidAppear:YES];
// Show the picker:
[self presentModalViewController:imagePicker animated:YES];
Without running the code, it looks like you are changing the live image, not the size of the view. So the original fullsize view is showing over the top of your other views.
Have you tried using camerOverlayView to overlay the viewcontrollers view on top of the live image?
cameraOverlayView
The custom view to display on top of the default image picker interface.
#property (nonatomic, retain) UIView *cameraOverlayView Discussion You
can use an overlay view to present a custom view hierarchy on top of
the default image picker interface. The image picker layers your
custom overlay view on top of the other image picker views and
positions it relative to the screen coordinates. If you have the
default camera controls set to be visible, incorporate transparency
into your view, or position it to avoid obscuring the underlying
content.

iphone: displaying small, live camera image in window (2)

I am having a great deal of trouble displaying at small, live camera image in a viewController.
I would have expected the following code to show camera display to appear in a 100x 100 window, but it keeps appearing full screen!
Help appreciated.
camera = [[UIImagePickerController alloc] init];
UIView *cameraHUD = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
cameraHUD.userInteractionEnabled = YES;
[camera setSourceType:UIImagePickerControllerSourceTypeCamera];
camera.showsCameraControls = NO;
camera.navigationBarHidden = YES;
camera.toolbarHidden = YES;
camera.cameraOverlayView = cameraHUD;
[self presentModalViewController:camera animated:YES];
[self.view bringSubviewToFront:cameraHUD];
You are present a new view instead of your actual view, so by default a new UIView has contentmode= scale to fill.
You have to add for example something like:
[camera setContentMode:UIViewContentModeTopLeft];
But if you want do something cool you have to add your Camera View as subview.
I hope it can help you
bye ;)

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

This question already has answers here:
Closed 11 years ago.
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?
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];
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

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

I created a simple application using UIImagePickerViewController for capturing from the camera, but I'd like to customize the interface for grabbing from the camera, such as adding some buttons.
UIImagePickerViewController doesn't allow this directly, so how would you create a custom view that allows for displaying the live camera feed and capturing from it?
The easy way is to continue to use UIImagePickerViewController but set showsCameraControls to NO and provide your own user interface using cameraOverlayView.
The more difficult (but more flexible) way is to use the AVFoundation classes (particularly AVCaptureVideoPreviewLayer and AVCaptureStillImageOutput) to construct your own camera.
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];
You need to set the value of showCameraControls to NO and provide your own custom overlay view using the cameraOverlayView.