-1
エラーがのライン上にある私は、顔検出にVEAソフトウェアのオフに続いている問題であり、何スレッド1:「ガードしましょう顔画像= CIImage」EXC不正命令(コード= EXC_1386
override func viewDidLoad() {
super.viewDidLoad()
imageView.image = UIImage(named: "FaceDetection") // name of first image to check out
findFace()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func findFace() {
// guard function = if everything equals to nil, then code will break out of function
guard let faceImage = CIImage(image: imageView.image!) else {return}
let accuracy = [CIDetectorAccuracy:CIDetectorAccuracyHigh] // highest accuracy for facial recognition
let faceDector = CIDetector(ofType: CIDetectorTypeFace, context: nil, options: accuracy) // searches for faces in still image/video
let faces = faceDector?.features(in: faceImage, options: [CIDetectorSmile:true, CIDetectorEyeBlink:true])
for face in faces as! [CIFaceFeature] {
if face.hasSmile {
// if face in picture is smiling
print("☺️")
}
if face.leftEyeClosed {
// if left eye is closed on the face in the picture
print("Left:")
}
if face.rightEyeClosed {
// if right eye is closed on the face in the picture
print("Right:")
}
}
if faces!.count != 0 {
// face is only detected
print("Number of Faces: \(faces!.count)")
} else {
// no faces detected
print("No Faces: ")
私はプロジェクトで使用している顔が私の資産フォルダにあります。これは問題の一部ですか? – Terril320
imageView.imageがnilで、強制アンラップされていると、「致命的なエラーが発生しません:オプションの値をアンラップすると予期せぬエラーが発生しました」 – penatheboss
@penatheboss彼はそれを手に入れている。彼はそう言わない。 (彼はそれを探す場所を知らないかもしれません) – matt