IPhone iOS 4.3 camera focus square - removeable programmatically? - iphone

Since my friend updated his iPhone iOS to 4.3 there's a small square which appears every time he takes a picture with the camera.
We're developing an app that uses the camera and would like to remove this annoying square. I didn't find anything about it in Apple's UIImagePickerController documentation.
The square didn't exist in former iOS versions.

You may want to try to lock the focus to disable auto-focus. Here is a sample code:
NSArray *devices = [AVCaptureDevice devices];
NSError *error;
for (AVCaptureDevice *device in devices) {
if (([device hasMediaType:AVMediaTypeVideo]) &&
([device position] == AVCaptureDevicePositionBack) ) {
[device lockForConfiguration:&error];
if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
device.focusMode = AVCaptureFocusModeLocked;
NSLog(#"Focus locked");
}
[device unlockForConfiguration];
}
}

Setting the .showsCameraControls property of your picker controller to NO should remove the focus square (it did pre 4.3, I don't think anything has changed), but the downside is you'll need to provide your own controls (to take photos, etc). It's all or nothing I'm afraid!

Create a custom overlay and default overlay will not display. You can make your overlay can be completely empty.

Related

Switch On/Off flash while recording the Video in iphone app

I am recording video from my iPhone app.
I am using an overlay over the camera and placed a button in the overlay. I want to know with the help of which function can I turn camera's flash on/off while the video is being recorded.
How can I set a flash button in the camera overlay?
If you are using AVFoundation for video recording, You should first check if device has torch/flash because torch is available when video is being recorded from the back camera, you can not have the torch/flash when using front camera.
using something like this
- (BOOL) hasTorch
{
return [[[self avCaptureDeviceInput] device] hasTorch];
}
and then set the torch accordingly using AVCaptureTorchMode
- (void) setTorchMode:(AVCaptureTorchMode)torchMode
{
AVCaptureDevice *device = [[self videoInput] device];
if ([device isTorchModeSupported:torchMode] && [device torchMode] != torchMode) {
NSError *error;
if ([device lockForConfiguration:&error]) {
[device setTorchMode:torchMode];
[device unlockForConfiguration];
} else {
id deleg = [self delegate];
if ([deleg respondsToSelector:#selector(acquiringDeviceLockFailedWithError:)]) {
[deleg acquiringDeviceLockFailedWithError:error];
}
}
}
}
if you follow the AVCam Demo from Apple you will get your answers basically.
Assuming you are using UIImagePickerController (from your tag), use the cameraFlashMode provided by UIImagePickerController to control the flash.
You can set its value to UIImagePickerControllerCameraFlashModeOff, UIImagePickerControllerCameraFlashModeAuto or UIImagePickerControllerCameraFlashModeOn. Default is auto.

iPhone 5's low light boost mode

Has anyone been able to get the iPhone 5's new low light boost mode to work in their custom camera app? I tried the following code, but noticed no difference - whereas the native camera app significantly boosted the brightness.
if ([[captureManager backFacingCamera] isLowLightBoostEnabled]) {
[[captureManager backFacingCamera] automaticallyEnablesLowLightBoostWhenAvailable];
}
You need to lockForConfiguration, according to the docs (well, the header file):
if ([[self backFacingCamera] respondsToSelector:#selector(isLowLightBoostSupported)]) {
if ([[self backFacingCamera] lockForConfiguration:nil]) {
if ([self backFacingCamera].isLowLightBoostSupported)
[self backFacingCamera].automaticallyEnablesLowLightBoostWhenAvailable = YES;
[[self backFacingCamera] unlockForConfiguration];
}
}
Also, isLowLightBoostEnabled tells you whether or not the low light is actually being boosted, not whether it can be. That's the isLowLightBoostSupported selector, as above (to which only iOS 6 devices respond).

Retina Image show 1/4th size in cocos2d ios6

i researched so much about that but i cant find anything interesting.. actually i had a project in cocos2d made in ios5 and show images size good either in retina .. when upgraded to ios6 it shows one fourth image sizes.. It shows Retina display ON in CCDirector.
I Think this will helps you.
NSString *iPadtext;
NSString *device = [UIDevice currentDevice].model;
NSLog(#"deive name is %#",device);
Add both images like pause.png and pause-hd.png
if([device isEqualToString:#"iPad"] || [device isEqualToString:#"iPad Simulator"] ){
iPadtext = #"-hd";
}
CCMenuItemImage *pauseMenuItem = [CCMenuItemImage
itemFromNormalImage:[NSString stringWithFormat:#"pause_01%#.png",iPadText] selectedImage:[NSString stringWithFormat:#"pause_01-over%#.png",iPadText]
target:self selector:#selector(PauseButtonTapped:)];
i hope it will help you

modifying zxing library files barcode scanner iPhone

I want to modify the zxing library files (which is an open source library) a bit to have the cameraFlashMode On as soon as user taps on scan button to open the bar code scanner camera. Also, I want to add one or two UIButtons at the bottom. In short, I want to customize that camera view according to my needs.
If anyone has done it or knows how to do it, then please help me.
You need to implement your customizations in OverlayView.m. Add the buttons in
- (id) initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled;
And set the flashmode in ZXingWidgetController.h in
- (void)initCapture;
Set the flashMode on with:
- (void)activateFlash {
Class captureDeviceClass = NSClassFromString(#"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[device lockForConfiguration:nil];
if ( [device hasFlash] ) {
[device setFlashMode:AVCaptureFlashModeOn];
}
[device unlockForConfiguration];
}
}

how to know is it iphone or ipad?

i want to know the user uses the iphone or ipad,if the user uses the iphone i want to open the camera,if he uses the ipad or runs in simulator i want to open the library. how it is possible?
how to find the details of devices?
how to know current using device by user through xcode?
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:#"iPhone"])
{
//your code
}
.....
Hope this helps.
EDIT:
See this thread -determine-device-iphone-ipod-touch-with-iphone-sdk .
[[UIDevice currentDevice].model hasPrefix:#"iPhone"]
Use the "hasPrefix" so that it works in simulator.
You should not determine whether there is a camera by looking at the model. This is not future proof - for instance, you would not be supporting the iPad 2's camera.
UIImagePickerController has a special method to determine whether a camera in available:
+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType
With sourceType being one of
UIImagePickerControllerSourceTypePhotoLibrary,
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum
Make use of this to identify devices.
// If iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
#ifndef __IPHONE_3_2
typedef enum {
UIUserInterfaceIdiomPhone, // iPhone and iPod touch
UIUserInterfaceIdiomPad, // iPad
} UIUserInterfaceIdiom;
#define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone
#endif // ifndef __IPHONE_3_2
but if you want to check if camera is available I think you can make use of UIImagePickerController's static method
+ (BOOL)isSourceTypeAvailable:(UIImagePickerControllerSourceType)sourceType
Working on Vaibhav Tekam's answer, I used this
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType hasPrefix:#"iPhone"])
{
//your code
}
or
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType hasPrefix:#"iPad"])
{
//your code
}
etc.
It's much easier that way as it covers all models.