The code below let me take a picture with my camera and put it in an image view. There will also appear some text in a label.
For example: I have some pictures in assets.xcassets from a couple of friends including myself. When I take a picture from myself, the app should scan all the pictures and say: "The person on this picture is me".
How do I have to compare pictures and let's say are 75% equal as each other?
var imagePicker: UIImagePickerController!
@IBOutlet weak var ImageView: UIImageView!
@IBOutlet weak var lblText: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func takeImage(sender: AnyObject) {
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
presentViewController(imagePicker, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
imagePicker.dismissViewControllerAnimated(true, completion: nil)
ImageView.image = info[UIImagePickerControllerOriginalImage] as? UIImage
lblText.text = "The person on this picture is *name person on picture*"
}
@IBAction func resetImage(sender: AnyObject) {
ImageView.image = nil
lblText.text = nil
}