Open dcaronson opened 6 years ago
Do you have any solution to this error? I've got it too
Hi, replace .point(at: i)
with normalizedPoints[i]
and for the orientation replace snippet below:
var orientation:Int32 = 0
// detect image orientation, we need it to be accurate for the face detection to work
switch image.imageOrientation {
case .up:
orientation = 1
case .right:
orientation = 6
case .down:
orientation = 3
case .left:
orientation = 8
default:
orientation = 1
}
with my one:
var orientation:CGImagePropertyOrientation = .down
// detect image orientation, we need it to be accurate for the face detection to work
switch image.imageOrientation {
case .up:
orientation = .up
case .right:
orientation = .right
case .down:
orientation = .down
case .left:
orientation = .left
default:
orientation = .down
}
Also, you need to modify the following to in ViewController:imagePickerController()
:
dismiss(animated: true, completion: nil)
if let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as? UIImage {
self.image = image
performSegue(withIdentifier: "showImageSegue", sender: self)
}
Otherwise, the image view will not show the selected image.
Great Face Detection Vision Framework Tutorial!
There are a total of 13 compiler errors.
Cause of the 1st compiler error:
In the ImageViewController, I am receiving the following compiler error: Value of type 'VNFaceLandmarkRegion2D' has no member 'point'
Here is the line of code with the error: let point = landmark.point(at: i)
Here is the correction: let point = landmark.normalizedPoints[i]
Cause of the 2nd compiler error:
In the ImageViewController, I am receiving the following compiler error: Cannot convert value of type 'Int32' to expected argument type 'CGImagePropertyOrientation'
Here is the line of code with the error: let requestHandler = VNImageRequestHandler(cgImage: image.cgImage!, orientation: orientation ,options: [:])
Here is the correction: let requestHandler = VNImageRequestHandler(cgImage: image.cgImage!, orientation: CGImagePropertyOrientation(rawValue: CGImagePropertyOrientation.RawValue(orientation))! ,options: [:])