Camera Preview inside Window with iPhone - iphone

I can launch a camera capture with UIImagePicker but capture process is done in another view. Is it possible to 'embed' camera preview into the application window?
What I use is:
UIImagePickerController *picker;
picker = [[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsImageEditing = YES;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];

The closest you can come is to add a cameraOverlayView to the camera view and put a 'frame' around the picture. However, this will crop, rather than scale, the viewfinder.

You can add the preview as a subview like this:
[self.view addSubview:picker.view];
[picker viewWillAppear:YES];
[picker viewDidAppear:YES];

Related

ARToolkit, UIImagePickerController & cameraOverlayView: How to take a picture?

I am developing an Augmented Reality app for iPhone with ARToolkit. Now I want to include its functionality in a main app, with a button which throws an 'AR View', in order to be able to take a picture with the 3D model on it.
I am using UIImagePickerController with cameraOverlayView to add the ARViewController view to the camera view, as an overlay, but it does not show it. Here it is the code:
-(IBAction)Switch2AR:(id)sender{
ARController = [[ARViewController alloc] init];
[ARController loadView];
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
picker.showsCameraControls = YES;
picker.cameraOverlayView = ARController.view;
//[ARController.view addSubview: picker.view];
//[picker.view addSubview: ARController.view];
//[picker viewWillAppear:YES];
//[picker viewDidAppear:YES];
//[ARController viewWillAppear:YES];
//[ARController viewDidAppear:YES];
[self presentModalViewController:picker animated:YES];
[ARController release];
}
I also tried to add the UIImagePickerController view as a subview of the ARViewController view, but does not work since the camera modal view 'hides' the AR view. Also ARViewController view as UIImagePickerController subview.
The problem is that I cannot overlay my ARView and the camera view in any way I tried
Thanks in advance
Just change
picker.showsCameraControls = YES;
to
picker.showsCameraControls = NO;
and it should work.

UIIMagePickerController don't automatically dismiss picker

How do you prevent the UIImagePickerController from automatically dismissing the camera after a picture is taken?
You set the picker to allowsImageEditing to be YES before you present it.
picker.allowsImageEditing = YES;
picker.delegate = self;
[self presentModalViewController:picker animated:YES];

ipad:how to use uiimagepickercontroller move and scale image

in my xib there is a choose image from photolibrary button, below is the touch up inside event
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.allowsImageEditing = YES;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:CGRectMake(0, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popoverController = popover;
[popover release];
[picker release];
}
but when i choose one image from photo albums i cant move or scale the image, it means when i move the image, it always move back to center automatically.
can anyone give me some help? thanks a lot
It sounds like you want functionality in the UIScrollView range. I would download the WWDC 10 video based on UIScrollViews to see how a zooming image is implemented well.
Good luck!

iphone how to go to the image gallery after taking photo through Xcode

Hi all I am implementing the following code to take a photo through my application
[[[UIApplication sharedApplication] keyWindow] setRootViewController:picker];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:NO];
Can anyone tel me How I can go to the photo gallery after the user takes the photo and not return to the application.
i think you might want to try this
How to open camera while I click the UIButton in iPhone?
or i really didn't get the question
Edit:
Well you can use the same code with UIImagePickerControllerSourcePhotoLibrary after taking the pic from camera. I mean call this Function with UIImagePickerControllerSourcePhotoLibrary then it will take you to photo Library and then back again to your application.
UIImagePickerControllerSourcePhotoLibrary
If you want to shoot a picure use this code -
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.allowsImageEditing = YES;
[[self navigationController] presentModalViewController:picker animated:YES];
If you want to go to photo gallery and wants to select a photo from there use this code -
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsImageEditing = YES;
[[self navigationController] presentModalViewController:picker animated:YES];
Notice the difference between the picker's sourceType

dismiss ModalViewController from another viewcontroller in iPhone

The new 3.1 sdk allows for the UIImagepickerController to hide the camera controls and use your own controls via cameraOverlay view. So, I implemented the overlay view through another Viewcontroller:
CameraViewController *cameraController = [[CameraViewController alloc] initWithNibName:#"CameraViewController" bundle:nil];
self.cameraviewController = cameraController;
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.cameraOverlayView = cameraviewController.view;
picker.showsCameraControls = NO;
[self presentModalViewController:picker animated:YES];
[cameraController release];
[picker release];
The cameraviewController.view has the Cancel button. The problem I'm facing is how to dismiss the Modal view with that cancel button. I haven't found a way of referencing the controller which called the Modalview.
Many thanks in advance
need to add cameraController.delegate = self; and setup the delegate protocol in CameraViewController.