我正在iOS 5中使用新的Core Image API进行自动增强。但是,从autoAdjustmentFilters或autoAdjustmentFiltersWithOptions返回的数组永远不会消除红眼,它只返回CIFaceBalance,CIVibrance和CIHighlightsAndShadows等过滤器。我甚至尝试将autoAdjustmentFiltersWithOptions字典键kCIImageAutoAdjustRedEye设置为TRUE,即使文档默认情况下它是真的。我知道相机/照片应用程序会检测到同一图像上的红眼,所以有些不对劲。
答案 0 :(得分:0)
此代码将返回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)>"
)