Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-10-2011, 07:44 AM   #1 (permalink)
CAM
Registered Member
 
Join Date: Feb 2009
Posts: 157
CAM is on a distinguished road
Default Facial Recognition Inside AVCaptureSession, is it possible?

Is it possible to use CIDetector within an AVCaptureSession or is it just not fast enough. I have tried Setting the accuracy to CIDetector to low and i call it in this function
Code:
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
I of course change the CMSampleBufferRef into a CIImage and rotate it to make it so it is the right orientation. Once i do that i run the the CIDetector code.
Code:
  NSArray *features = [detector featuresInImage:imag.CIImage options:nil];
    for (CIFaceFeature *f in features) {
        CGFloat faceWidth = f.bounds.size.width;
        
      
        
        if(f.hasLeftEyePosition){
            
            NSLog(@"left eye position x = %f , y = %f", f.leftEyePosition.x, f.leftEyePosition.y);
             
      
        }
        
        if(f.hasRightEyePosition){
            
            NSLog(@"right eye position x = %f , y = %f", f.rightEyePosition.x, f.rightEyePosition.y);
        
        }
        if(f.hasMouthPosition){
            
            NSLog(@"mouth position x = %f , y = %f", f.mouthPosition.x, f.mouthPosition.y);
         
           
        }
    }
My problem is, when I hold it up to my face, the Logs only seem to get called maybe once every minute, sometimes not at all. The picture is definitely being created properly because i got it to save them to my photo album and i checked every time.
Thanks in Advance
CAM is offline   Reply With Quote
Old 12-10-2011, 12:43 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,005
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by CAM View Post
Is it possible to use CIDetector within an AVCaptureSession or is it just not fast enough. I have tried Setting the accuracy to CIDetector to low and i call it in this function
Code:
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
I of course change the CMSampleBufferRef into a CIImage and rotate it to make it so it is the right orientation. Once i do that i run the the CIDetector code.
Code:
  NSArray *features = [detector featuresInImage:imag.CIImage options:nil];
    for (CIFaceFeature *f in features) {
        CGFloat faceWidth = f.bounds.size.width;
        
      
        
        if(f.hasLeftEyePosition){
            
            NSLog(@"left eye position x = %f , y = %f", f.leftEyePosition.x, f.leftEyePosition.y);
             
      
        }
        
        if(f.hasRightEyePosition){
            
            NSLog(@"right eye position x = %f , y = %f", f.rightEyePosition.x, f.rightEyePosition.y);
        
        }
        if(f.hasMouthPosition){
            
            NSLog(@"mouth position x = %f , y = %f", f.mouthPosition.x, f.mouthPosition.y);
         
           
        }
    }
My problem is, when I hold it up to my face, the Logs only seem to get called maybe once every minute, sometimes not at all. The picture is definitely being created properly because i got it to save them to my photo album and i checked every time.
Thanks in Advance
I'm wondering about that as well. We have a prototype we're working with right now that uses a CIDetector set to high quality for still images, and it takes around 5 seconds to recognize a face, or sometimes less. It doesn't make sense that low accuracy would be slower.

My plan was to capture an image from a video capture session and pass that image to a CIDetector working in the background. Once I got a response from the detector, I would use those results on the current image stream. Hopefully the CIDetector would not lag too far behind, so it's results are still relevant.

If you look at Photo Booth in Mac OS 10.7, that's almost certainly what they are doing. The new morphs that apply to faces lag for a few seconds if the faces in the image move around.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is online now   Reply With Quote
Old 12-10-2011, 02:32 PM   #3 (permalink)
CAM
Registered Member
 
Join Date: Feb 2009
Posts: 157
CAM is on a distinguished road
Default

Quote:
Originally Posted by Duncan C View Post
I'm wondering about that as well. We have a prototype we're working with right now that uses a CIDetector set to high quality for still images, and it takes around 5 seconds to recognize a face, or sometimes less. It doesn't make sense that low accuracy would be slower.

My plan was to capture an image from a video capture session and pass that image to a CIDetector working in the background.
I am doing the same thing, and i feel like it is too slow. I have tried something like this to see what it can do.
Code:
-(void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
    i++;
    if(i==100){
        i=0;
 

   UIImage *imag = [self imageFromSampleBuffers:sampleBuffer ];

        imag = [UIImage imageWithCGImage:imag.CGImage scale:imag.scale orientation:UIImageOrientationRight];
    [self performSelectorInBackground:@selector(markFacesWithImage:) withObject:imag];
}
}
I did this to see if the CIDetector was just running slow and that didn't seem to work either. I am thinking OpenCV might be the best to use, but I don't believe it can detect the eyes or mouth.
CAM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 409
11 members and 398 guests
7twenty7, AppsBlogger, David-T, Duncan C, HemiMG, heshiming, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:46 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0