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];
Related
I need to capture video in predefine size as square box format and after take it show into box size so can you please help me on this, how can i do this thing
Thanks
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];
Enjoy Programming!!
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/
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.
I am new to iphone development. I am creating one camera app, in that i need to capture only some co-ordinates of the image for example (I have overlay image on camera. that image is dollar. In the middle of the dollar bill there is a rectangle. inside this rectangle i can set my own image and capture).That is working fine. But when i save i need to save only image inside the rectangle co-ordinates. How to capture that. Please can anyone help me. Here is my code sample.
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
// Make camera view full screen:
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
picker.cameraOverlayView = overlay;
// Show the picker:
[self presentModalViewController:picker animated:YES];
[picker release];
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!