UIImagePickerController disable iPhone 4S face detection (iOS 5.1)

后端 未结 2 1340
悲&欢浪女
悲&欢浪女 2020-12-21 07:32

I am currently developing an iPhone app that makes use of a UIImagePickerController with a custom overlay to take photos.

Unfortunately I do not have direct access t

相关标签:
2条回答
  • 2020-12-21 08:11

    Check out this post. There are some hints here, but still can't find much info outside of Apple's docs on this API. Proper usage of CIDetectorTracking

    0 讨论(0)
  • 2020-12-21 08:30

    Try This -->

    Lets Say We have one UIViewController named as - RecordVideoViewController

    Implementation of -- RecordVideoViewController.h

    #import <UIKit/UIKit.h>
    #import <MediaPlayer/MediaPlayer.h>
    #import <MobileCoreServices/UTCoreTypes.h>
    #import <AssetsLibrary/AssetsLibrary.h>
    @interface RecordVideoViewController : UIViewController
    - (IBAction)recordAndPlay:(id)sender;
    
    -(BOOL)startCameraControllerFromViewController:(UIViewController*)controllerusingDelegate:
    (id)delegate;   
    
    -(void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error
    contextInfo(void*)contextInfo; 
    @end
    

    Implementation of -- RecordVideoViewController.m

    - (IBAction)recordAndPlay:(id)sender {
    
    [self startCameraControllerFromViewController:self usingDelegate:self];
    
    }
    
    -(BOOL)startCameraControllerFromViewController:(UIViewController*)controller
                                 usingDelegate:(id )delegate 
    {
    // 1 - Validattions
    if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] ==
    NO)  
        || (delegate == nil)
        || (controller == nil)) {
        return NO;
    }
    // 2 - Get image picker
    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
    // Displays a control that allows the user to choose movie capture
    cameraUI.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeMovie, nil];
    // Hides the controls for moving & scaling pictures, or for
    // trimming movies. To instead show the controls, use YES.
    cameraUI.allowsEditing = NO;
    cameraUI.delegate = delegate;
    // 3 - Display image picker
    [controller presentViewController:cameraUI animated:YES completion:nil];
     return YES;
    }
    
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:
     (NSDictionary *)info {
     NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
     [self dismissViewControllerAnimated:YES completion:nil];
     // Handle a movie capture
     if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == 
     kCFCompareEqualTo) {
         NSString *moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
    
         if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath)) {
             UISaveVideoAtPathToSavedPhotosAlbum(moviePath,
             self,@selector(video:didFinishSavingWithError:contextInfo:),nil); 
         }
       }
     }
    
     -(void)video:(NSString*)videoPath didFinishSavingWithError:(NSError*)error contextInfo:
     (void*)contextInfo {  
       if (error) {
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Video Saving
         Failed" 
          delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
         [alert show];
       } else {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Video Saved" message:@"Saved To
         Photo Album" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];  
        [alert show];
     }
    }
    

    Implement This code it, i hope this will help you .

    0 讨论(0)
提交回复
热议问题