Search code examples
iosobjective-cface-detectionciimage

What is kCGImagePropertyOrientation for face detection?


https://developer.apple.com/library/ios/documentation/graphicsimaging/Conceptual/CoreImaging/ci_detect_faces/ci_detect_faces.html

@ Listing 2-1 Creating a face detector

CIContext *context = [CIContext contextWithOptions:nil];                    // 1
NSDictionary *opts = @{ CIDetectorAccuracy : CIDetectorAccuracyHigh };      // 2
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                      context:context
                                      options:opts];                    // 3

opts = @{ CIDetectorImageOrientation :
      [[myImage properties] valueForKey:kCGImagePropertyOrientation] }; // 4
NSArray *features = [detector featuresInImage:myImage options:opts];        // 5

4.Sets up an options dictionary for finding faces. It’s important to let Core Image know the image orientation so the detector knows where it can find upright faces. Most of the time you’ll read the image orientation from the image itself, and then provide that value to the options dictionary.

Use of undeclared identifier 'kCGImagePropertyOrientation'

What is this image prop orientation supposed to be?
What kind of object?
How do I set it?


Solution

  • You need to include the ImageIO framework into your project.

    kCGImagePropertyOrientation:

    The intended display orientation of the image. If present, this key is a CFNumber value with the same value as defined by the TIFF and EXIF specifications. The value specifies where the origin (0,0) of the image is located, as shown in Table 1. If not present, a value of 1 is assumed.