Regarding uiimagepickercontroller - iphone

In my application i have to upload a image and that image is taken from the ipad camera, now my query is when i choose the button "TakePicture" the cameraview opens can I resize the cameraview which captures the image.
Here is my code.
- (void) takePicture {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
}

Dont think so, that is an internal ui call,
You might be able to put some custom overlay on the camera view as quite a few other apps do, but to resize the internal camera view is not what apple wants us to do.
But then again, it would be a nice to have as we can use that for some really cool effects!

Do you mean view itself? No, the size couldn't be changed. If you mean size of taken/chosen image, user will be allowed to do resizing if you set allowsEditing to YES.

Related

Imagepicker for AVCaptureSession

I implemented code for taking picture using AVCaptureSession. And i have button to pick image from Gallery. So, i need to use UIImagePickerController for picking image from gallery.
Is it possible to use UIImagepicker for picking Gallery and AVCaptureSession for taking picture. If i use this inside same app, appstore reject app or not?
Sure. You want to create your UIImagePickerController with a sourceType of UIImagePickerControllerSourceTypePhotoLibrary:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
I can't imagine that Apple would reject you for doing this in the same app that you're using AVCaptureSession - they're providing these classes to do exactly what you're proposing, after all.

automatically start FrontCamera and capture image

I want to make a camera application in which i want to start front camera automatically and capture image without user interaction. thanks in advance.
In addition to Robin's answer, add the following statements (before presentModalViewController:) to ensure that if the device has a front camera, that should be opened by default
if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]){
self.imagePicker.sourceType=UIImagePickerControllerSourceTypeCamera; //skipping this was crashing my app with some ** Assertion failure.
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
}
Please note, if your app is compatible with devices running OS older than 4.0, you will have to put in conditional checks since cameraDevice property is available only in iOS 4.0 and later
The UIImagePickerController is a higher level abstraction to the camera. Have a look at AVFoundation examples to see how to get to the camera more directly.
The documentation for AVFoundation is here.
To do it while still using the picker, have a look at.1317978. Look around for some examples using UIGetScreenImage(). It used to be a private API but I think it is now allowed.
You might also want to look around at some examples concerning custom overlay, like this one.
I dont know how much you know about objective-c or iphone development. so I will tell how to take photos in your iphone app.
First you should get your self aquatinted with UIImagePickerController class
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
here is some examples for the same from apple
http://developer.apple.com/library/ios/samplecode/PhotoLocations/
http://developer.apple.com/library/ios/samplecode/PrintPhoto/
http://developer.apple.com/library/ios/samplecode/PhotoPicker/
http://developer.apple.com/library/ios/samplecode/iPhoneCoreDataRecipes/
and next here is the code that will help you take the pics if you just place it in your .m file
- (void)selectPhotos
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
imageView.image = image;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
now get started.

iOS4: UIImagePickerController behaving weirdly when presented modally

I'm trying to present a UIImagePickerController from a UITableViewController subclass using the following code:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
if(library)
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
else
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentModalViewController:picker animated:YES];
[picker release];
If I create a brand new project and throw this code in, it works absolutely fine. However, in this project, for some reason, the UIImagePickerController's view appears as a blank white screen if I try to show the Photo Library, or shows the camera view but with no camera controls if I try to show the Camera.
Is there anything in a UITableViewController subclass that would be causing this? I get complaints about two-stage animations as well, but from what I've been able to find, this is an issue with Apple's code.
For some reason, changing the PRODUCT_NAME in the Info.plist (something which I was going to do anyway but hadn't gotten around to until just now) fixed this issue. I have absolutely no idea why, but I'm going to assume it was some obscure bug in the iPhone SDK.

Skip UIImagePickerController Preview View?

I'm using UIImagePickerController to allow my user to select a video from the asset library.
When the UIImagePickerController is initially displayed, it shows thumbnails for the various movies that have been recorded.
Once the user selects a movie, it displays a "preview" view which allows them to playback and potentially edit the selected movie.
Is there any way to avoid displaying this view and instead return the movie that was selected on the thumbnail screen?
Here is the code I'm using:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePicker.allowsEditing = NO;
[self presentModalViewController:imagePicker animated:YES];
I haven't tested this myself, though I'll be attempting this in my own application shortly. If you take a look at the UIImagePickerController showsCameraControls documentation, it alludes to the fact that if you eliminate the camera controls you can take as many photos as you want.
So theoretically if you set showsCameraControls to NO, and assign your own cameraOverlayView UIView to let the user take a photo, you can dismiss the image picker without the preview view from showing.
Perhaps that helps. You could listen with the NSNotificationCenter on #"_UIImagePickerControllerUserDidCaptureItem". If the user select the item, you could dismiss the imagePicker and do your thumbnail stuff.
I had a similar issue, to remove an overlay on the preview view and could solve it with this approach.

Severe memory problems with UIImagePickerController using Camera

I've noticed that when I load a UIImagePickerController and I take a picture with it, didReceiveMemoryWarning is called. Also, in Instruments, there is a significant memory leak (not by me, I swear!). I've heard that this is a problem with UIImagePickerController but, I'm not sure how to fix it. Here is my implementation of UIImagePickerController.
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; // Create the imagePicker
imagePicker.delegate = self;
imagePicker.allowsEditing = YES; // Allow editing of the images
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
Any ideas? I really don't want to sacrifice such a useful feature.
Do you have the same leak with the SDK 3.2?
I had a similar leak when using the UIImagePickerController to take a video.
When I found that the leak was fixed in 3.2, I decided to set the minimum OS version of my application to 3.2.
About the memory warning, it's to be expected. The camera needs a lot of memory to do its job, and is simply requesting as much memory as possible from your app by sending a didReceiveMemoryWarning message.
You need to rescale the image to a smaller size, say 320x460. Then it will run successfully.