|
@@ -276,42 +276,27 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
let g = Int(color.greenComponent*255)
|
|
|
let b = Int(color.blueComponent*255)
|
|
|
|
|
|
- let key = String("\(r)-\(g)-\(b)")
|
|
|
-
|
|
|
- if (markInfo[key] != nil) {
|
|
|
- let count = (markInfo[key] as? NSNumber)!.intValue ?? 0
|
|
|
+ if (markInfo[color] != nil) {
|
|
|
+ let count = (markInfo[color] as? NSNumber)!.intValue ?? 0
|
|
|
|
|
|
- markInfo[key] = NSNumber.init(value: count + 1)
|
|
|
+ markInfo[color] = NSNumber.init(value: count + 1)
|
|
|
}else {
|
|
|
- markInfo[key] = NSNumber.init(value: 1)
|
|
|
+ markInfo[color] = NSNumber.init(value: 1)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var maxCount = Int(0);
|
|
|
- var bgColorString : String? = nil
|
|
|
- for key in markInfo.allKeys {
|
|
|
- let count = (markInfo[key] as? NSNumber)!.intValue ?? 0
|
|
|
+ var bgColor : NSColor? = nil
|
|
|
+ for color in markInfo.allKeys {
|
|
|
+ let count = (markInfo[color] as? NSNumber)!.intValue ?? 0
|
|
|
|
|
|
if count > maxCount {
|
|
|
maxCount = count
|
|
|
- bgColorString = key as! String
|
|
|
+ bgColor = color as! NSColor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var bgColor : NSColor? = nil
|
|
|
- if bgColorString != nil {
|
|
|
- let coms = NSString(string: bgColorString!).components(separatedBy: "-")
|
|
|
-
|
|
|
- let r = NSString(string: coms[0]).intValue
|
|
|
- let g = NSString(string: coms[1]).intValue
|
|
|
- let b = NSString(string: coms[2]).intValue
|
|
|
- bgColor = NSColor(red: CGFloat(CGFloat(r)/255.0),
|
|
|
- green: CGFloat(CGFloat(g)/255.0),
|
|
|
- blue: CGFloat(CGFloat(b)/255.0),
|
|
|
- alpha: 1)
|
|
|
- }
|
|
|
-
|
|
|
if nil != bgColor {
|
|
|
NSLog(String("识别到背景色\(bgColor)"))
|
|
|
}
|
|
@@ -339,6 +324,8 @@ class AutoTest : NSObject, AutoTestProtocal {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ NSLog(String("过滤点数目\(bgCount)"))
|
|
|
+
|
|
|
return Double(max(equalCount-bgCount, 1)/(max(Double(cWidth) * Double(cHeight)-bgCount, 1)) * 100.0)
|
|
|
}
|
|
|
|