With the release of Xcode 13, a large section of my vision framework processing code became errors and cannot compile. All of these have became deprecated.
This is my original code:
do {
// Perform VNDetectHumanHandPoseRequest
try handler.perform([handPoseRequest])
// Continue only when a hand was detected in the frame.
// Since we set the maximumHandCount property of the request to 1, there will be at most one observation.
guard let observation = handPoseRequest.results?.first else {
self.state = "no hand"
return
}
// Get points for thumb and index finger.
let thumbPoints = try observation.recognizedPoints(forGroupKey: .handLandmarkRegionKeyThumb)
let indexFingerPoints = try observation.recognizedPoints(forGroupKey: .handLandmarkRegionKeyIndexFinger)
let middleFingerPoints = try observation.recognizedPoints(forGroupKey: .handLandmarkRegionKeyMiddleFinger)
let ringFingerPoints = try observation.recognizedPoints(forGroupKey: .handLandmarkRegionKeyRingFinger)
let littleFingerPoints = try observation.recognizedPoints(forGroupKey: .handLandmarkRegionKeyLittleFinger)
let wristPoints = try observation.recognizedPoints(forGroupKey: .all)
// Look for tip points.
guard let thumbTipPoint = thumbPoints[.handLandmarkKeyThumbTIP],
let thumbIpPoint = thumbPoints[.handLandmarkKeyThumbIP],
let thumbMpPoint = thumbPoints[.handLandmarkKeyThumbMP],
let thumbCMCPoint = thumbPoints[.handLandmarkKeyThumbCMC] else {
self.state = "no tip"
return
}
guard let indexTipPoint = indexFingerPoints[.handLandmarkKeyIndexTIP],
let indexDipPoint = indexFingerPoints[.handLandmarkKeyIndexDIP],
let indexPipPoint = indexFingerPoints[.handLandmarkKeyIndexPIP],
let indexMcpPoint = indexFingerPoints[.handLandmarkKeyIndexMCP] else {
self.state = "no index"
return
}
guard let middleTipPoint = middleFingerPoints[.handLandmarkKeyMiddleTIP],
let middleDipPoint = middleFingerPoints[.handLandmarkKeyMiddleDIP],
let middlePipPoint = middleFingerPoints[.handLandmarkKeyMiddlePIP],
let middleMcpPoint = middleFingerPoints[.handLandmarkKeyMiddleMCP] else {
self.state = "no middle"
return
}
guard let ringTipPoint = ringFingerPoints[.handLandmarkKeyRingTIP],
let ringDipPoint = ringFingerPoints[.handLandmarkKeyRingDIP],
let ringPipPoint = ringFingerPoints[.handLandmarkKeyRingPIP],
let ringMcpPoint = ringFingerPoints[.handLandmarkKeyRingMCP] else {
self.state = "no ring"
return
}
guard let littleTipPoint = littleFingerPoints[.handLandmarkKeyLittleTIP],
let littleDipPoint = littleFingerPoints[.handLandmarkKeyLittleDIP],
let littlePipPoint = littleFingerPoints[.handLandmarkKeyLittlePIP],
let littleMcpPoint = littleFingerPoints[.handLandmarkKeyLittleMCP] else {
self.state = "no little"
return
}
guard let wristPoint = wristPoints[.handLandmarkKeyWrist] else {
self.state = "no wrist"
return
}
...
}
Now every line from thumbPoints onwards results in error, I have fixed the first part (not sure if it is correct or not as it cannot compile) to :
let thumbPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.thumb.rawValue)
let indexFingerPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.indexFinger.rawValue)
let middleFingerPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.middleFinger.rawValue)
let ringFingerPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.ringFinger.rawValue)
let littleFingerPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.littleFinger.rawValue)
let wristPoints = try observation.recognizedPoints(forGroupKey: VNHumanHandPoseObservation.JointsGroupName.littleFinger.rawValue)
I tried many different things but just could not get the retrieving individual points to work. Can anyone help on fixing this?