下面的代码让我用相机拍照并将其放在图像视图中。标签中也会出现一些文字。
例如:我在包括我自己在内的几个朋友的assets.xcassets中有一些图片。当我从自己拍照时,应用程序应扫描所有图片并说:“这张照片上的人就是我”。
我如何比较图片,让我们说75%相等?
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
}