Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7799537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:20:34+00:00 2026-06-02T00:20:34+00:00

I am following a facial recognition app example from Pro iOS 5 Augmented Reality

  • 0

I am following a facial recognition app example from Pro iOS 5 Augmented Reality book. I even downloaded the source code… I ran it from there and the problem persists with his code. Here is the problem: It crashes on the assignment of an array that takes the featuresInImage of a CGImage for a CIDetector that is detecting for a face. From logging… it seems that this method is called many many many times… I am using cocos2d_chipmunk so I am using a CSScene. Note that this crash is an EXC_BAD_ACCESS (code=1, address=0x4499923c)
Help please?

  - (void)facialRecognitionRequest:(UIImage *)image {
//NSLog(@"Image is: %f by %f", image.size.width, image.size.height);
if (!isProcessingRequest) {
    isProcessingRequest = YES;
    //NSLog(@"Detecting Faces");
  NSArray* arr = [detector featuresInImage:[CIImage imageWithCGImage:[image CGImage]]]; // CRASHES HERE


    if ([arr count] > 0) {
        //NSLog(@"Faces found.");
        for (int i = 0; i < 1; i++) { //< [arr count]; i++) {
            CIFaceFeature *feature = [arr objectAtIndex:i];
            double xPosition = (feature.leftEyePosition.x + feature.rightEyePosition.x+feature.mouthPosition.x)/(3*image.size.width) ;
            double yPosition = (feature.leftEyePosition.y + feature.rightEyePosition.y+feature.mouthPosition.y)/(3*image.size.height);

            double dist = sqrt(pow((feature.leftEyePosition.x - feature.rightEyePosition.x),2)+pow((feature.leftEyePosition.y - feature.rightEyePosition.y),2))/image.size.width;

            yPosition += dist;
            CGSize size = [[CCDirector sharedDirector] winSize];
            pumpkin.opacity = 255;
            pumpkin.scale = 5*(size.width*dist)/256.0;

            //int randomPumpkin = ((arc4random() % 10) + 5);
            [pumpkin setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"pumpkin%d.png", pumpkin_count + 4]]];
            CCMoveTo *moveAction = [CCMoveTo actionWithDuration:0 position:ccp((size.width * (xPosition)), (size.height * ((yPosition))))];
            [pumpkin runAction:moveAction];

        }
    } else {
        pumpkin.opacity = 0;

    }    


}
isProcessingRequest = NO;

  }

Assigning the CIDetector:

  - (id)init {
if (self = [super init]) {
  // ....... other stuff here        
    NSDictionary *detectorOptions = [NSDictionary dictionaryWithObjectsAndKeys:CIDetectorAccuracyLow, CIDetectorAccuracy, nil];
    self.detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:detectorOptions]; // CIDetector instance named detector is my property

}
return self;
 }

I tried:
CGImage *theCGImage = [image CGImage];
NSLog(@”theCGImage: %@”, theCGImage);

CIImage *theCIImage = [CIImage imageWithCGImage:theCGImage];
NSLog(@"theCIImage: %@", theCIImage);

NSArray* arr = [detector featuresInImage:theCIImage];
NSLog(@"arr: %@", arr);

Here are the results:

 2012-04-15 19:08:25.136 Ch8[981:609f] tmpCGImage: <CGImage 0x1f689c00>
 2012-04-15 19:08:25.143 Ch8[981:609f] tmpCIImage: <CIImage: 0x1f687970 extent [0 0 480 360]>
 2012-04-15 19:08:25.282 Ch8[981:609f] arr: (
"<CIFaceFeatureInternal: 0x1f58e080>"
)

I also tried enabling NSZombies but still no luck… any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:20:36+00:00Added an answer on June 2, 2026 at 12:20 am

    In answer to the comment (not the entire question, presented as answer just for the formatting):
    “how would i do that do i just write if statements to see if they are non-zero then log it?”

    Instead of:

      NSArray* arr = [detector featuresInImage:[CIImage imageWithCGImage:[image CGImage]]];
    

    break it up into three statements:

    CGImage *theCGImage = [image CGImage];
    NSLog(@"theCGImage: %@", theCGImage);
    
    CIImage *theCIImage = [CIImage imageWithCGImage:theCGImage];
    NSLog(@"theCIImage: %@", theCIImage);
    
    NSArray* arr = [detector featuresInImage:theCIImage];
    NSLog(@"arr: %@", arr);
    

    So that the offending statement can be found. This is a general debugging technique and not a bad way to write the code in any case.

    The NSLog statements are not really necessary, a breakpoint on the first statement and then single step through.

    For crashes due to premature releases use NSZombies. It can be enabled in Xcode under “Edit Scheme, tab: “Diagnostics”, be sure to turn it off when running on the device.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following example code from the libpcap documentation yields the following code which should report
following code is used to find url from a string with php. Here is
Following code is used to get images from particular folder but how to get
Following is the code from my audio, video recording project. The audio file is
Following s my Code to display data to listview from database. But it will
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to
Following code worked fine abstract class FunctionRunnable<V> implements Runnable { protected abstract V calculate();
Following chunk html code works as expected: <iframe src=http://www.amazon.com/></iframe> But when trying embed inner
Following leads in this thread and others, I've set up a code block where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.