diff --git a/scripts/swift_processors/swift_face.swift b/scripts/swift_processors/swift_face.swift index 47cb8c8c..67a66432 100644 --- a/scripts/swift_processors/swift_face.swift +++ b/scripts/swift_processors/swift_face.swift @@ -152,6 +152,7 @@ struct SwiftFace: ParsableCommand { "bbox": ["x": max(0, faceX), "y": max(0, faceY), "width": faceW, "height": faceH], "confidence": Double(lmObs.confidence), + "captureQuality": Double(lmObs.value(forKey: "faceCaptureQuality") as? Double ?? 0), ] // Pose from landmark observation @@ -219,10 +220,9 @@ struct SwiftFace: ParsableCommand { } if matched { continue } - // Quality filtering for unmatched face rects - uses MIN_CONFIDENCE and MIN_SIZE from outer scope + // Quality filtering for unmatched face rects - let faceConf = Double(faceObs.faceCaptureQuality ?? faceObs.confidence) - if faceConf < MIN_CONFIDENCE { continue } + if faceObs.confidence < MIN_CONFIDENCE { continue } let faceW = Int(fBB.size.width * imgW) let faceH = Int(fBB.size.height * imgH) @@ -235,7 +235,8 @@ struct SwiftFace: ParsableCommand { var faceData: [String: Any] = [ "bbox": ["x": max(0, faceX), "y": max(0, faceY), "width": faceW, "height": faceH], - "confidence": Double(faceObs.faceCaptureQuality ?? faceObs.confidence), + "confidence": Double(faceObs.confidence), + "captureQuality": Double(faceObs.faceCaptureQuality ?? 0), ] if let yaw = faceObs.yaw?.doubleValue, let roll = faceObs.roll?.doubleValue { diff --git a/scripts/swift_processors/swift_face_pose.swift b/scripts/swift_processors/swift_face_pose.swift index 507738ae..3b642e88 100644 --- a/scripts/swift_processors/swift_face_pose.swift +++ b/scripts/swift_processors/swift_face_pose.swift @@ -171,6 +171,7 @@ func processFrameForFace(pixelBuffer: CVPixelBuffer, fps: Float) -> FrameFaceRes "bbox": ["x": max(0, faceX), "y": max(0, faceY), "width": faceW, "height": faceH], "confidence": Double(lmObs.confidence), + "captureQuality": Double(lmObs.value(forKey: "faceCaptureQuality") as? Double ?? 0), ] if let yaw = lmObs.yaw?.doubleValue, @@ -234,8 +235,7 @@ func processFrameForFace(pixelBuffer: CVPixelBuffer, fps: Float) -> FrameFaceRes } if matched { continue } - let faceConf = Double(faceObs.faceCaptureQuality ?? faceObs.confidence) - if faceConf < MIN_CONFIDENCE { continue } + if faceObs.confidence < MIN_CONFIDENCE { continue } let faceW = Int(fBB.size.width * imgW) let faceH = Int(fBB.size.height * imgH) @@ -247,7 +247,8 @@ func processFrameForFace(pixelBuffer: CVPixelBuffer, fps: Float) -> FrameFaceRes var faceData: [String: Any] = [ "bbox": ["x": max(0, faceX), "y": max(0, faceY), "width": faceW, "height": faceH], - "confidence": Double(faceObs.faceCaptureQuality ?? faceObs.confidence), + "confidence": Double(faceObs.confidence), + "captureQuality": Double(faceObs.faceCaptureQuality ?? 0), ] if let yaw = faceObs.yaw?.doubleValue, let roll = faceObs.roll?.doubleValue {