I'm using the new Core Image APIs in iO开发者_StackOverflow中文版S 5 that do auto enhancements. However, the array returned from autoAdjustmentFilters or autoAdjustmentFiltersWithOptions never removes red eye, it only returns filters such as CIFaceBalance, CIVibrance, and CIHighlightsAndShadows. I've even tried setting the autoAdjustmentFiltersWithOptions dictionary key kCIImageAutoAdjustRedEye to TRUE, even though the docs state it's true by default. I know the Camera/Photos app will detect red eye on the same image, so something's amiss.
This code will return the CIRedEyeCorrections. Since I do not have any pictures with real red eye. I just google and found this one "redeye_incorrect_lg.jpg". This is the first female picture returned from google images. I found that not all red eye images can be detected.... so make sure yours is real red eye...
-(void) coreImageInit
{
NSString *sourcePath = [[NSBundle mainBundle] resourcePath];
NSString *file1 = [sourcePath stringByAppendingPathComponent:@"/redeye_incorrect_lg.jpg"];
UIImage *img = [[[UIImage alloc]initWithContentsOfFile:file1]autorelease];
CIImage *image = [[CIImage alloc]initWithImage:img];
NSLog(@"after ciimage: %@", kCIImageAutoAdjustEnhance);
NSDictionary *options = [NSDictionary dictionaryWithObject:@"NO" forKey:kCIImageAutoAdjustEnhance];
NSLog(@"options: %@", options);
NSArray *adjustments = [image autoAdjustmentFiltersWithOptions:options];
NSLog(@"adjustments: %@ ", adjustments);
}
Here is the my log output that show it detected red eye:
11/4/11 10:13:19.231 AM iPadTestBed: after ciimage: kCIImageAutoAdjustEnhance
11/4/11 10:13:19.232 AM iPadTestBed: options: {
kCIImageAutoAdjustEnhance = NO;
}
11/4/11 10:13:19.879 AM iPadTestBed: adjustments: (
"<CIRedEyeCorrections: inputImage=<CIImage: 0x878a980 extent [0 0 370 427]> inputCameraModel=nil inputCorrectionInfo=(\n {\n averageSkinLuminance = 0;\n bitmaskThreshold = \"0.1372549\";\n bitmaskX = \"0.372973\";\n bitmaskY = \"0.5854801\";\n cornealReflectionThreshold = \"0.854902\";\n cornealReflectionX = \"0.3783784\";\n cornealReflectionY = \"0.587822\";\n existingPupilAverage = \"0.1607843\";\n existingPupilHigh = \"0.345098\";\n existingPupilLow = \"0.01176471\";\n existingPupilMedium = \"0.1333333\";\n finalEyeCase = 0;\n forceCase = 0;\n fullImageHeight = 427;\n fullImageWidth = 370;\n imageOrientation = 1;\n imageSignalToNoiseRatio = 20;\n imageSpecialValue = 0;\n interocularDistance = \"0.2284475\";\n pointX = \"0.3702703\";\n pointY = \"0.587822\";\n pupilShadeAlignment = 1;\n pupilShadeAverage = \"0.2117647\";\n pupilShadeHigh = \"0.2901961\";\n pupilShadeLow = \"0.1372549\";\n pupilShadeMedium = \"0.2117647\";\n repairRectangleMaximumX = \"0.4162162\";\n repairRectangleMaximumY = \"0.557377\";\n repairRectangleMinimumX = \"0.3513514\";\n repairRectangleMinimumY = \"0.6135831\";\n searchRectangleMaximumX = \"0.4864865\";\n searchRectangleMaximumY = \"0.4871194\";\n searchRectangleMinimumX = \"0.2540541\";\n searchRectangleMinimumY = \"0.6885245\";\n size = \"0.012472\";\n snappedX = \"0.3702703\";\n snappedY = \"0.587822\";\n },\n {\n averageSkinLuminance = 0;\n bitmaskThreshold = \"0.09411766\";\n bitmaskX = \"0.7081081\";\n bitmaskY = \"0.6533958\";\n cornealReflectionThreshold = \"0.8745099\";\n cornealReflectionX = \"0.7081081\";\n cornealReflectionY = \"0.6487119\";\n existingPupilAverage = \"0.1686275\";\n existingPupilHigh = \"0.3490196\";\n existingPupilLow = \"0.03921569\";\n existingPupilMedium = \"0.1372549\";\n finalEyeCase = 0;\n forceCase = 0;\n fullImageHeight = 427;\n fullImageWidth = 370;\n imageOrientation = 1;\n imageSignalToNoiseRatio = 20;\n imageSpecialValue = 0;\n interocularDistance = \"0.2284475\";\n pointX = \"0.7081081\";\n pointY = \"0.6557377\";\n pupilShadeAlignment = 1;\n pupilShadeAverage = \"0.2117647\";\n pupilShadeHigh = \"0.2901961\";\n pupilShadeLow = \"0.1372549\";\n pupilShadeMedium = \"0.2117647\";\n repairRectangleMaximumX = \"0.7405406\";\n repairRectangleMaximumY = \"0.6229508\";\n repairRectangleMinimumX = \"0.6864865\";\n repairRectangleMinimumY = \"0.6697892\";\n searchRectangleMaximumX = \"0.827027\";\n searchRectangleMaximumY = \"0.5526932\";\n searchRectangleMinimumX = \"0.5945946\";\n searchRectangleMinimumY = \"0.7540984\";\n size = \"0.010893\";\n snappedX = \"0.7081081\";\n snappedY = \"0.6557377\";\n }\n)>"
)
精彩评论