Friday, April 17, 2026
HomeiOS Developmentregulate object primarily based on the hand place - iOS Swift

regulate object primarily based on the hand place – iOS Swift

[ad_1]

I’m utilizing VisionKit for hand pose detection and I’m able to obtain it. However once I change the hand place route, picture just isn’t rotated primarily based on the hand route. I’ve posted picture and code under:

func showPoints(_ factors: [CGPoint]) {
    CATransaction.start()
    CATransaction.setDisableActions(true)
    imageLayer.removeFromSuperlayer()
    let picture = UIImage(named: "Watch")
    for level in factors {
        let bounds = factors.scale back(CGRect.null) { rect, level in
            return rect.union(CGRect(origin: level, measurement: .zero))
        }
        if bounds.peak > 100 && bounds.width > 30 {
            imageLayer.bounds = CGRect(x: level.x, y: level.y  , width: bounds.peak , peak: bounds.width)
        } else {
            imageLayer.bounds = CGRect(x: level.x, y: level.y  , width: 100 , peak: 45)
        }
        self.imageLayer.place = CGPoint(x:level.x ,y:level.y + 50)
    }
    // overlayLayer.fillColor = colour.cgColor
    self.imageLayer.contents = picture?.cgImage
              
    overlayLayer.addSublayer(imageLayer)
    CATransaction.commit()
}

enter image description here

I count on the watch needs to be together with the hand and route like under.
enter image description here

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments