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

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

Related

How to display or pass camera capture image into other views in iphone

I am new to i phone programming.Once i capture picture that picture iam displaying in same view,after applying image filter effect i have taken preview button if i click on preview button means same image i want to display in another view but image is not going to next view.how can i do this can any body help me.Inside preview button i have given this below code
Thanks
preview *p=[[preview alloc]init];
p.secondimageviewobject= firstimageviewobject.image;
[self presentModalViewController:p animated:YES];
Well for this kind of method, you would have to create a singleton class like ShareClass.h or if you are really new (and dont know about this) , in the AppDelegate.h wherein you would have to declare a UIImage say UIImage *SavedImage.
Now call this class in the view where you are capturing the image . Then save this captured image in the SavedImage. To share this image you would then call the ShareClass.h class or the AppDelegate.h in the view in which you want to share the image and display it in the UIImageView.
Any clarifications please ask. :)
In the ShareClass.h
UIImage *SavedImage;
#interface ShareClass : NSObject
{
}
In the Class where the image was captured, First import the ShareClass.h, then
imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagepicker.sourceType = UIImagePickerControllerSourceTypeCamera;
SavedImage = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:imagepicker animated:YES completion:NULL];
}
In the Class where the image should be displayed again import the ShareClass.h
UIImageView *DisplayImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:SavedImage]];
DisplayImage.frame=CGRectMake(0, 0, 20, 20);
[self.view addSubView:DisplayImage];

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 (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 ;)

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.

iPhone sdk - Use a custom camera

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.