3

私は現在、写真を撮るためにカスタムオーバーレイを備えたUIImagePickerControllerを利用するiPhoneアプリを開発しています。

残念ながら、私は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];
4

2 に答える 2

1

これを試してください->

たとえば、次の名前のUIViewControllerが1つあります-RecordVideoViewController

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

このコードを実装してください。これがお役に立てば幸いです。

于 2013-09-10T11:08:15.293 に答える
0

この投稿をチェックしてください。ここにいくつかのヒントがありますが、それでもこのAPIに関するAppleのドキュメント以外に多くの情報を見つけることはできません。 CIDetectorTrackingの適切な使用法

于 2013-01-18T04:33:00.480 に答える