Do we have notification for image capture event in iPhone? - iphone

I want to get the timestamp when the image is captured in my application. Do we have any notification when the camera is clicked?

use UIImagePickerController delegate:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSDictionary *metadataDictionary = (NSDictionary *)[info valueForKey:UIImagePickerControllerMediaMetadata];
// do something with the metadata
NSLog(#"meta : %# \n\n",metadataDictionary);
}

Related

Dismiss Video Recorder to a new ViewController

In my app I'm allowing the user to select if they want to choose a photo from the library, use the camera to take a photo, or use the camera to record a video.
After a photo has been selected or taken with the Camera, tapping Use will dismiss the UIImagePickerController and take the user to a new UIViewController.
I want to do the same for when a user records a video. Right now if the user taps the 'Use' button it just dismisses the picker.
How do I detect if the picker is set to record video?
Here's what I have tried:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
if (picker.mediaTypes == [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera] && picker.cameraCaptureMode == UIImagePickerControllerCameraCaptureModeVideo)
{
// Push to new view controller
// dismiss the picker
}
}
Is it possible to do this? What should I check for?
Thanks!
Refer to Apple's "Camera Programming Topics for iOS". The recommendation there is to implement imagePickerController:didFinishPickingMediaWithInfo: instead of imagePickerController:didFinishPickingImage:editingInfo: (which has been deprecated since iOS 3). Then, one can inspect the value of the info dictionary's UIImagePickerControllerMediaType key and compare against the appropriate types.
For example (note that you'll need to add the MobileCoreServices framework, and import its header):
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *pickedMediaType = info[UIImagePickerControllerMediaType];
NSString *movieType = (__bridge NSString *)kUTTypeMovie;
NSString *imageType = (__bridge NSString *)kUTTypeImage;
if ([pickedMediaType isEqualToString:movieType]) {
NSLog(#"movie was picked");
}
else if ([pickedMediaType isEqualToString:imageType]) {
NSLog(#"image was picked");
}
else {
NSLog(#"something else was picked");
}
[self dismissViewControllerAnimated:YES completion:nil];
}
In your application, you'd replace the logging statements with the appropriate actions (From your question, it sounds like you already have code to push to the new view controllers, so replace the logging statements accordingly). Also, note that you generally shouldn't compare Objective-C objects with ==. As I'm comparing strings, I use isEqualToString:.
use the below stated code that detects the recording of video an at the end of dismissal it goes to detailviewcontroller
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
//not production code, do not use hard coded string in real app
if ( [mediaType isEqualToString:#"public.image" ])
{
NSLog(#"Picked a photo");
}
//not production code, do not use hard coded string in real app
else if ( [ mediaType isEqualToString:#"public.movie" ])
{
NSLog(#"Picked a movie at URL %#", [info objectForKey:UIImagePickerControllerMediaURL]);
NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];
NSLog(#">>>>>>>>>>> Url %#", [url absoluteString]);
RecordDetailiPhone *objDetail = [[RecordDetailiPhone alloc] initWithNibName:#"RecordDetailiPhone" bundle:nil];
[objDetail saveVideoFileToDeractory:url];
[self.navigationController pushViewController:objDetail animated:YES];
}
}

ios custom takePicture button

I want my custom button to take a picture using UIImagePickerController and to save it in my device.
I can save the picture in the device using the default camera controls, although when i turn them off and start using my custom button it doesn't do the job.
- (IBAction)takePhoto:(id)sender {
[picker takePicture];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
UIImageWriteToSavedPhotosAlbum(chosenImage, nil, nil, nil);
[picker dismissViewControllerAnimated:YES completion:nil];
}
didFinishPickingMediaWithInfo is being called but the picture isn't being saved.
How can i achieve this?
I did something similar and used this tutorial to get be started. Have a look.
http://www.musicalgeometry.com/?p=821

how to identify the image take from uiimagePicketController is screenshot or camera image?

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editInfo {
NSLog(#"done");
headingLabel.hidden= NO;
//[self playMovie];
[picker dismissViewControllerAnimated:YES completion:nil];
[self setupCroppingTool:selectedImage];
}
this is the code,so how can i identify the selectedImage is screenshot or camera image
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)selectedImage editingInfo:(NSDictionary *)editInfo
This method picks the image from photo library. You cant compare a screenshot image with a normal image because both are UIImage.
May be help..
I think source property of UIImagePickerController help you.
Example.
UIImagePickerController *abc = [[UIImagePickerController alloc] init];;
abc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
You can use one of this..
UIImagePickerControllerSourceTypePhotoLibrary
UIImagePickerControllerSourceTypeCamera
UIImagePickerControllerSourceTypeSavedPhotosAlbum
Look at the image metadata - date, keywords, geolocation... and compare that.

Capturing image using custom buttons in cameraoverlayview in iphone

Thanks in advance.
I have created a custom toolbar on cameraOverlayView. One of the toolbar buttons will trigger the takeSnap method –
-(IBAction)takeSnap
{
NSLog(#"take snap called");
[self.picker takePicture];
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editingInfo
{
UIImage *image = img;
NSLog(#"image : %#",image);
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
NSLog(#"Did cancel called");
}
But it is not calling the delegate methods after capturing. The view continues to remain in capture mode. If any one know the reason please help me.
Its very likely that you haven't assigned a delegate properly.

how to know image picking in uiimagepicker?

how to know image picking in uiimagepicker and how to modify the picking image or how to call after image picking? and how to get the picking image as background image for next view using xcode for iphone?
You can refer UIImagePickercontroller and use the UIImagePickerController's delegate methods UIImagePickerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Get the image picked by the image picker
UIImage *image = [info objectForKey:#"UIImagePickerControllerOriginalImage"];
//Do something
}
Use the UIImagePickerController's delegate methods:
- (void)imagePickerController:(UIImagePickerController *)pickerdidFinishPickingMediaWithInfo:(NSDictionary *)info {
// Get the image picked by the image picker
UIImage *image :[info objectForKey:#"UIImagePickerControllerOriginalImage"] ;
//Do something
[picker dismissModalViewControllerAnimated:YES];
}
Or I am sure this link may be helpful to you:
http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/