Skip to content

Commit

Permalink
Merge pull request #9 from allure-ai/master
Browse files Browse the repository at this point in the history
Implement bounding box calculation on iOS
  • Loading branch information
rodgomesc committed Feb 10, 2022
2 parents cb064da + fefba91 commit 42815a9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ios/VisionCameraFaceDetector.swift
Expand Up @@ -81,8 +81,22 @@ public class VisionCameraFaceDetector: NSObject, FrameProcessorPluginBase {
}

private static func processBoundingBox(from face: Face) -> [String:Any] {
// TODO: implement bounding box calculations
return [:]
let frameRect = face.frame

let offsetX = (frameRect.midX - ceil(frameRect.width)) / 2.0
let offsetY = (frameRect.midY - ceil(frameRect.height)) / 2.0

let x = frameRect.maxX + offsetX
let y = frameRect.minY + offsetY

return [
"x": frameRect.midX + (frameRect.midX - x),
"y": frameRect.midY + (y - frameRect.midY),
"width": frameRect.width,
"height": frameRect.height,
"boundingCenterX": frameRect.midX,
"boundingCenterY": frameRect.midY
]
}

@objc
Expand Down

0 comments on commit 42815a9

Please sign in to comment.