Post

Replies

Boosts

Views

Activity

Swift - How to detect one eye blink
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 ClosedisSmiling false blinking true rightEyeClosed true leftEyeClosed trueBoth Eyes OpenedisSmiling false blinking false rightEyeClosed false leftEyeClosed falseLeft Eye ClosedisSmiling false blinking false rightEyeClosed false leftEyeClosed falseRight Eye ClosedisSmiling false blinking false rightEyeClosed false leftEyeClosed false
2
0
2.2k
Apr ’20