Sunday, June 2, 2013

Camera on iOS keeps locking when preforming operation

Camera on iOS keeps locking when preforming operation

Right now I'm using OpenCV on iOS to do some image processing and things, and i'm using the OpenCV CvVideoCamera and grabbing frames with the delegate method and preforming operations on those frames. The only problem I have with this is when I attempt to preform the operations it freezes the camera until the task has finished. Is there anyway to stop this from happening?
I've tried this approach:
-(void) processImage:(Mat&)mat{
    if(counter % 60 == 0){
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            [self preformTask:mat]; // 1
            dispatch_async(dispatch_get_main_queue(), ^{
                 // 2
            });
        });
    }
    counter++;
}
With this method I keep getting point to:
CV_XADD(refcount, 1);
with EXC_BAD_ACCESS so I'm not really sure how to go about fixing this. Any help would be great!