UIImagePickerController with Custom OverlayView Crash on iPod iOS5, iPhone4S iOS5 - iphone

I'm using following coding to shoot a video, I'm facing a strange issue in this. Below coding are working perfectly fine with iPad iOS6, iPad iOS5, iPhone iOS6 devices but crashing on iPod iOS5, iPhone4S iOS5.
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = YES;
cameraUI.delegate = self.objVideoAnalysis;
cameraUI.showsCameraControls = NO;
cameraUI.navigationBarHidden = YES;
cameraUI.toolbarHidden = YES;
// Displays a control that allows the user to choose movie capture
cameraUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
cameraUI.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
//cameraUI.videoQuality = UIImagePickerControllerQualityTypeHigh;
//set Overlay View for recording
VideoRecorderOverlayView *objOverlay = [[VideoRecorderOverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
objOverlay.objVideoRecorder = cameraUI;
cameraUI.cameraOverlayView = objOverlay;
[objOverlay release];
[self presentModalViewController:cameraUI animated: YES];
Thanks in advance,
Ganesh.

Related

UIImagePickerController in iOS7

How to get UIImagePickerController in iOS 7 Look like the same screen that show in the attached screen shot with out using Overlay Controller.
This is the code am using for picker controller.
UIImagePickerController *eImagePickerController = [[UIImagePickerController alloc] init];
eImagePickerController.delegate=self;
eImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
eImagePickerController.cameraDevice = UIImagePickerControllerSourceTypeCamera;
eImagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
eImagePickerController.showsCameraControls = YES;
eImagePickerController.navigationBarHidden = NO;
eImagePickerController.cameraDevice=UIImagePickerControllerCameraDeviceRear;
eImagePickerController.wantsFullScreenLayout = NO;
eImagePickerController.cameraViewTransform = CGAffineTransformScale(eImagePickerController.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
[self presentViewController:eImagePickerController animated:YES completion:nil];
The issue is shown in attached screenshot
The following code will present the UIImagePickerController in a way that resembles the screenshot given.
UIImagePickerController *eImagePickerController = [[UIImagePickerController alloc] init];
eImagePickerController.delegate = self;
eImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
eImagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
eImagePickerController.cameraDevice= UIImagePickerControllerCameraDeviceRear;
eImagePickerController.showsCameraControls = YES;
eImagePickerController.navigationBarHidden = NO;
[self presentViewController:eImagePickerController animated:YES completion:nil];
Just make sure that you hide the status bar or it will be displayed in the UIImagePickerController as well.

crop the recorded video - Objective c

I'm developing an app which will record the video with the specified square frame, just same like instagram. But when I record using UIImagePickerController it will record with the full screen, and now I want to crop the video to the square. Please help me to find how to crop the video with some specified frame. Thanks in Advance!!
You can capture photo in your defined frame
Checkout following snippet
UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init];
mediaUI.sourceType = UIImagePickerControllerSourceTypeCamera;
mediaUI.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil] ;
mediaUI.delegate = self;
mediaUI.allowsEditing = YES;
mediaUI.view.frame = CGRectMake(5, 5, 310, 280);
[self.view addSubview:mediaUI];

how to implement camera view layer for qr code scanning iphone application?

I am writing iphone application where i want qr code scanning.I have QR code library to scan QR code. And now I want to give QR code scanning interface to my iPhone application.
In Android I could achieve this using SurfaceView that is the view where we can show camera frames. Is there anything available in iPhone equilvalent to surfaceview in Android? If so how to do this. Please give me a tutorial or example links.
- (IBAction)TakePicture:(id)sender {
// Create image picker controller
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
// Set source to the camera
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Delegate is self
imagePicker.delegate = self;
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
// Insert the overlay:
imagePicker.cameraOverlayView = overlay;
// Allow editing of image ?
imagePicker.allowsImageEditing = YES;
[imagePicker setCameraDevice:
UIImagePickerControllerCameraDeviceFront];
[imagePicker setAllowsEditing:YES];
imagePicker.showsCameraControls=YES;
imagePicker.navigationBarHidden=YES;
imagePicker.toolbarHidden=YES;
imagePicker.wantsFullScreenLayout=YES;
self.library = [[ALAssetsLibrary alloc] init];
// Show image picker
[self presentModalViewController:imagePicker animated:YES];
}
Make a UIView class and add this code
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
// Clear the background of the overlay:
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
// Load the image to show in the overlay:
UIImage *overlayGraphic = [UIImage imageNamed:#"overlaygraphic.png"];
UIImageView *overlayGraphicView = [[UIImageView alloc] initWithImage:overlayGraphic];
overlayGraphicView.frame = CGRectMake(30, 100, 260, 200);
[self addSubview:overlayGraphicView];
}
return self;
}
You can also refer to this link: http://www.musicalgeometry.com/?p=821
QR code detection is readily available in iOS since iOS 7, the trick is to tell a AVCaptureMetadataOutput instance to detect objects with type AVMetadataObjectTypeQRCode.
Live camera preview (with access to pixels if you still want to use that) is in iOS for a long time, easiest with AVCaptureVideoPreviewLayer.
See here for an example http://www.appcoda.com/qr-code-reader-swift/

How to store the time period(duration) of a captured video in iPhone?

Thanks to all for responding to the questions which I posted.
I got one problem that is, while capturing the video in the iPhone, I don't know how to store the time period (duration) that I captured video with iPhone. Can any one solve my problem.
I am using the following code for capturing.
-(void) RecordVideoWithCamera
{
printf("\n Hai I am in record vedio with camera -============");
[self startCameraPickerFromViewController:self usingDelegate:self];
}
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *picker = [[[UIImagePickerController alloc] init]autorelease];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
picker.delegate = self;
picker.showsCameraControls=YES;
picker.allowsEditing = NO;
UIView *overlayView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
picker.cameraOverlayView = overlayView;
[controller presentModalViewController:picker animated:YES];
}
return YES;
}
Thanking you,
Madan Mohan.
I think you should check CMTime struct.

Image Move & Resize not working when using a custom camera overlay iPhone SDK 3.1+

I used to use the old-school method of adding an overlay to the camera screen, and that worked fine. However, since 3.1 came out, Apple is insisting that I use the API to add an overlay. I quickly got the overlay to work, but it seems that if I use the custom overlay, then the move & resize screen is not responsive, I can only use or retake, can't actually resize & move. The code I am using is below. I have tried several variations, but the only thing that actually enables the move & resize is to remove the line that adds the custom overlay view.
Any ideas?
UIImage *image = [UIImage imageNamed:#"camera-template-long.png"];
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] ;
imgView.image = image;
UIView *overlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
overlayView.opaque = NO;
[overlayView addSubview:imgView];
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
picker.cameraOverlayView = overlayView;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentModalViewController:picker animated:YES];
Set both allowsEditing/showsCameraControls properties to NO, prepare your original view to cameraOverlayView, and use takePicture method.
Then, imagePickerController:didFinishPickingMediaWithInfo: will be called directly.
Please try the following code:
- (void)foo {
UIImagePickerController *controller = [[[UIImagePickerController alloc] init] autorelease];
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
controller.cameraOverlayView = self.cameraOverlay;
[self performSelector:#selector(moveOverlayViewToSublayer:) withObject:controller afterDelay:0.1f];
controller.delegate = self;
[self presentModalViewController:controller animated:YES];
}
- (void) moveOverlayViewToSublayer:(UIImagePickerController*)controller {
CALayer *aLayer = self.cameraOverlay.layer.superlayer;
controller.cameraOverlayView = nil;
[aLayer addSublayer:self.cameraOverlay.layer];
}
I hope it will work well.
The entire issue goes away once you use [overlayView setUserInteractionEnabled:NO]; to stop the overlay view from handling the input.
http://www.techques.com/question/1-10178214/cameraOverlayView-prevents-editing-with-allowsEditing
This works perfectly for me. I tried to disable userInteractionEnabled but in vain.