The Easiest Way to Save and Share Code Snippets on the web

Untitled

objc

posted: Feb, 2nd 2012 | jump to bottom

    NSString *ptsName = [[fileName  stringByDeletingPathExtension] stringByAppendingPathExtension:@"pts2"];
    NSLog(@"Open pts file %@",ptsName);
 
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:ptsName];
    NSLog(@"File exists: %@", (fileExists ? @"YES" : @"NO"));
 
    if (!fileExists)
    {
        [progressView setDescription:@"Face detection underway..."];
        CFRunLoopRunInMode(CFRunLoopCopyCurrentMode(CFRunLoopGetCurrent()), 0, FALSE);
 
        UIImage *img = [UIImage imageWithContentsOfFile:fileName];
        IplImage *im = [CVUtils CreateIplImageFromUIImage:img];
        cv::Mat cvMat = im;
        Face *_face = [Result sharedFaceAnalyzer]->analyzeFace(im);
        cvReleaseImage(&im);
 
        if (_face != NULL)
        {
            [_flurryController addFlurryEvent:@"Selected old image, face rescanned successfully"];
 
            NSLog(@"Saving points to file %@",ptsName);
            bool done = [_face->m_faceShape saveToPtsFile:[ptsName UTF8String]];
 
            IplImage res = _face->m_faceImage;
 
            NSLog(@"Saving new image to file");
            UIImage * newCroppedImage = [CVUtils UIImageFromIplImage:&res];
            [UIImagePNGRepresentation(newCroppedImage) writeToFile:fileName atomically:YES];
 
            NSLog(@"Saved %@",done?@"yes":@"no");
            [_face->m_faceShape release];
        }
    }
 
20 views