Sonny Sluiter Sonny Sluiter -4 years ago 70
Swift Question

Im creating a facial recognition program and I am getting a Thread BAD EXECUTION error and I don't know what to do

import UIKit
import CoreImage

class ViewController: UIViewController {
@IBOutlet weak var personPic: UIImageView!

override func viewDidLoad() {

personPic.image = UIImage(named: "stupidsonny")


func detect() {
guard let personciImage = CIImage(image: personPic.image!) else { //This line has the error

Answer Source

Either the personPic outlet isn't connected, or the "stupidsonny" image isn't getting found and loaded. It's hard to tell which since they're both being accessed on the same line.

To help narrow it down, you could put a ! where you load the image:

personPic.image = UIImage(named: "stupidsonny")!
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download