Created
December 15, 2020 18:54
-
-
Save anupamchugh/733947e4f85320aed3c4103fda71f606 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func processPoints(_ points: [CGPoint?]) { | |
let previewLayer = cameraView.previewLayer | |
var pointsConverted: [CGPoint] = [] | |
for point in points { | |
pointsConverted.append(previewLayer.layerPointConverted(fromCaptureDevicePoint: point!)) | |
} | |
let thumbTip = pointsConverted[0] | |
let wrist = pointsConverted[pointsConverted.count - 1] | |
let yDistance = thumbTip.y - wrist.y | |
if(yDistance > 50){ | |
if self.restingHand{ | |
self.restingHand = false | |
self.handDelegate?.thumbsDown() | |
} | |
}else if(yDistance < -50){ | |
if self.restingHand{ | |
self.restingHand = false | |
self.handDelegate?.thumbsUp() | |
} | |
} | |
else{ | |
self.restingHand = true | |
} | |
cameraView.showPoints(pointsConverted) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment