UIImagePickerController禁用iPhone 4S面部识别(iOS 5.1)

3

我正在开发一款 iPhone 应用程序,它使用带有自定义叠加层的 UIImagePickerController 来拍照。

不幸的是,我没有直接访问 iPhone 4S 的权限,但是几个测试人员报告说相机选择器会在脸部周围绘制一个绿色边框,就像这样:http://cdn.iphonehacks.com/wp-content/uploads/2012/03/camera_faces.jpg

由于应用程序的性质,这是不可取的。

仔细查看 UIImagePickerController 文档后,并没有找到相关信息,同样在这里找到的所有与面部识别相关的内容都是提供使用 CIDetector 或类似工具的说明。

我该如何在我的 UIImagePickerController 中禁用面部检测?

以下是我 UIImagePickerController 的初始化代码:

UIImagePickerController *cameraPicker = [[UIImagePickerController alloc] init];

[cameraPicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[cameraPicker setCameraDevice:UIImagePickerControllerCameraDeviceRear];
if ([UIImagePickerController isFlashAvailableForCameraDevice:cameraPicker.cameraDevice]){
    [cameraPicker setCameraFlashMode:UIImagePickerControllerCameraFlashModeOn];
}
[cameraPicker setShowsCameraControls:NO];
[cameraPicker setCameraOverlayView:cameraOverlayView];

cameraPicker.delegate = self;
[self presentModalViewController:cameraPicker animated:YES];
2个回答

1

请试一下 -->

假设我们有一个名为 RecordVideoViewController 的 UIViewController。

-- 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

实现 -- 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];
 }
}

实现这段代码,我希望它能帮到你。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接