Last active
May 14, 2022 10:17
-
-
Save eilonkr/40faa196edebd0628c84720abb31581a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { | |
picker.dismiss(animated: true) | |
guard let image = info[.originalImage] as? UIImage else { | |
return | |
} | |
imageView.image = image | |
// layout logic, fit image view size to image ratio... | |
... | |
generateFaceBoundingBoxes(for: image) | |
} | |
func generateFaceBoundingBoxes(for image: UIImage) { | |
debugRectContainerView.subviews.forEach { | |
$0.removeFromSuperview() | |
} | |
for faceRect in self.imageProcessingService.getFaceRects(in: image, normalizedTo: self.imageView.frame) { | |
let rectView = UIView(frame: faceRect) | |
rectView.backgroundColor = nil | |
rectView.layer.borderColor = UIColor.green.cgColor | |
rectView.layer.borderWidth = 1.5 | |
debugRectContainerView.addSubview(rectView) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment