I use CoreImage to detect eye blinking, it works fine except when I try to detect only one eye. Any ideas in how to detect eye contact flirting **by using CoreImage**?
if let faceImage = CIImage(image: target) {
let accuracy = [CIDetectorAccuracy: CIDetectorAccuracyHigh]
let faceDetector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: accuracy)
let faces = faceDetector?.features(in: faceImage, options: [CIDetectorSmile:true, CIDetectorEyeBlink: true])
if !faces!.isEmpty {
for face in faces as! [CIFaceFeature] {
let leftEyeClosed = face.leftEyeClosed
let rightEyeClosed = face.rightEyeClosed
let blinking = face.rightEyeClosed && face.leftEyeClosed
let isSmiling = face.hasSmile
print("isSmiling \(isSmiling)")
print("blinking \(blinking)")
print("rightEyeClosed \(rightEyeClosed)")
print("leftEyeClosed \(leftEyeClosed)\n\n")
}
} else {
print("No faces found")
}
}
The properties hasLeftEyePosition and hasRightEyePosition are always true.
Both Eyes Closed
isSmiling false
blinking true
rightEyeClosed true
leftEyeClosed true
Both Eyes Opened
isSmiling false
blinking false
rightEyeClosed false
leftEyeClosed false
Left Eye Closed
isSmiling false
blinking false
rightEyeClosed false
leftEyeClosed false
Right Eye Closed
isSmiling false
blinking false
rightEyeClosed false
leftEyeClosed false