此代碼將返回CIRedEyeCorrections。因爲我沒有真正的紅眼的照片。我只是谷歌,發現這一個「redeye_incorrect_lg.jpg」。這是谷歌圖片返回的第一張女性圖片。我發現,並不是所有的紅色眼睛的圖像可以被檢測到....所以一定要確保你的是真正的紅眼......
-(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);
}
這裏是我的日誌輸出,顯示它檢測到的紅眼:
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)>"
)
感謝您的檢查。我注意到了它的工作原理。我想我遇到的問題是將在Photos應用程序中刪除紅眼的相同圖像不會總是使用autoAdjustmentFiltersWithOptions返回CIRedEyeCorrections。 – akaru