Skip to content

Instantly share code, notes, and snippets.

@eilonkr
Last active May 14, 2022 10:17
Show Gist options
  • Save eilonkr/40faa196edebd0628c84720abb31581a to your computer and use it in GitHub Desktop.
Save eilonkr/40faa196edebd0628c84720abb31581a to your computer and use it in GitHub Desktop.
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