1

I am calling this takePicture function 5 times because i neeed to take 5 picture on on click(Burst Mode)

for(count=0;count<5;count++)
{
     [picker takePicture];
     [NSThread sleepForTimeInterval:0.5];
     [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate date]];
}

I am getting this error UIImagePickerController: ignoring request to take picture; image is already being captured or camera not yet ready.

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
mshau
  • 503
  • 4
  • 19
  • If you're on iOS5+ see my answer here (describes a way to make sure that the camera is ready to take a picture) : http://stackoverflow.com/questions/10678067/how-to-know-if-iphone-camera-is-ready-to-take-picture/10768237#10768237 – Alladinian Jul 05 '12 at 12:52
  • Your ans is related to AVFoundation and i have used UIImagePickerController – mshau Jul 05 '12 at 12:57
  • Please read it more carefully. `AVFoundation` is just the underlying framework that handles all this stuff. You will still be using `UIImagePickerController` and just use the `AVFoundation` to catch the notifications. – Alladinian Jul 05 '12 at 13:02

2 Answers2

0

Not sure but i think camera not yet ready ... Because you are trying to capture images continuously.... I think you will have to delay for few seconds before call take picture method again..... Dont do it in for loop i would like to suggest you please use NSTimer instead of looping.

something like this -

Declare

-(void)startTimer; 

and

int count; 

in your .h class then see below code -

-(void)yourTakePictureButtonClick:(id)sender
{
    [self startTimer];
}

-(void)startTimer
{
    count = 0;
    yourTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(myFunctionForClickImage) userInfo:nil repeats:YES];
}

-(void)myFunctionForClickImage
{
    [picker takePicture];
    count ++;
    if (count < 5)
    {
       [yourTimer invalidate];
    }
}
Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
TheTiger
  • 13,264
  • 3
  • 57
  • 82
0

Hi H2SO4 (Nice Name han)

The most probable reason seems to be the absence of the required key in your info.plist file. You will need to configure UIRequiredDeviceCapabilities. Also, you must implement the delegate object. For details, have a look at

http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/TakingPicturesAndMovies.html#//apple_ref/doc/uid/TP40010406.

HTH,

Another thing you should release your resources in every call inside loop.

You can delay with following.

[picker performSelector:@selector(takePicture) withObject:nil afterDelay:2.0];

For more you can visit...

http://highoncoding.com/Articles/856_Building_Instagram_for_the_iPhone_Part_2.aspx

Atulkumar V. Jain
  • 5,102
  • 9
  • 44
  • 61
Jigar Pandya
  • 6,004
  • 2
  • 27
  • 45
  • i have also tried that if i increase delay i could not take 5 picture i can take take 2 or 3 picture and then i will get such error – mshau Jul 05 '12 at 12:53