3

I use an UIImagePickerController to show rear camera as background. Everything works as expected, but in iPhone 5 and maybe in iPhone 4s I have a green box in the image like

face detection

I think is a face detection feature, but I don't now how to disable it. Any suggestion?

This is a code snippet that I use for UIImagePickerController:
I declare ad UIView in my .h file

UIView *overlay;

And in the init method of my .m file

#define CAMERA_TRANSFORM  1.24299

UIImagePickerController *uip;

@try {
      uip = [[[UIImagePickerController alloc] init] autorelease];
      uip.sourceType = UIImagePickerControllerSourceTypeCamera;
      uip.showsCameraControls = NO;
      uip.toolbarHidden = YES;
      uip.navigationBarHidden = YES;
      uip.wantsFullScreenLayout = YES;
      uip.cameraViewTransform = CGAffineTransformScale(uip.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);
}
@catch (NSException * e) {
    [uip release];
    uip = nil;
}
@finally {
    if(uip) {
        [overlay addSubview:[uip view]];
        [overlay release];
    }
}
Lebyrt
  • 1,376
  • 1
  • 9
  • 18
PizzaRings
  • 171
  • 1
  • 1
  • 8
  • Why do you want to disable it? Apple added this as a seemingly core feature... users may expect it and be confused if it's not there... – JRG-Developer Jan 30 '13 at 10:28
  • Because I what display camera view as background application with no other features. Maybe `UIImagePickerController` is not the right controller to use for this, better using `AVCaptureDevice`? – PizzaRings Jan 30 '13 at 14:15

1 Answers1

0

Take a look at this post

His problem was the other way around, I'm sure if you tweak the settings for the feature detector you'll be able to turn it off, if it's not turnable, just try to run it in a mirrored mode or upside down mode, and it won't be able to detect faces and will seem to be "off"

but i'm pretty sure it can be disabled.

Here's another reference that I found Also make sure to look at the class reference

Update:

Warning: I do not recommend using this at all, it's just to show a way I managed to hide those boxes, it will break sooner or later.

After hacking around a little bit, i managed to track down the subview that holds those little squares and set it's hidden property to YES

simply, at the end of your init code, you makeKeyAndVisible, put in this:

[[[[[[[[[[[[[[uip childViewControllers] objectAtIndex:0] view]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
subviews] objectAtIndex:0]
setHidden:YES];

Sorry for the bad formatting, I'm doing this in a hurry, but you get the idea, Also while messing around I found that you can control the Camera Iris view and some other features. but this should do your trick Also, this won't disable the face detection, meaning when the user finishes selecting, you can find out how many face features where detected !

I also think this will ONLY work on iPhone 4s and up !, you need to test a lot, this is really bad hackery that I don't recommend using on production apps !

Community
  • 1
  • 1
Mostafa Berg
  • 3,211
  • 22
  • 36
  • Thanks for response. I saw the link you posted, UIImagePickerController seems don't handle face detection property to set. I will change my implementation with AVCaptureDevice for showing video as background – PizzaRings Jan 29 '13 at 16:03
  • Can you Put a code snippet ? I'll try to take a deeper look on my phone cause I'm curious how it works !, thanks :) – Mostafa Berg Jan 29 '13 at 18:36
  • Of course! I edited my post with a code snippet. If you have any other question feel free to tell :) – PizzaRings Jan 29 '13 at 22:13
  • Ok managed to hack it, i'll update my answer now on how to do it :) – Mostafa Berg Jan 30 '13 at 10:13
  • -1: This "brute force" method is a terrible idea... this is bound to break in a future update! – JRG-Developer Jan 30 '13 at 10:27
  • If you slowed down a bit and read my last line You'll notice I said: "This is really bad hackery that I don't recommend using on production apps !" – Mostafa Berg Jan 30 '13 at 10:33